Skip to content

Commit

Permalink
feat: enable recursive library paths
Browse files Browse the repository at this point in the history
Fix #839
  • Loading branch information
heraplem authored Sep 5, 2024
1 parent 07d2a63 commit fb9a833
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion citar-file.el
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ separator that does not otherwise occur in citation keys."

(defvar citar-notes-paths)
(defvar citar-library-paths)
(defvar citar-library-paths-recursive)
(defvar citar-library-file-extensions)
(defvar citar-note-format-function)

Expand Down Expand Up @@ -177,6 +178,14 @@ whether entries have associated files."
(when citar-file-variable
(lambda (citekey) (and (citar-get-value citar-file-variable citekey) t))))

(defun citar--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))

(defun citar-file--get-from-file-field (&optional keys)
"Return files for KEYS by parsing the `citar-file-variable' field.
Expand All @@ -191,7 +200,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-paths
(let ((dirs (append (citar--library-dirs)
(mapcar #'file-name-directory (citar--bibliography-files)))))
(citar--get-resources-using-function
(lambda (citekey entry)
Expand Down
5 changes: 5 additions & 0 deletions citar.el
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ buffer.")
:group 'citar
:type '(repeat directory))

(defcustom citar-library-paths-recursive nil
"Whether library paths should be searched recursively."
:group 'citar
:type 'boolean)

(defcustom citar-library-file-extensions nil
"List of file extensions to filter for related files.
Expand Down

0 comments on commit fb9a833

Please sign in to comment.