From fb9a833dfdbd0052318cdf9c336c6748d4fd1c26 Mon Sep 17 00:00:00 2001 From: heraplem Date: Thu, 5 Sep 2024 15:00:04 +0200 Subject: [PATCH] feat: enable recursive library paths Fix #839 --- citar-file.el | 11 ++++++++++- citar.el | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/citar-file.el b/citar-file.el index 3396d277..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) @@ -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. @@ -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) 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.