Skip to content

Commit

Permalink
Show all keywords as completion candidates when editing the keywords …
Browse files Browse the repository at this point in the history
…field.

When we edit the keywords field, we do not want to display just the values of
this field in the currently open databases as completion candidates. If the user
has a canonical keyword list, those keywords should be presented as completion
candidates.
  • Loading branch information
Joost Kremers committed Nov 16, 2023
1 parent 556bccb commit 4c089f1
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions ebib.el
Original file line number Diff line number Diff line change
Expand Up @@ -4420,15 +4420,19 @@ See also `ebib-field-edit-functions'."
;; "\s*,\s*", equivalent to "[[:space:]]*,[[:space:]]" in Emacs.
(let* ((crm-local-completion-map (make-composed-keymap '(keymap (32)) crm-local-completion-map))
(crm-separator "[[:space:]]*,[[:space:]]*")
(collection
;; Account for fields containing more than one entry, e.g.
;; keywords = {Bar, Foo, Qux}
(delete-dups
(apply
#'append
(mapcar (lambda (str)
(split-string str crm-separator t "[[:space:]]"))
(ebib--create-collection-from-fields fields)))))
;; If we're editing the "keywords" field, the completion candidates are
;; taken from `ebib--keywords-completion-list'. Otherwise, we collect
;; all the values for the current field in the currently open
;; databases. Since the field values are actually (Biblatex) list, we
;; need to split them on commas.))
(collection (if (string= field-name "keywords")
ebib--keywords-completion-list
(delete-dups
(apply
#'append
(mapcar (lambda (str)
(split-string str crm-separator t "[[:space:]]"))
(ebib--create-collection-from-fields fields))))))
(result (completing-read-multiple
(format "%s: " field-name) collection nil nil
;; Append a crm-separator to the result, so that
Expand Down

0 comments on commit 4c089f1

Please sign in to comment.