Skip to content

Commit

Permalink
gptel-context: Support adding files in directories to context
Browse files Browse the repository at this point in the history
  • Loading branch information
benthamite committed Oct 26, 2024
1 parent 73bcc68 commit 6b2c0b9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions gptel-context.el
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ context chunk. This is accessible as, for example:
context. If there is already a gptel context at point, remove it
instead.
- If in Dired, add marked files or file at point to the context.
With negative prefix ARG, remove them from the context instead.
- If in Dired, add marked files or file at point to the context. If
the file at point is a directory, or directories are marked,
recursively add all their files. With negative prefix ARG, remove
them from the context instead.
- Otherwise add the current buffer to the context. With positive
prefix ARG, prompt for a buffer name and add it to the context.
Expand All @@ -110,10 +112,14 @@ context chunk. This is accessible as, for example:
(message "Current region added as context."))
;; If in dired
((derived-mode-p 'dired-mode)
(mapc (if (and arg (< (prefix-numeric-value arg) 0))
#'gptel-context-remove
(let ((files (cl-loop for file in (dired-get-marked-files)
if (file-directory-p file)
append (directory-files-recursively file "." t)
else collect file)))
(mapc (if (and arg (< (prefix-numeric-value arg) 0))
#'gptel-context-remove
#'gptel-context-add-file)
(dired-get-marked-files)))
(cl-remove-if #'file-directory-p files))))
;; If in an image buffer
((and (derived-mode-p 'image-mode)
(gptel--model-capable-p 'media;)
Expand Down

0 comments on commit 6b2c0b9

Please sign in to comment.