[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gptel c22c59d20a 061/273: gptel: Add post-response hook an
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gptel c22c59d20a 061/273: gptel: Add post-response hook and fix org converter |
Date: |
Wed, 1 May 2024 10:01:43 -0400 (EDT) |
branch: elpa/gptel
commit c22c59d20ad3425225865c36e2635a319a490d92
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
gptel: Add post-response hook and fix org converter
* gptel.el (gptel--convert-playback-markdown->org,
gptel-post-response-hook): Add a hook that runs after the response
is received. This will allow for custom actions like moving the
cursor to the next prompt. The markdown->org stream converter now
cleans up after itself using this hook.
---
gptel.el | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/gptel.el b/gptel.el
index 18ed080db3..d1ded40665 100644
--- a/gptel.el
+++ b/gptel.el
@@ -104,6 +104,14 @@ return the transformed string."
:group 'gptel
:type 'hook)
+(defcustom gptel-post-response-hook nil
+ "Hook run after inserting ChatGPT's response into the current buffer.
+
+This hook is called in the buffer from which the prompt was sent
+to ChatGPT. Note: this hook runs even if the request fails."
+ :group 'gptel
+ :type 'hook)
+
(defvar gptel-default-session "*ChatGPT*")
(defvar gptel-default-mode (if (featurep 'markdown-mode)
'markdown-mode
@@ -551,10 +559,21 @@ elements."
(buffer-string)))
(defun gptel--convert-playback-markdown->org ()
- ""
- (let ((in-src-block)
- (temp-buf (generate-new-buffer-name "*gptel-temp*"))
- (start-pt (make-marker)))
+ "Return a Markdown to Org converter.
+
+This function parses a stream of Markdown text to Org
+continuously when it is called with successive chunks of the
+text stream."
+ (letrec ((in-src-block)
+ (temp-buf (generate-new-buffer-name "*gptel-temp*"))
+ (start-pt (make-marker))
+ (cleanup-fn
+ (lambda ()
+ (when (buffer-live-p (get-buffer temp-buf))
+ (set-marker start-pt nil)
+ (kill-buffer temp-buf))
+ (remove-hook 'gptel-post-response-hook cleanup-fn))))
+ (add-hook 'gptel-post-response-hook cleanup-fn)
(lambda (str)
(let ((noop-p))
(with-current-buffer (get-buffer-create temp-buf)
- [nongnu] elpa/gptel 49cfc78378 203/273: gptel: Add page boundaries, restructure files, (continued)
- [nongnu] elpa/gptel 49cfc78378 203/273: gptel: Add page boundaries, restructure files, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 0d6264f268 214/273: gptel-curl: Adjust response beginning position, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 39376aa3f4 020/273: gptel-transient: Add transient menus for setting parameters, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel dfca03a266 028/273: LICENSE: Add GPLv3 license, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 048eaf9b64 044/273: README: Update description of chat parameters, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 051501c892 035/273: README: Change installation instructions (no aio), ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 1ab8a57183 051/273: add installation instructions, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel cd22ea836c 045/273: Add autoload for gptel-send, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel f843614f5b 048/273: gptel: Set gptel-api-key if reading from minibuffer, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel a500c76a68 053/273: Encode a lambda-provided API key as utf-8, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel c22c59d20a 061/273: gptel: Add post-response hook and fix org converter,
ELPA Syncer <=
- [nongnu] elpa/gptel 1cd0f58552 067/273: gptel-curl: Better error handling when streaming, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 44045be327 072/273: gptel: gptel-mode is local by default, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel a43f5ac5fa 064/273: gptel: Rename stream-related vars and defuns, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 2e34981aa0 062/273: gptel: Rename :insert-marker, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 23332a9bc5 077/273: gptel-transient: Add outline-minor-mode support, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 00abbf7597 081/273: gptel-transient: More visual feedback, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 444a43134f 083/273: gptel-curl: Fix current-buffer for Curl requests, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 37c381c2e5 092/273: README: Update with acknowledgments and more, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel d13b0c4ab7 088/273: gptel-transient: Fix gptel-system-prompt, ELPA Syncer, 2024/05/01
- [nongnu] elpa/gptel 6202474a6e 080/273: README: Update with changes to gptel-menu, ELPA Syncer, 2024/05/01