]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix gnus-search notmuch thread searches
authorEric Abrahamsen <eric@ericabrahamsen.net>
Thu, 17 Feb 2022 21:09:49 +0000 (13:09 -0800)
committerEric Abrahamsen <eric@ericabrahamsen.net>
Thu, 17 Feb 2022 21:11:25 +0000 (13:11 -0800)
* lisp/gnus/gnus-search.el (gnus-search-run-search): Multiple things
wrong with collecting thread ids from the search results, and
constructing a new search query.
(gnus-search-indexed-search-command): Use list appending rather than
backtick construction, that was more confusing than it was helpful.

lisp/gnus/gnus-search.el

index 605d8a34e950afc44b635766211aeed22e2d2010..1e927ca922152d6c86ed18fdcf79e0cf01c7fd82 100644 (file)
@@ -1634,13 +1634,20 @@ Namazu provides a little more information, for instance a score."
                            proc-buffer program cp-list))
          (while (process-live-p proc)
            (accept-process-output proc))
-         (while (re-search-forward "^thread:\\([^ ]+\\)" (point-max) t)
-           (push (match-string 1) thread-ids))
+          (goto-char (point-min))
+         (while (re-search-forward
+                  "^thread:\\([^[:space:]\n]+\\)"
+                  (point-max) t)
+           (cl-pushnew (match-string 1) thread-ids :test #'equal))
          (cl-call-next-method
           engine server
-          ;; Completely replace the query with our new thread-based one.
-          (mapconcat (lambda (thrd) (concat "thread:" thrd))
-                     thread-ids " or ")
+          ;; If we found threads, completely replace the query with
+          ;; our new thread-based one.
+           (if thread-ids
+               `((query . ,(mapconcat (lambda (thrd)
+                                        (concat "thread:" thrd))
+                                      thread-ids " or ")))
+             query)
           nil)))
     (cl-call-next-method engine server query groups)))
 
@@ -1653,16 +1660,16 @@ Namazu provides a little more information, for instance a score."
   (let ((limit (alist-get 'limit query))
        (thread (alist-get 'thread query)))
     (with-slots (switches config-file) engine
-      `(,(format "--config=%s" config-file)
-       "search"
-       ,(if thread
-            "--output=threads"
-          "--output=files")
-       "--duplicate=1" ; I have found this necessary, I don't know why.
-       ,@switches
-       ,(if limit (format "--limit=%d" limit) "")
-       ,qstring
-       ))))
+      (append
+       (list (format "--config=%s" config-file)
+             "search"
+             (if thread
+                 "--output=threads"
+             "--output=files"))
+       (unless thread '("--duplicate=1"))
+       (when limit (list (format "--limit=%d" limit)))
+       switches
+       (list qstring)))))
 
 ;;; Mairix interface