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

fix: change functions to take entry, decouple cache from formatting #281

Merged
merged 11 commits into from
Sep 14, 2021
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:CUSTOM_ID: features
:END:

This package provides a completing-read front-end to browse and act on BibTeX, BibLaTeX, and CSL JSON bibliographic data.
This package provides a completing-read front-end to browse and act on BibTeX, BibLaTeX, and CSL JSON bibliographic data, and LaTeX, markdown, and org-cite editing support.

When used with vertico (or selectrum), embark, and marginalia, it provides similar functionality to helm-bibtex and ivy-bibtex: quick filtering and selecting of bibliographic entries from the minibuffer, and the option to run different commands against them.

Expand Down
24 changes: 12 additions & 12 deletions bibtex-actions-file.el
Original file line number Diff line number Diff line change
Expand Up @@ -91,29 +91,29 @@ use 'orb-edit-note' for this value."
(expand-file-name file dir)) files))
dirs)))

(defun bibtex-actions-file--possible-names (key dirs extensions)
"Possible names for files correponding to KEY with EXTENSIONS in DIRS."
(defun bibtex-actions-file--possible-names (entry dirs extensions)
"Possible names for files correponding to ENTRY with EXTENSIONS in DIRS."
(cl-flet ((possible-file-names-with-extension
(extension)
(seq-map
(lambda (directory)
(expand-file-name
(concat key "." extension) directory))
(concat
(bibtex-actions-get-value "=Key=" entry) "." extension) directory))
dirs)))
(let* ((results-key (seq-mapcat
#'possible-file-names-with-extension
extensions))
(entry (bibtex-actions-get-entry key))
(file-field (bibtex-actions-get-value
bibtex-actions-file-variable entry))
(results-file
(when file-field (funcall bibtex-actions-file-parser-function dirs file-field))))
(append results-key results-file))))

(defun bibtex-actions-file--files-for-key (key dirs extensions)
"Find files related to KEY in DIRS with extension in EXTENSIONS."
(defun bibtex-actions-file--files-for-key (entry dirs extensions)
"Find files related to ENTRY in DIRS with extension in EXTENSIONS."
(seq-filter #'file-exists-p
(bibtex-actions-file--possible-names key dirs extensions)))
(bibtex-actions-file--possible-names entry dirs extensions)))

(defun bibtex-actions-file--files-to-open-or-create (keys dirs extensions)
"Find files related to a list of KEYS in DIRS with extension in EXTENSIONS."
Expand All @@ -137,7 +137,7 @@ use 'orb-edit-note' for this value."
"Find files related to a list of KEYS in DIRS with extension in EXTENSIONS."
(seq-mapcat
(lambda (key)
(bibtex-actions-file--files-for-key key dirs extensions)) keys))
(bibtex-actions-file--files-for-key (car key) dirs extensions)) keys))

;;;; Opening and creating files functions

Expand All @@ -158,16 +158,16 @@ use 'orb-edit-note' for this value."
nil 0 nil
file)))

(defun bibtex-actions-file-open-notes-default-org (key)
"Open a note file from KEY."
(defun bibtex-actions-file-open-notes-default-org (key-entry)
"Open a note file from KEY-ENTRY."
(if-let* ((file
(caar (bibtex-actions-file--files-to-open-or-create
(list key)
(list key-entry)
bibtex-actions-notes-paths '("org"))))
(file-exists (file-exists-p file)))
(funcall bibtex-actions-file-open-function file)
(let* ((uuid (org-id-new))
(entry (bibtex-actions-get-entry key))
(entry (cdr key-entry))
(note-meta
(bibtex-actions--format-entry-no-widths
entry
Expand Down
Loading