emacs-diffs
[Top][All Lists]
Advanced

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

master 11bef96: Assume default imap TEXT search even when not using pars


From: Eric Abrahamsen
Subject: master 11bef96: Assume default imap TEXT search even when not using parsed queries
Date: Wed, 25 Nov 2020 18:07:16 -0500 (EST)

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

    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.
---
 lisp/gnus/gnus-search.el | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el
index 492ee20..310711e 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")



reply via email to

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