From: Eric Abrahamsen Date: Thu, 1 Jun 2017 14:08:11 +0000 (+0800) Subject: New defsubst gnus-search-single-p X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1f821aee7f0cd1c38b411df19bd5293ec4899be2;p=emacs.git New defsubst gnus-search-single-p * 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 . ""). (gnus-search-run-search): Use in the imap method. (gnus-search-indexed-parse-output): Use in the indexed method. --- diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el index 3f4aced7166..debd1f82a5a 100644 --- a/lisp/gnus/gnus-search.el +++ b/lisp/gnus/gnus-search.el @@ -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?