Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable recursive library paths #840

Merged
merged 2 commits into from
Sep 5, 2024
Merged
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
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
Loading