diff --git a/bibtex-completion.el b/bibtex-completion.el index 19076a5..0825b97 100644 --- a/bibtex-completion.el +++ b/bibtex-completion.el @@ -762,6 +762,24 @@ Returns nil if no PDF is found." (or (bibtex-completion-find-pdf-in-field key-or-entry) (bibtex-completion-find-pdf-in-library key-or-entry find-additional))) +(defun bibtex-completion-find-note-file-default (entry-key) + "Find note file associated from BibTeX’s ENTRY-KEY in the default directory. +The default directory is `bibtex-completion-notes-path'. If the +note file doesn’t exist, return nil." + (and bibtex-completion-notes-path + (f-directory? bibtex-completion-notes-path) + (f-file? (f-join bibtex-completion-notes-path + (s-concat entry-key + bibtex-completion-notes-extension))))) + +(defcustom bibtex-completion-find-note-file-fns + (list #'bibtex-completion-find-note-file-default) + "List of functions to use to find note files. +The functions should accept one argument: the entry-key of the +BibTeX entry." + :group 'bibtex-completion + :type 'list) + (defun bibtex-completion-prepare-entry (entry &optional fields do-not-find-pdf) "Prepare ENTRY for display. ENTRY is an alist representing an entry as returned by @@ -781,11 +799,10 @@ find a PDF file." ; Check for notes: (entry (if (or ;; One note file per entry: - (and bibtex-completion-notes-path - (f-directory? bibtex-completion-notes-path) - (f-file? (f-join bibtex-completion-notes-path - (s-concat entry-key - bibtex-completion-notes-extension)))) + (cl-some #'identity + (mapcar (lambda (fn) + (funcall fn entry-key)) + bibtex-completion-find-note-file-fns)) ;; All notes in one file: (and bibtex-completion-notes-path (f-file? bibtex-completion-notes-path) @@ -795,7 +812,7 @@ find a PDF file." ; Remove unwanted fields: (entry (if fields (--filter (member-ignore-case (car it) fields) entry) - entry))) + entry))) ;; Normalize case of entry type: (setcdr (assoc "=type=" entry) (downcase (cdr (assoc "=type=" entry)))) ;; Remove duplicated fields: