summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-search.el
diff options
context:
space:
mode:
authorEric Abrahamsen <eric@ericabrahamsen.net>2021-07-10 10:00:32 -0700
committerEric Abrahamsen <eric@ericabrahamsen.net>2021-07-10 20:22:35 -0700
commitd93ff9459feb77ed5df0d3af563d1280ff42062f (patch)
treea121d6d4218ca8e8e0d73c7a0f777f68f68386ea /lisp/gnus/gnus-search.el
parente7f6bb38ddb71bfe08bdca87119ff13cd40ecf62 (diff)
downloademacs-d93ff9459feb77ed5df0d3af563d1280ff42062f.tar.gz
Rewrite gnus-search-query-expand-key
* lisp/gnus/gnus-search.el (gnus-search-query-expand-key): There was a misunderstanding about how completion-all-completion works (if the test string can't be completed, the whole table is returned). Simplify to use try-completion. * test/lisp/gnus/gnus-search-tests.el (gnus-s-expand-keyword): Ensure that an unknown/uncompletable keyword is returned unmolested.
Diffstat (limited to 'lisp/gnus/gnus-search.el')
-rw-r--r--lisp/gnus/gnus-search.el22
1 files changed, 10 insertions, 12 deletions
diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el
index 898b57bcef8..56675eb8651 100644
--- a/lisp/gnus/gnus-search.el
+++ b/lisp/gnus/gnus-search.el
@@ -629,18 +629,16 @@ gnus-*-mark marks, and return an appropriate string."
mark))
(defun gnus-search-query-expand-key (key)
- (cond ((test-completion key gnus-search-expandable-keys)
- ;; We're done!
- key)
- ;; There is more than one possible completion.
- ((consp (cdr (completion-all-completions
- key gnus-search-expandable-keys #'stringp 0)))
- (signal 'gnus-search-parse-error
- (list (format "Ambiguous keyword: %s" key))))
- ;; Return KEY, either completed or untouched.
- ((car-safe (completion-try-completion
- key gnus-search-expandable-keys
- #'stringp 0)))))
+ (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.
+ (signal 'gnus-search-parse-error
+ (list (format "Ambiguous keyword: %s" key)))
+ ;; We completed to a unique known key.
+ comp))))
(defun gnus-search-query-return-string (&optional delimited trim)
"Return a string from the current buffer.