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.
This commit is contained in:
parent
e7f6bb38dd
commit
d93ff9459f
2 changed files with 13 additions and 13 deletions
|
@ -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.
|
||||
|
|
|
@ -49,7 +49,9 @@
|
|||
(default-value 'gnus-search-expandable-keys))
|
||||
(pairs
|
||||
'(("su" . "subject")
|
||||
("sin" . "since"))))
|
||||
("sin" . "since")
|
||||
("body" . "body")
|
||||
("list-id" . "list-id"))))
|
||||
(dolist (p pairs)
|
||||
(should (equal (gnus-search-query-expand-key (car p))
|
||||
(cdr p))))
|
||||
|
|
Loading…
Add table
Reference in a new issue