Skip to content

Commit 34e249a

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 34e249a

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

ellama-context.el

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,13 +723,24 @@ 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.
728+
Exclude dot-files. Include subdirs if RECURSIVE is 't."
728729
(interactive "DSelect directory: ")
729730
(dolist (file-name (directory-files dir t "^[^\.].*"))
730-
(unless (file-directory-p file-name)
731+
(cond
732+
((file-regular-p file-name)
731733
(let ((element (ellama-context-element-file :name file-name)))
732-
(ellama-context-element-add element)))))
734+
(ellama-context-element-add element)))
735+
((and (file-directory-p file-name) recursive)
736+
(ellama-context-add-directory file-name 't)))))
737+
738+
;;;###autoload
739+
(defun ellama-context-add-directory-recursive (dir)
740+
"Add all files in DIR to the context.
741+
Exclude dot-files. Include all subdirs."
742+
(interactive "DSelect directory: ")
743+
(ellama-context-add-directory dir 't))
733744

734745
;;;###autoload
735746
(defun ellama-context-add-selection ()

0 commit comments

Comments
 (0)