From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: "Adam Sjøgren" <asjo@koldfront.dk>
Cc: ding@gnus.org
Subject: Re: Help testing gnus-search fixups
Date: Wed, 30 Jun 2021 09:58:07 -0700 [thread overview]
Message-ID: <87zgv7thls.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <87k0mclxo8.fsf@tullinup.koldfront.dk> ("Adam =?utf-8?Q?Sj?= =?utf-8?Q?=C3=B8gren=22's?= message of "Tue, 29 Jun 2021 13:25:59 +0200")
[-- Attachment #1: Type: text/plain, Size: 589 bytes --]
Adam Sjøgren <asjo@koldfront.dk> writes:
> Adam writes:
>
>> Thomas writes:
>>
>>> the attached patch applied to the patched file fixes this for me.
>>
>> That makes search work for me as well.
>
> In case Thomas' email doesn't reach the mailing list, here is the
> combined diff I ended up with:
Thanks to you both! That happened to slip by the test cases I was using,
and that's why we get extra testers! I've attached a new version of the
patch with your change applied; I'll give it a few days in case anyone
else wants to test it, then push.
Thanks,
Eric
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Rework-gnus-search-indexed-parse-output.patch --]
[-- Type: text/x-patch, Size: 5068 bytes --]
From b15fd217335f6711560ef88205ccfc262b4d2f25 Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Sat, 26 Jun 2021 10:16:19 -0700
Subject: [PATCH] Rework gnus-search-indexed-parse-output
* lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output): Be more
careful about matching filesystem paths to Gnus group names; make
absolutely sure that we only return valid article numbers.
---
lisp/gnus/gnus-search.el | 95 ++++++++++++++++++----------------------
1 file changed, 43 insertions(+), 52 deletions(-)
diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el
index 70bde264c1..898b57bcef 100644
--- a/lisp/gnus/gnus-search.el
+++ b/lisp/gnus/gnus-search.el
@@ -1351,68 +1351,59 @@ gnus-search-run-search
(cl-defmethod gnus-search-indexed-parse-output ((engine gnus-search-indexed)
server query &optional groups)
- (let ((prefix (slot-value engine 'remove-prefix))
- (group-regexp (when groups
- (mapconcat
- (lambda (group-name)
- (mapconcat #'regexp-quote
- (split-string
- (gnus-group-real-name group-name)
- "[.\\/]")
- "[.\\\\/]"))
- groups
- "\\|")))
- artlist vectors article group)
+ (let ((prefix (or (slot-value engine 'remove-prefix)
+ ""))
+ artlist article group)
(goto-char (point-min))
+ ;; Prep prefix, we want to at least be removing the root
+ ;; filesystem separator.
+ (when (stringp prefix)
+ (setq prefix (file-name-as-directory
+ (expand-file-name prefix "/"))))
(while (not (or (eobp)
(looking-at-p
"\\(?:[[:space:]\n]+\\)?Process .+ finished")))
(pcase-let ((`(,f-name ,score) (gnus-search-indexed-extract engine)))
(when (and f-name
(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))))
+ (null (file-directory-p f-name)))
+ (setq group
+ (replace-regexp-in-string
+ "[/\\]" "."
+ (replace-regexp-in-string
+ "/?\\(cur\\|new\\|tmp\\)?/\\'" ""
+ (replace-regexp-in-string
+ "\\`\\." ""
+ (string-remove-prefix
+ prefix (file-name-directory f-name))
+ nil t)
+ nil t)
+ nil t))
+ (setq group (gnus-group-full-name group server))
+ (setq article (file-name-nondirectory f-name)
+ article
+ ;; TODO: Provide a cleaner way of producing final
+ ;; article numbers for the various backends.
+ (if (string-match-p "\\`[[:digit:]]+\\'" article)
+ (string-to-number article)
+ (nnmaildir-base-name-to-article-number
+ (substring article 0 (string-match ":" article))
+ group (string-remove-prefix "nnmaildir:" server))))
+ (when (and (numberp article)
+ (or (null groups)
+ (member group groups)))
+ (push (list f-name article group score)
+ artlist)))))
;; Are we running an additional grep query?
(when-let ((grep-reg (alist-get 'grep query)))
(setq artlist (gnus-search-grep-search engine artlist grep-reg)))
- ;; Prep prefix.
- (when (and prefix (null (string-empty-p prefix)))
- (setq prefix (file-name-as-directory (expand-file-name prefix))))
- ;; Turn (file-name score) into [group article score].
- (pcase-dolist (`(,f-name ,score) artlist)
- (setq article (file-name-nondirectory f-name)
- group (file-name-directory f-name))
- ;; Remove prefix.
- (when prefix
- (setq group (string-remove-prefix prefix group)))
- ;; Break the directory name down until it's something that
- ;; (probably) can be used as a group name.
- (setq group
- (replace-regexp-in-string
- "[/\\]" "."
- (replace-regexp-in-string
- "/?\\(cur\\|new\\|tmp\\)?/\\'" ""
- (replace-regexp-in-string
- "^[./\\]" ""
- group nil t)
- nil t)
- nil t))
-
- (push (vector (gnus-group-full-name group server)
- (if (string-match-p "\\`[[:digit:]]+\\'" article)
- (string-to-number article)
- (nnmaildir-base-name-to-article-number
- (substring article 0 (string-match ":" article))
- group (string-remove-prefix "nnmaildir:" server)))
- (if (numberp score)
- score
- (string-to-number score)))
- vectors))
- vectors))
+ ;; Munge into the list of vectors expected by nnselect.
+ (mapcar (pcase-lambda (`(,_ ,article ,group ,score))
+ (vector group article
+ (if (numberp score)
+ score
+ (string-to-number score))))
+ artlist)))
(cl-defmethod gnus-search-indexed-extract ((_engine gnus-search-indexed))
"Base implementation treats the whole line as a filename, and
--
2.32.0
next prev parent reply other threads:[~2021-06-30 16:58 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-28 16:42 Eric Abrahamsen
2021-06-28 18:00 ` Adam Sjøgren
2021-06-28 23:15 ` Eric Abrahamsen
2021-06-29 6:04 ` Thomas Alexander Gerds
2021-06-29 9:30 ` Adam Sjøgren
2021-06-29 9:55 ` Adam Sjøgren
2021-06-29 11:03 ` Thomas Alexander Gerds
2021-06-29 11:13 ` Adam Sjøgren
2021-06-29 11:25 ` Adam Sjøgren
2021-06-30 16:58 ` Eric Abrahamsen [this message]
[not found] ` <87bl6tuqcb.fsf@posteo.org>
2021-07-23 15:18 ` Eric Abrahamsen
[not found] ` <87bl6sual8.fsf@posteo.org>
2021-07-24 22:16 ` Eric Abrahamsen
2021-07-25 11:17 ` Alexandr Vityazev
2021-07-25 22:11 ` Eric Abrahamsen
2021-07-30 18:17 ` Joseph Mingrone
2021-07-30 18:22 ` Joseph Mingrone
2021-07-30 18:47 ` Eric Abrahamsen
2021-07-30 19:29 ` Joseph Mingrone
2021-07-30 20:23 ` Eric Abrahamsen
2021-07-30 19:34 ` Alexandr Vityazev
2021-07-30 20:25 ` Eric Abrahamsen
2021-08-05 17:15 ` Eric Abrahamsen
2021-08-05 19:54 ` Alexandr Vityazev
2021-08-05 20:19 ` Joseph Mingrone
2021-08-05 21:24 ` Eric Abrahamsen
2021-08-05 21:38 ` Joseph Mingrone
2021-08-07 16:07 ` Eric Abrahamsen
2021-08-10 7:32 ` Daniel Jensen
2021-08-13 16:50 ` Eric Abrahamsen
2021-08-13 19:30 ` Daniel Jensen
2021-08-13 19:37 ` Eric Abrahamsen
2021-06-29 11:27 ` Eric S Fraga
2021-09-11 13:29 Sergey Makarov
2021-09-11 15:04 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zgv7thls.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=asjo@koldfront.dk \
--cc=ding@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).