[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gptel 57a70c23cb 131/273: gptel: Skip to end of word befor
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gptel 57a70c23cb 131/273: gptel: Skip to end of word before sending |
Date: |
Wed, 1 May 2024 10:02:13 -0400 (EDT) |
branch: elpa/gptel
commit 57a70c23cb1e71dd32594692a060378a7d49d02f
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
gptel: Skip to end of word before sending
* gptel.el (gptel--at-word-end, gptel-send, gptel-request):
Include the word the cursor is on in the prompt, and don't break
it when inserting the response. This is primarily useful for
evil-mode users who frequenty end up one char before the end of a
word when they switch to normal-mode.
* gptel-transient.el (gptel-send): Same. Also fix bug with
selecting an existing buffer to send the response to.
---
gptel-transient.el | 6 +++---
gptel.el | 10 ++++++++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/gptel-transient.el b/gptel-transient.el
index 30496a82a5..ec18779635 100644
--- a/gptel-transient.el
+++ b/gptel-transient.el
@@ -415,7 +415,7 @@ will get progressively longer!"
'gptel)
t))
(point))
- (point))))))
+ (gptel--at-word-end (point)))))))
(with-current-buffer buffer
(setq gptel-backend backend)
(gptel--update-header-line " Waiting..." 'warning)
@@ -423,7 +423,7 @@ will get progressively longer!"
(setq output-to-other-buffer-p t))
((setq gptel-buffer-name
(cl-some (lambda (s) (and (string-prefix-p "e" s)
- (substring s 2)))
+ (substring s 1)))
args))
(setq buffer (get-buffer gptel-buffer-name))
(setq output-to-other-buffer-p t)
@@ -440,7 +440,7 @@ will get progressively longer!"
'gptel)
t))
(point))
- (point))))))
+ (gptel--at-word-end (point)))))))
(with-current-buffer buffer
(goto-char (point-max))
(if (or buffer-read-only
diff --git a/gptel.el b/gptel.el
index c91db7128c..3d019069c3 100644
--- a/gptel.el
+++ b/gptel.el
@@ -387,6 +387,12 @@ and \"apikey\" as USER."
"Ensure VAL is a number."
(if (stringp val) (string-to-number val) val))
+(defmacro gptel--at-word-end (&rest body)
+ "Execute BODY at end of the current word or punctuation."
+ `(save-excursion
+ (skip-syntax-forward "w.")
+ ,@body))
+
(defun gptel-prompt-string ()
(or (alist-get major-mode gptel-prompt-prefix-alist) ""))
@@ -621,7 +627,7 @@ Model parameters can be let-bound around calls to this
function."
((null position)
(if (use-region-p)
(set-marker (make-marker) (region-end))
- (point-marker)))
+ (gptel--at-word-end (point-marker))))
((markerp position) position)
((integerp position)
(set-marker (make-marker) position buffer))))
@@ -658,7 +664,7 @@ instead."
(let* ((response-pt
(if (use-region-p)
(set-marker (make-marker) (region-end))
- (point-marker)))
+ (gptel--at-word-end (point-marker))))
(gptel-buffer (current-buffer))
(full-prompt (gptel--create-prompt response-pt)))
(funcall
- [nongnu] elpa/gptel 9bc54bed9c 244/273: gptel-transient: Remove "-ts" suffix from major mode (#259), (continued)
- [nongnu] elpa/gptel 9bc54bed9c 244/273: gptel-transient: Remove "-ts" suffix from major mode (#259), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 9a5a4a60d5 248/273: README: Mention wiki entry on saving transient flags, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 8dbcbbb908 256/273: gptel-org: Move session save/restore code for Org, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 1b47235e25 071/273: README: Add section on gptel-request, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel bb8b37d8c0 100/273: gptel, gptel-curl: Fix byte-compile warnings, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 219e163dc7 091/273: gptel-curl: Add gptel-abort, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel a660e13a8b 106/273: gptel, gptel-transient: Fix read temperature from minibuffer (#85), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel c0ffce0849 110/273: gptel: Fix reading bounds in org files (#98), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 648fa228a1 115/273: gptel: Fix check for markdown-mode (#109), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 63027083cd 125/273: README: Update additional customization section, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 57a70c23cb 131/273: gptel: Skip to end of word before sending,
ELPA Syncer <=
- [nongnu] elpa/gptel 1434bbac7b 122/273: gptel-ollama, gptel-openai: Add example of backend creation, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 8973498378 151/273: gptel: Add minimal status indicator via mode-line-process, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 3dd00a7457 145/273: gptel-gemini: Add streaming responses, simplify configuration, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 8d3e08faa8 157/273: gptel: Don't use called-interactively-p, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel febeada960 172/273: gptel: Make gptel-backend customizable, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 612aea3456 178/273: gptel: Make gptel-post-response-* easier to use, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel f7ba368c38 055/273: gptel: More flexible callbacks, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 1a554785e8 149/273: gptel-curl: Remove redundant calls to insert-response, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 2e92c0303c 156/273: gptel: gptel-backend-url can accept functions, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 2c87acddd5 200/273: gptel: Add request logging (Fix #165), ELPA Syncer, 2024/05/01