Variable: gptel-context
gptel-context is a customizable variable defined in gptel-request.el.
Value
nil
Documentation
List of gptel's context sources.
The items in this list (file names or buffers) are included with gptel queries as additional context.
Each entry can be a file path (string) or a buffer (object, not buffer name):
'("~/path/to/file1"
"./file2"
#<buffer *scratch*>
...)
The above covers the most common cases. You can also specify context sources in a more targeted way, with entries of the form
(<buffer> . spec)
("/path/to/file" . spec)
where spec is a plist declaring specific parts of the buffer/file to include instead of the entire text.
For buffers, you can specify regions to include using buffer spans and line number ranges as conses, and overlays as a list:
(<buffer> :bounds ((start1 . end1) (start2 . end2) ...)
:lines ((from1 . to1) (from2 . end2) ...)
:overlays (ov1 ov2 ...))
For files, spec can include buffer spans and line number ranges, as well as the MIME type of the file:
("/path/to/file" :bounds ((start1 . end1) (start2 . end2) ...)
:lines ((from1 . to1) (from2 . end2) ...)
:mime "image/png")
gptel tries to guess file MIME types, but is not always successful, so it is recommended to provide it with non-text files.
Usage of context commands (such as gptel-add and gptel-add-file)
will modify this variable. You can also set this variable
buffer-locally, or let-bind it around calls to gptel queries, or via
gptel presets with the :context key.
Aliases
gptel-context--alist (obsolete since 0.9.9.3)
Source Code
;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel-request.el
(defcustom gptel-context nil
"List of gptel's context sources.
The items in this list (file names or buffers) are included with gptel
queries as additional context.
Each entry can be a file path (string) or a buffer (object, not buffer
name):
\\='(\"~/path/to/file1\"
\"./file2\"
#<buffer *scratch*>
...)
The above covers the most common cases. You can also specify context
sources in a more targeted way, with entries of the form
(<buffer> . spec)
(\"/path/to/file\" . spec)
where spec is a plist declaring specific parts of the buffer/file to
include instead of the entire text.
For buffers, you can specify regions to include using buffer spans and
line number ranges as conses, and overlays as a list:
(<buffer> :bounds ((start1 . end1) (start2 . end2) ...)
:lines ((from1 . to1) (from2 . end2) ...)
:overlays (ov1 ov2 ...))
For files, spec can include buffer spans and line number ranges, as well as
the MIME type of the file:
(\"/path/to/file\" :bounds ((start1 . end1) (start2 . end2) ...)
:lines ((from1 . to1) (from2 . end2) ...)
:mime \"image/png\")
gptel tries to guess file MIME types, but is not always successful, so
it is recommended to provide it with non-text files.
Usage of context commands (such as `gptel-add' and `gptel-add-file')
will modify this variable. You can also set this variable
buffer-locally, or let-bind it around calls to gptel queries, or via
gptel presets with the :context key."
:type '(repeat string))