]> git.eshelyaron.com Git - emacs.git/commitdiff
New defsubst gnus-search-single-p
authorEric Abrahamsen <eric@ericabrahamsen.net>
Thu, 1 Jun 2017 14:08:11 +0000 (22:08 +0800)
committerEric Abrahamsen <eric@ericabrahamsen.net>
Mon, 5 Jun 2017 08:04:35 +0000 (16:04 +0800)
* lisp/gnus/gnus-search.el (gnus-search-single-p): Convenience
  function for checking if a search is meant to return a single
  message: ie, the query is only (id . "<msg-id>").
  (gnus-search-run-search): Use in the imap method.
  (gnus-search-indexed-parse-output): Use in the indexed method.

lisp/gnus/gnus-search.el

index 3f4aced71662a311547dced705fa302eb4c7aaf4..debd1f82a5a71a1a89b9dd7fb048d03ffd1125ad 100644 (file)
@@ -1087,6 +1087,13 @@ Responsible for handling and, or, and parenthetical expressions.")
        engine (alist-get 'parsed-query query-spec))
     (alist-get 'query query-spec)))
 
+(defsubst gnus-search-single-p (query)
+  "Return t if QUERY is a search for a single message."
+  (let ((q (alist-get 'parsed-query query)))
+    (and (= (length q ) 1)
+        (consp (car-safe q))
+        (eq (caar q) 'id))))
+
 (cl-defmethod gnus-search-transform ((engine gnus-search-engine)
                                     (query list))
   (let (clauses)
@@ -1138,8 +1145,7 @@ Responsible for handling and, or, and parenthetical expressions.")
     (let ((server (cadr (gnus-server-to-method srv)))
           (gnus-inhibit-demon t)
          ;; We're using the message id to look for a single message.
-         (single-search (and (= (length query) 1)
-                             (eql (caar query) 'id)))
+         (single-search (gnus-search-single-p query))
          q-string artlist group)
       (message "Opening server %s" server)
       ;; We should only be doing this once, in
@@ -1459,6 +1465,8 @@ Returns a list of [group article score] vectors."
        (when (and (file-readable-p f-name)
                   (null (file-directory-p f-name))
                   (or (null groups)
+                       (and (gnus-search-single-p query)
+                            (alist-get 'thread query))
                       (string-match-p group-regexp f-name)))
          (push (list f-name score) artlist))))
     ;; Are we running an additional grep query?