emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gptel de6d8089cd 136/273: gptel-transient: Fix system-mess


From: ELPA Syncer
Subject: [nongnu] elpa/gptel de6d8089cd 136/273: gptel-transient: Fix system-message setting function
Date: Wed, 1 May 2024 10:02:15 -0400 (EDT)

branch: elpa/gptel
commit de6d8089cdf68732a3942ef729f774322120175e
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>

    gptel-transient: Fix system-message setting function
    
    gptel-transient.el (gptel--suffix-system-message): Removing the
    `(setf (buffer-local-value ...))` construct (as instructed to by
    the byte compiler) introduced a bug where custom system message
    were set from the wrong buffer.  Handle this correctly to fix #138
    and possibly #140.
---
 gptel-transient.el | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/gptel-transient.el b/gptel-transient.el
index ec18779635..7f22de9725 100644
--- a/gptel-transient.el
+++ b/gptel-transient.el
@@ -525,7 +525,9 @@ This uses the prompts in the variable
       (insert
        "# Insert your system message below and press "
        (propertize "C-c C-c" 'face 'help-key-binding)
-       " when ready.\n"
+       " when ready, or "
+       (propertize "C-c C-k" 'face 'help-key-binding)
+       " to abort.\n"
        "# Example: You are a helpful assistant. Answer as concisely as 
possible.\n"
        "# Example: Reply only with shell commands and no prose.\n"
        "# Example: You are a poet. Reply only in verse.\n\n")
@@ -540,19 +542,25 @@ This uses the prompts in the variable
                       `((display-buffer-below-selected)
                         (body-function . ,#'select-window)
                         (window-height . ,#'fit-window-to-buffer)))
-      (local-set-key (kbd "C-c C-c")
-                     (lambda ()
-                       (interactive)
-                       (with-current-buffer orig-buf
-                         (setq gptel--system-message
-                               (buffer-substring msg-start (point-max))))
-                       (quit-window)
-                       (display-buffer
-                        orig-buf
-                        `((display-buffer-reuse-window
-                           display-buffer-use-some-window)
-                          (body-function . ,#'select-window)))
-                       (call-interactively #'gptel-menu))))))
+      (let ((quit-to-menu
+             (lambda ()
+               (interactive)
+               (quit-window)
+               (display-buffer
+                orig-buf
+                `((display-buffer-reuse-window
+                   display-buffer-use-some-window)
+                  (body-function . ,#'select-window)))
+               (call-interactively #'gptel-menu))))
+        (local-set-key (kbd "C-c C-c")
+                       (lambda ()
+                         (interactive)
+                         (let ((system-message
+                                (buffer-substring msg-start (point-max))))
+                           (with-current-buffer orig-buf
+                             (setq gptel--system-message system-message)))
+                         (funcall quit-to-menu)))
+        (local-set-key (kbd "C-c C-k") quit-to-menu)))))
 
 ;; ** Suffixes for rewriting/refactoring
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]