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

    gptel: Set default for gptel-prompt-transform-functions
    
    * gptel.el (gptel-prompt-transform-functions): Set the default
    transformers/augmentors.  They (i) apply any preset included at the
    beginning of the prompt (via `@preset`) and (ii) add gptel's
    context to the prompt buffer.
    
    Note that `gptel-prompt-transform-functions' (or a list containing
    augmentors) needs to be passed explicitly to `gptel-request' (via
    the `:transforms' argument) for it to take effect.  `gptel-send'
    does this.  It is not read from the environment as this can have
    unexpected side-effects when using `gptel-request' as a library.
---
 gptel.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/gptel.el b/gptel.el
index e556e83b95..54a9f32a19 100644
--- a/gptel.el
+++ b/gptel.el
@@ -289,12 +289,19 @@ 
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-process
 (define-obsolete-variable-alias 'gptel-prompt-filter-hook
   'gptel-prompt-transform-functions "0.9.9")
 
-(defcustom gptel-prompt-transform-functions nil
+(defcustom gptel-prompt-transform-functions
+  '(gptel--transform-apply-preset gptel--transform-add-context)
   "Handlers to augment or transform a query before sending it.
 
 This hook is called in a temporary buffer containing the text to
 be sent, with the cursor at the end of the prompt.  You can use
-it to modify the buffer as required.
+it to modify the buffer or buffer-local variables as required.
+
+Since these functions modify the prompt construction buffer, the order
+in which they run is significant!  In particular, you may want to add
+your function before (the default) or after
+`gptel--transform-add-context', which adds gptel's context (other
+buffers, files etc) to this buffer.
 
 Example: A typical use case might be to search for occurrences of $(cmd)
 and replace it with the output of the shell command cmd, making it easy

Reply via email to