From 4c089f1efad1131f7d32ba10cfe4f7a8a1abff57 Mon Sep 17 00:00:00 2001 From: Joost Kremers Date: Thu, 16 Nov 2023 17:32:45 +0100 Subject: [PATCH] Show all keywords as completion candidates when editing the keywords 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. --- ebib.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ebib.el b/ebib.el index f3bbfd87..03104fe5 100644 --- a/ebib.el +++ b/ebib.el @@ -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