Skip to content

Commit

Permalink
Revise bibtex-completion--get-candidates
Browse files Browse the repository at this point in the history
Change to cl-loop, and propertize candidates string to use
bibtex-completion-candidates, but to display using
bibtex-completion-format-entry.
  • Loading branch information
bdarcus committed Feb 28, 2021
1 parent fea2a52 commit 8516cfa
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions bibtex-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8516cfa

Please sign in to comment.