emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/gnus-search 741ccdc 06/12: Create general gnus-sea


From: Eric Abrahamsen
Subject: [Emacs-diffs] scratch/gnus-search 741ccdc 06/12: Create general gnus-search-indexed-massage-output method
Date: Wed, 3 May 2017 11:50:58 -0400 (EDT)

branch: scratch/gnus-search
commit 741ccdc64d77f5104f0708509bc1a9b08030c1ae
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Create general gnus-search-indexed-massage-output method
    
    * lisp/gnus/gnus-search.el (gnus-search-indexed-massage-output): Take
      the namazu version, and install it as general for all
      gnus-search-indexed engines. Probably they all can use the same
      method, but I haven't taken the time to test them all yet.
---
 lisp/gnus/gnus-search.el | 73 ++++++++++++++++++++++++++----------------------
 1 file changed, 40 insertions(+), 33 deletions(-)

diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el
index 180888a..0943caf 100644
--- a/lisp/gnus/gnus-search.el
+++ b/lisp/gnus/gnus-search.el
@@ -1374,6 +1374,46 @@ Returns a vector of [group name, file name, score] 
vectors."
        (when (> gnus-verbose 6)
          (display-buffer buffer))))))
 
+(cl-defmethod gnus-search-indexed-massage-output ((engine gnus-search-indexed)
+                                                 server &optional groups)
+  "Common method for massaging filenames returned by indexed
+search engines.
+
+This method assumes that the engine returns a plain list of
+absolute filepaths to standard out."
+  ;; This method was originally the namazu-specific method.  I'm
+  ;; almost certain that all the engines can use this same method
+  ;; (meaning some fairly significant code reduction), but I haven't
+  ;; gone and tested them all yet.
+
+  ;; What if the server backend is nnml, and/or uses mboxes?
+  (let ((article-pattern (if (string-match "\\'nnmaildir:"
+                                          (gnus-group-server server))
+                            ":[0-9]+"
+                          "^[0-9]+$"))
+       (prefix (slot-value engine 'prefix))
+       (group-regexp (when groups
+                       (regexp-opt
+                        (mapcar
+                         (lambda (x) (gnus-group-real-name x))
+                         groups))))
+       score group article artlist)
+    (goto-char (point-min))
+    (while (re-search-forward
+           "^\\([0-9,]+\\.\\).*\\((score: \\([0-9]+\\)\\))\n\\([^ ]+\\)"
+           nil t)
+      (setq score (match-string 3)
+           group (file-name-directory (match-string 4))
+           article (file-name-nondirectory (match-string 4)))
+
+      ;; make sure article and group is sane
+      (when (and (string-match article-pattern article)
+                (not (null group))
+                (or (null group-regexp)
+                    (string-match-p group-regexp group)))
+       (gnus-search-add-result group article score prefix server artlist)))
+    artlist))
+
 ;; Swish++
 
 (cl-defmethod gnus-search-transform-expression ((engine gnus-search-swish++)
@@ -1554,39 +1594,6 @@ Returns a vector of [group name, file name, score] 
vectors."
       ,index-dir ; index directory
       )))
 
-(cl-defmethod gnus-search-indexed-massage-output ((engine gnus-search-namazu)
-                                                 server &optional groups)
-  ;; Namazu output looks something like this:
-  ;; 2. Re: Gnus agent expire broken (score: 55)
-  ;; /home/henrik/Mail/mail/sent/1310 (4,138 bytes)
-
-  (let ((article-pattern (if (string-match "\\'nnmaildir:"
-                                          (gnus-group-server server))
-                            ":[0-9]+"
-                          "^[0-9]+$"))
-       (prefix (slot-value engine 'prefix))
-       (group-regexp (when groups
-                       (regexp-opt
-                        (mapcar
-                         (lambda (x) (gnus-group-real-name x))
-                         groups))))
-       score group article artlist)
-    (goto-char (point-min))
-    (while (re-search-forward
-           "^\\([0-9,]+\\.\\).*\\((score: \\([0-9]+\\)\\))\n\\([^ ]+\\)"
-           nil t)
-      (setq score (match-string 3)
-           group (file-name-directory (match-string 4))
-           article (file-name-nondirectory (match-string 4)))
-
-      ;; make sure article and group is sane
-      (when (and (string-match article-pattern article)
-                (not (null group))
-                (or (null group-regexp)
-                    (string-match-p group-regexp group)))
-       (gnus-search-add-result group article score prefix server artlist)))
-    artlist))
-
 ;;; Notmuch interface
 
 (cl-defmethod gnus-search-transform ((_engine gnus-search-notmuch)



reply via email to

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