From: Eric Abrahamsen Date: Sun, 11 Jul 2021 16:00:33 +0000 (-0700) Subject: Further tweaks to gnus-search-query-expand-key X-Git-Tag: emacs-28.0.90~1900 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e25c1b5cd390a7a3f76f9309455d9632a36e373b;p=emacs.git 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. --- 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.