Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions ellama-context.el
Original file line number Diff line number Diff line change
Expand Up @@ -723,13 +723,28 @@ the context."
(ellama-context-element-add element)))

;;;###autoload
(defun ellama-context-add-directory (dir)
"Add all files in DIR to the context."
(defun ellama-context-add-directory (dir &optional recursive)
"Add all files in DIR to the context.
Exclude dot-files. Include subdirs if RECURSIVE is t."
(interactive "DSelect directory: ")
(dolist (file-name (directory-files dir t "^[^\.].*"))
(unless (file-directory-p file-name)
(let ((element (ellama-context-element-file :name file-name)))
(ellama-context-element-add element)))))
(let ((rec
(or recursive
(transient-arg-value "recursive"
(transient-args transient-current-command)))))
(dolist (file-name (directory-files dir t "^[^\.].*"))
(cond
((file-regular-p file-name)
(let ((element (ellama-context-element-file :name file-name)))
(ellama-context-element-add element)))
((and (file-directory-p file-name) rec)
(ellama-context-add-directory file-name 't))))))

;;;###autoload
(defun ellama-context-add-directory-recursive (dir)
"Add all files in DIR to the context.
Exclude dot-files. Include all subdirs."
(interactive "DSelect directory: ")
(ellama-context-add-directory dir 't))

;;;###autoload
(defun ellama-context-add-selection ()
Expand Down
1 change: 1 addition & 0 deletions ellama-transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ Otherwise, prompt the user to enter a system message."
(buffer-substring (point-min) (point-max)))))
["Add"
("b" "Add Buffer" ellama-context-add-buffer)
("-r" "Recursive mode for `Add Directory'" "recursive")
("d" "Add Directory" ellama-context-add-directory)
("f" "Add File" ellama-context-add-file)
("s" "Add Selection" ellama-context-add-selection)
Expand Down