Skip to content

Commit fb9a833

Browse files
author
heraplem
authored
feat: enable recursive library paths
Fix #839
1 parent 07d2a63 commit fb9a833

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

citar-file.el

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ separator that does not otherwise occur in citation keys."
8080

8181
(defvar citar-notes-paths)
8282
(defvar citar-library-paths)
83+
(defvar citar-library-paths-recursive)
8384
(defvar citar-library-file-extensions)
8485
(defvar citar-note-format-function)
8586

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

181+
(defun citar--library-dirs ()
182+
"Return all directories to be searched for library files."
183+
(mapcar (lambda (dir)
184+
(cons dir (when citar-library-paths-recursive
185+
(directory-files-recursively dir "" :include-directories
186+
#'file-directory-p))))
187+
citar-library-paths))
188+
180189
(defun citar-file--get-from-file-field (&optional keys)
181190
"Return files for KEYS by parsing the `citar-file-variable' field.
182191
@@ -191,7 +200,7 @@ files associated with KEYS."
191200
(when-let ((filefield citar-file-variable))
192201
(citar--check-configuration 'citar-library-paths 'citar-library-file-extensions
193202
'citar-file-parser-functions)
194-
(let ((dirs (append citar-library-paths
203+
(let ((dirs (append (citar--library-dirs)
195204
(mapcar #'file-name-directory (citar--bibliography-files)))))
196205
(citar--get-resources-using-function
197206
(lambda (citekey entry)

citar.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ buffer.")
9191
:group 'citar
9292
:type '(repeat directory))
9393

94+
(defcustom citar-library-paths-recursive nil
95+
"Whether library paths should be searched recursively."
96+
:group 'citar
97+
:type 'boolean)
98+
9499
(defcustom citar-library-file-extensions nil
95100
"List of file extensions to filter for related files.
96101

0 commit comments

Comments
 (0)