From: Eric Abrahamsen Date: Sat, 14 Nov 2020 21:37:08 +0000 (-0800) Subject: Assume default imap TEXT search even when not using parsed queries X-Git-Tag: emacs-28.0.90~5023 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=11bef9693ab89c29758eb7e82245f807a60e1dde;p=emacs.git Assume default imap TEXT search even when not using parsed queries This behavior both better matches the previous nnir behavior, reducing confusion for new users, and matches behavior when using parsed queries. * lisp/gnus/gnus-search.el (gnus-search-imap-search-keys): Make sure this variable contains all known IMAP search keys. (gnus-search-run-search): If the search query doesn't start with a known search key, prepend "TEXT " to the query. --- diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el index 492ee2052c4..310711eca0a 100644 --- a/lisp/gnus/gnus-search.el +++ b/lisp/gnus/gnus-search.el @@ -1030,6 +1030,13 @@ Responsible for handling and, or, and parenthetical expressions.") (declare-function nnimap-buffer "nnimap" ()) (declare-function nnimap-command "nnimap" (&rest args)) +(defvar gnus-search-imap-search-keys + '(body cc bcc from header keyword larger smaller subject text to uid x-gm-raw + answered before deleted draft flagged on since recent seen sentbefore + senton sentsince unanswered undeleted undraft unflagged unkeyword + unseen all) + "Known IMAP search keys.") + ;; imap interface (cl-defmethod gnus-search-run-search ((engine gnus-search-imap) srv query groups) @@ -1059,6 +1066,15 @@ Responsible for handling and, or, and parenthetical expressions.") (setq q-string (gnus-search-make-query-string engine query)) + ;; A bit of backward-compatibility slash convenience: if the + ;; query string doesn't start with any known IMAP search + ;; keyword, assume it is a "TEXT" search. + (unless (and (string-match "\\`[[:word:]]+" q-string) + (memql (intern-soft (downcase + (match-string 0 q-string))) + gnus-search-imap-search-keys)) + (setq q-string (concat "TEXT " q-string))) + ;; If it's a thread query, make sure that all message-id ;; searches are also references searches. (when (alist-get 'thread query) @@ -1115,12 +1131,6 @@ Other capabilities could be tested here." (nnimap-get-response call))) (t (nnimap-command "UID SEARCH %s" query))))) -;; TODO: Don't exclude booleans and date keys, just check for them -;; before checking for general keywords. -(defvar gnus-search-imap-search-keys - '(body cc bcc from header keyword larger smaller subject text to uid x-gm-raw) - "Known IMAP search keys, excluding booleans and date keys.") - (cl-defmethod gnus-search-transform ((_ gnus-search-imap) (_query null)) "ALL")