From e25c1b5cd390a7a3f76f9309455d9632a36e373b Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sun, 11 Jul 2021 09:00:33 -0700 Subject: [PATCH] Further tweaks to gnus-search-query-expand-key * lisp/gnus/gnus-search.el (gnus-search-query-expand-key): It's possible that KEY could be partially completed (ie no longer string= to COMP), but not all the way. Use a more accurate test. Add docstring. --- lisp/gnus/gnus-search.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el index 8627619e96e..39bde837b30 100644 --- a/lisp/gnus/gnus-search.el +++ b/lisp/gnus/gnus-search.el @@ -629,12 +629,19 @@ gnus-*-mark marks, and return an appropriate string." mark)) (defun gnus-search-query-expand-key (key) + "Attempt to expand KEY to a full keyword. +Use `gnus-search-expandable-keys' as a completion table; return +KEY directly if it can't be completed. Raise an error if KEY is +ambiguous, meaning that it is a prefix of multiple known +keywords. This means that it's not possible to enter a custom +keyword that happens to be a prefix of a known keyword." (let ((comp (try-completion key gnus-search-expandable-keys))) (if (or (eql comp 't) ; Already a key. (null comp)) ; An unknown key. key - (if (string= comp key) - ;; KEY matches multiple possible keys. + (if (null (member comp gnus-search-expandable-keys)) + ;; KEY is a prefix of multiple known keywords, and could not + ;; be completed to something unique. (signal 'gnus-search-parse-error (list (format "Ambiguous keyword: %s" key))) ;; We completed to a unique known key. -- 2.39.2