branch: elpa/gptel
commit 5ea747af3370ae9937b69042b43e50139cce73c0
Author: Karthik Chikmagalur <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel-request: Move response hooks to gptel
Move gptel's response hooks to the gptel library from
gptel-request. These hooks are relevant only to the handlers of
`gptel-send', so moving them further separates the gptel-request
and gptel features.
* gptel-request.el: (gptel-pre-response-hook,
gptel-post-response-hook, gptel-post-response-functions,
gptel-post-stream-hook, gptel-prompt-prefix-alist): Move out of
this file.
* gptel.el: (gptel-pre-response-hook, gptel-post-response-hook,
gptel-post-response-functions, gptel-post-stream-hook): Move into
this file.
---
gptel-request.el | 45 ---------------------------------------------
gptel.el | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 45 deletions(-)
diff --git a/gptel-request.el b/gptel-request.el
index 7f20543e5e1..3623692bb25 100644
--- a/gptel-request.el
+++ b/gptel-request.el
@@ -193,51 +193,6 @@ filter LLM response text, either use `gptel-request' with a
custom callback, or use `gptel-post-response-functions'."
"0.9.7")
-(defcustom gptel-pre-response-hook nil
- "Hook run before inserting the LLM response into the current buffer.
-
-This hook is called in the buffer where the LLM response will be
-inserted.
-
-Note: this hook only runs if the request succeeds."
- :type 'hook)
-
-(define-obsolete-variable-alias
- 'gptel-post-response-hook 'gptel-post-response-functions
- "0.6.0"
- "Post-response functions are now called with two arguments: the
-start and end buffer positions of the response.")
-
-(defcustom gptel-post-response-functions nil
- "Abnormal hook run after inserting the LLM response into the current buffer.
-
-This hook is called in the buffer to which the LLM response is
-sent, and after the full response has been inserted. Each
-function is called with two arguments: the response beginning and
-end positions.
-
-Note: this hook runs even if the request fails. In this case the
-response beginning and end positions are both the cursor position
-at the time of the request."
- :type 'hook)
-
-(add-hook 'gptel-post-response-functions 'pulse-momentary-highlight-region 70)
-
-;; (defcustom gptel-pre-stream-insert-hook nil
-;; "Hook run before each insertion of the LLM's streaming response.
-
-;; This hook is called in the buffer from which the prompt was sent
-;; to the LLM, immediately before text insertion."
-;; :group 'gptel
-;; :type 'hook)
-
-(defcustom gptel-post-stream-hook nil
- "Hook run after each insertion of the LLM's streaming response.
-
-This hook is called in the buffer from which the prompt was sent
-to the LLM, and after a text insertion."
- :type 'hook)
-
;; TODO: Handle `prog-mode' using the `comment-start' variable
(defcustom gptel-prompt-prefix-alist
'((markdown-mode . "### ")
diff --git a/gptel.el b/gptel.el
index 3d96e33a092..dec08d43eea 100644
--- a/gptel.el
+++ b/gptel.el
@@ -224,6 +224,46 @@
;;; User options
+(defcustom gptel-pre-response-hook nil
+ "Hook run before inserting the LLM response into the current buffer.
+
+This hook is called in the buffer where the LLM response will be
+inserted.
+
+Note: this hook only runs if the request succeeds."
+ :type 'hook
+ :group 'gptel)
+
+(define-obsolete-variable-alias
+ 'gptel-post-response-hook 'gptel-post-response-functions
+ "0.6.0"
+ "Post-response functions are now called with two arguments: the
+start and end buffer positions of the response.")
+
+(defcustom gptel-post-response-functions nil
+ "Abnormal hook run after inserting the LLM response into the current buffer.
+
+This hook is called in the buffer to which the LLM response is
+sent, and after the full response has been inserted. Each
+function is called with two arguments: the response beginning and
+end positions.
+
+Note: this hook runs even if the request fails. In this case the
+response beginning and end positions are both the cursor position
+at the time of the request."
+ :type 'hook
+ :group 'gptel)
+
+(add-hook 'gptel-post-response-functions 'pulse-momentary-highlight-region 70)
+
+(defcustom gptel-post-stream-hook nil
+ "Hook run after each insertion of the LLM's streaming response.
+
+This hook is called in the buffer from which the prompt was sent
+to the LLM, and after a text insertion."
+ :type 'hook
+ :group 'gptel)
+
(defcustom gptel-save-state-hook nil
"Hook run before gptel saves model parameters to a file.