Skip to content

Commit

Permalink
fix: recursive directories
Browse files Browse the repository at this point in the history
  • Loading branch information
heraplem authored Sep 7, 2024
1 parent fb9a833 commit 0f1786b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
19 changes: 11 additions & 8 deletions citar-file.el
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,16 @@ whether entries have associated files."
(when citar-file-variable
(lambda (citekey) (and (citar-get-value citar-file-variable citekey) t))))

(defun citar--library-dirs ()
(defun citar-file--library-dirs ()
"Return all directories to be searched for library files."
(mapcar (lambda (dir)
(cons dir (when citar-library-paths-recursive
(directory-files-recursively dir "" :include-directories
#'file-directory-p))))
citar-library-paths))
(apply #'append
(mapcar (lambda (dir)
(cons dir
(when citar-library-paths-recursive
(seq-filter #'file-directory-p
(directory-files-recursively dir ""
:include-directories)))))
citar-library-paths)))

(defun citar-file--get-from-file-field (&optional keys)
"Return files for KEYS by parsing the `citar-file-variable' field.
Expand All @@ -200,7 +203,7 @@ files associated with KEYS."
(when-let ((filefield citar-file-variable))
(citar--check-configuration 'citar-library-paths 'citar-library-file-extensions
'citar-file-parser-functions)
(let ((dirs (append (citar--library-dirs)
(let ((dirs (append (citar-file--library-dirs)
(mapcar #'file-name-directory (citar--bibliography-files)))))
(citar--get-resources-using-function
(lambda (citekey entry)
Expand All @@ -221,7 +224,7 @@ files associated with KEYS."
"Return list of files for KEYS in ENTRIES."
(citar--check-configuration 'citar-library-paths 'citar-library-file-extensions)
(citar-file--directory-files
citar-library-paths keys citar-library-file-extensions
(citar-file--library-dirs) keys citar-library-file-extensions
citar-file-additional-files-separator))

(defun citar-file--make-filename-regexp (keys extensions &optional additional-sep)
Expand Down
7 changes: 4 additions & 3 deletions citar.el
Original file line number Diff line number Diff line change
Expand Up @@ -1352,9 +1352,10 @@ it.
SOURCE-PLIST must be as specified in the documentation of
`citar-add-file-sources'."
(let* ((directory (if (cdr citar-library-paths)
(completing-read "Directory: " citar-library-paths)
(car citar-library-paths)))
(let* ((dirs (citar-file--library-dirs))
(directory (if (cdr dirs)
(completing-read "Directory: " dirs)
(car dirs)))
(extension (or (plist-get source-plist :extension)
(read-string "File extension: ")))
(destfile (expand-file-name citekey directory))
Expand Down

0 comments on commit 0f1786b

Please sign in to comment.