Skip to content

Commit eef4279

Browse files
committed
Add recursive mode to ellama-context-add-directory.
Also, add ellama-context-add-directory-recursive for interactive use.
1 parent a5bea6d commit eef4279

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

ellama-context.el

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,13 +723,22 @@ the context."
723723
(ellama-context-element-add element)))
724724

725725
;;;###autoload
726-
(defun ellama-context-add-directory (dir)
727-
"Add all files in DIR to the context."
726+
(defun ellama-context-add-directory (dir &optional recursive)
727+
"Add all files in DIR to the context. Exclude dot-files. Include subdirs if RECURSIVE is 't."
728728
(interactive "DSelect directory: ")
729729
(dolist (file-name (directory-files dir t "^[^\.].*"))
730-
(unless (file-directory-p file-name)
730+
(cond
731+
((file-regular-p file-name)
731732
(let ((element (ellama-context-element-file :name file-name)))
732-
(ellama-context-element-add element)))))
733+
(ellama-context-element-add element)))
734+
((and (file-directory-p file-name) recursive)
735+
(ellama-context-add-directory file-name 't)))))
736+
737+
;;;###autoload
738+
(defun ellama-context-add-directory-recursive (dir)
739+
"Add all files in DIR to the context. Exclude dot-files. Include all subdirs."
740+
(interactive "DSelect directory: ")
741+
(ellama-context-add-directory dir 't))
733742

734743
;;;###autoload
735744
(defun ellama-context-add-selection ()

0 commit comments

Comments
 (0)