aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/gnus/gnus-search.el47
1 files changed, 12 insertions, 35 deletions
diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el
index bad2b909c36..1db13a6ca7c 100644
--- a/lisp/gnus/gnus-search.el
+++ b/lisp/gnus/gnus-search.el
@@ -692,41 +692,18 @@ chunk of query syntax."
692 addresses))))) 692 addresses)))))
693 693
694(defun gnus-search-query-expand-key (key) 694(defun gnus-search-query-expand-key (key)
695 "Attempt to expand KEY to a full keyword." 695 (cond ((test-completion key gnus-search-expandable-keys)
696 (let ((bits (split-string key "-")) 696 ;; We're done!
697 bit out-bits comp) 697 key)
698 (if (try-completion (car bits) gnus-search-expandable-keys) 698 ;; There is more than one possible completion.
699 (progn 699 ((consp (cdr (completion-all-completions
700 (while (setq bit (pop bits)) 700 key gnus-search-expandable-keys #'stringp)))
701 (setq comp (try-completion bit gnus-search-expandable-keys)) 701 (signal 'gnus-search-parse-error
702 (if (stringp comp) 702 (list (format "Ambiguous keyword: %s" key))))
703 (if (and (string= bit comp) 703 ;; Return KEY, either completed or untouched.
704 (null (member comp gnus-search-expandable-keys))) 704 ((car-safe (completion-try-completion
705 (signal 'gnus-search-parse-error 705 key gnus-search-expandable-keys
706 (list (format "Ambiguous keyword: %s" key))) 706 #'stringp 0)))))
707 (push comp out-bits))
708 (push bit out-bits)))
709 (mapconcat #'identity (reverse out-bits) "-"))
710 key)))
711
712;; (defun gnus-search-query-expand-key (key)
713;; "Attempt to expand (possibly abbreviated) KEY to a full keyword.
714
715;; Can handle any non-ambiguous abbreviation, with hyphens as substring separator."
716;; (let* ((bits (split-string key "-"))
717;; (bit (pop bits))
718;; (comp (all-completions bit gnus-search-expandable-keys)))
719;; ;; Make a cl-labels recursive function, that accepts a rebuilt key and
720;; ;; results of `all-completions' back in as a COLLECTION argument.
721;; (if (= 1 (length comp))
722;; (setq key (car comp))
723;; (when (setq comp (try-completion bit gnus-search-expandable-keys))
724;; (if (and (string= bit comp)
725;; (null (member comp gnus-search-expandable-keys)))
726;; (error "Ambiguous keyword: %s" key)))
727;; (unless (eq t (try-completion key gnus-search-expandable-keys))))
728;; key))
729
730 707
731(defun gnus-search-query-return-string (&optional delimited trim) 708(defun gnus-search-query-return-string (&optional delimited trim)
732 "Return a string from the current buffer. 709 "Return a string from the current buffer.