From 5084125d9357fae5cc8e3b2731a52406612c3b67 Mon Sep 17 00:00:00 2001 From: Nicholas Coltharp Date: Thu, 5 Sep 2024 13:06:51 +0200 Subject: [PATCH 1/2] feat: enable recursive library paths --- citar-file.el | 10 +++++++++- citar.el | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/citar-file.el b/citar-file.el index 3396d277..a3e84f7e 100644 --- a/citar-file.el +++ b/citar-file.el @@ -177,6 +177,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. @@ -191,7 +199,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) diff --git a/citar.el b/citar.el index a62908d7..6f09e338 100644 --- a/citar.el +++ b/citar.el @@ -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. From 5a6c8514d82bfdd625b60a2be0dd814120ffefc1 Mon Sep 17 00:00:00 2001 From: Nicholas Coltharp Date: Thu, 5 Sep 2024 14:35:49 +0200 Subject: [PATCH 2/2] fix: byte-compiler error --- citar-file.el | 1 + 1 file changed, 1 insertion(+) diff --git a/citar-file.el b/citar-file.el index a3e84f7e..25346603 100644 --- a/citar-file.el +++ b/citar-file.el @@ -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)