From 8516cfa10f37d9ce45f1f568f391ad867015de34 Mon Sep 17 00:00:00 2001 From: Bruce D'Arcus Date: Sat, 27 Feb 2021 06:30:45 -0500 Subject: [PATCH] Revise bibtex-completion--get-candidates Change to cl-loop, and propertize candidates string to use bibtex-completion-candidates, but to display using bibtex-completion-format-entry. --- bibtex-completion.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bibtex-completion.el b/bibtex-completion.el index 5d3b9ea..c33a076 100644 --- a/bibtex-completion.el +++ b/bibtex-completion.el @@ -503,19 +503,23 @@ for string replacement." (bibtex-completion-init) (completing-read "BibTeX entries: " - (lambda (string pred action) + (lambda (string predicate action) (if (eq action 'metadata) '(metadata + ;; (annotation-function . bibtex-completion--annotation) (category . bibtex)) - (complete-with-action action (bibtex-completion--get-candidates) string pred))))) + (complete-with-action action (bibtex-completion--get-candidates) string predicate))))) (defun bibtex-completion--get-candidates () "Return all keys from bibtex-completion-candidates." - (mapcar - (lambda (cand) - (cons (bibtex-completion-format-entry cand (1- (frame-width))) - (cdr (assoc "=key=" cand)))) - (bibtex-completion-candidates))) + (cl-loop + for candidate in (bibtex-completion-candidates) + collect + (cons + ;; Here use one string for display, and the other for search. + (propertize + (car candidate) 'display (bibtex-completion-format-entry candidate (1- (frame-width)))) + (cdr (assoc "=key=" candidate))))) (defun bibtex-completion-candidates () "Read the BibTeX files and return a list of conses, one for each entry.