From 36179f0b1e118bbc2b486200c773da20edb9b406 Mon Sep 17 00:00:00 2001 From: Bruce D'Arcus Date: Sun, 7 Mar 2021 16:36:13 -0500 Subject: [PATCH] Change to completing-read-multiple The bibtex-completion functions all take multiple keys as input, and some of them (notably the "input" ones) lose functionality without support for this. Hence, this changes the core read function to using 'completing-read-multiple'. Addresses #17. --- bibtex-actions.el | 51 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/bibtex-actions.el b/bibtex-actions.el index ef113229..208c4db5 100644 --- a/bibtex-actions.el +++ b/bibtex-actions.el @@ -67,16 +67,17 @@ (bibtex-actions-read-backend)) (defun bibtex-actions--completing-read () - "Read bibtex-completion entries for completion using 'completing-read'." + "Read bibtex-completion entries for completion using 'completing-read-multiple'." (bibtex-completion-init) (when-let ((candidates (bibtex-actions--get-candidates)) (chosen - (completing-read + (completing-read-multiple "BibTeX entries: " + ;; FIX getting a "wrong number of arguments" error when interactive (lambda (string predicate action) (if (eq action 'metadata) '(metadata - ;; (annotation-function . bibtex-completion--annotation) + ;; TODO (annotation-function . bibtex-completion--annotation) (category . bibtex)) (complete-with-action action candidates string predicate)))))) (cdr (assoc chosen candidates)))) @@ -99,62 +100,62 @@ Opens the PDF(s) associated with the KEYS. If multiple PDFs are found, ask for the one to open using ‘completing-read’. If no PDF is found, try to open a URL or DOI in the browser instead." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-open-any (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-open-any keys)) (defun bibtex-actions-open-pdf (keys) "Open PDF associated with the KEYS. If multiple PDFs are found, ask for the one to open using ‘completing-read’." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-open-pdf (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-open-pdf keys)) (defun bibtex-actions-open-link (keys) "Open URL or DOI link associated with the KEYS in a browser." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-open-url-or-doi (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-open-url-or-doi keys)) (defun bibtex-actions-insert-citation (keys) "Insert citation for the KEYS." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-insert-citation (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-insert-citation keys)) (defun bibtex-actions-insert-reference (keys) "Insert formatted reference(s) associated with the KEYS." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-insert-reference (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-insert-reference keys)) (defun bibtex-actions-insert-key (keys) "Insert BibTeX KEYS." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-insert-key (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-insert-key keys)) (defun bibtex-actions-insert-bibtex (keys) "Insert BibTeX entry associated with the KEYS." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-insert-bibtex (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-insert-bibtex keys)) (defun bibtex-actions-add-pdf-attachment (keys) "Attach PDF(s) associated with the KEYS to email." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-add-PDF-attachment (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-add-PDF-attachment keys)) (defun bibtex-actions-open-notes (keys) "Open notes associated with the KEYS." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-edit-notes (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-edit-notes keys)) (defun bibtex-actions-open-entry (keys) "Open BibTeX entry associated with the KEYS." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-show-entry (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-show-entry keys)) (defun bibtex-actions-add-pdf-to-library (keys) "Add PDF associated with the KEYS to library. The PDF can be added either from an open buffer, a file, or a URL." - (interactive (list (bibtex-actions--read))) - (bibtex-completion-add-pdf-to-library (list keys))) + (interactive (bibtex-actions--read)) + (bibtex-completion-add-pdf-to-library keys)) (provide 'bibtex-actions) ;;; bibtex-actions.el ends here