[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)
- [Emacs-diffs] branch scratch/gnus-search created (now 221b872), Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search 05dbfee 07/12: Make related change to nnselect.el, Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search 5c9bab3 03/12: Make related change to nnselect.el, Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search 5b6b375 11/12: WIP on search presets, Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search 221b872 12/12: WIP on Mairix server, Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search 2f27292 08/12: Handle regexp and wildcard search terms, Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search a3e7edf 04/12: Add function gnus-search-prepare-query, Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search 741ccdc 06/12: Create general gnus-search-indexed-massage-output method,
Eric Abrahamsen <=
- [Emacs-diffs] scratch/gnus-search 6e1e003 05/12: Move search group creation functions to gnus-group.el, Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search ec2eadf 09/12: Remove Hyrex search engine, Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search e9b5c5d 10/12: WIP on documentation, Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search 8d71e81 01/12: WIP on a generalized search query language for Gnus, Eric Abrahamsen, 2017/05/03
- [Emacs-diffs] scratch/gnus-search 89700be 02/12: Rename nnir.el to gnus-search.el, Eric Abrahamsen, 2017/05/03