emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e25c1b5: Further tweaks to gnus-search-query-expand-key


From: Eric Abrahamsen
Subject: master e25c1b5: Further tweaks to gnus-search-query-expand-key
Date: Sun, 11 Jul 2021 12:05:11 -0400 (EDT)

branch: master
commit e25c1b5cd390a7a3f76f9309455d9632a36e373b
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    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 8627619..39bde83 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]