GNU bug report logs -
#73581
29.4; Gnus: Error doing a search on nnmaildir with gnus-search-find-grep
Previous Next
Full log
Message #17 received at 73581 <at> debbugs.gnu.org (full text, mbox):
[வியாழன் ஏப்ரல் 10, 2025] Visuwesh wrote:
> With all that accounted for, I ended up with the (ugly?) patch below.
Here's a slightly better patch which directly edits the buffer text
instead of working with strings.
diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el
index 41915a0e3c0..1f66225318c 100644
--- a/lisp/gnus/gnus-search.el
+++ b/lisp/gnus/gnus-search.el
@@ -1980,8 +1980,11 @@ gnus-search-run-search
&optional groups)
"Run find and grep to obtain matching articles."
(let* ((method (gnus-server-to-method server))
- (sym (intern
- (concat (symbol-name (car method)) "-directory")))
+ ;; `nnmaildir' backends use the 'directory' setting.
+ (sym (if (eq (car method) 'nnmaildir)
+ 'directory
+ (intern
+ (concat (symbol-name (car method)) "-directory"))))
(directory (cadr (assoc sym (cddr method))))
(regexp (alist-get 'grep query))
(grep-options (slot-value engine 'grep-options))
@@ -1996,6 +1999,12 @@ gnus-search-run-search
#'vconcat
(mapcar (lambda (x)
(let ((group x)
+ (nnmaildir-strip-regexp
+ ;; TODO: Does it need the ^ anchor?
+ (concat (regexp-quote (gnus-group-real-name x))
+ "/\\(?:new\\|cur\\)/"))
+ (nnmaildir-strip-repl
+ (concat (gnus-group-real-name x) "/"))
artlist)
(gnus-message 7 "Searching %s using find-grep..."
(or group server))
@@ -2003,7 +2012,7 @@ gnus-search-run-search
(set-buffer buffer)
(if (> gnus-verbose 6)
(pop-to-buffer (current-buffer)))
- (cd directory) ; Using relative paths simplifies
+ (cd directory) ; Using relative paths simplifies
; postprocessing.
(let ((group
(if (not group)
@@ -2029,28 +2038,49 @@ gnus-search-run-search
(save-excursion
(apply
#'call-process "find" nil t
- "find" group "-maxdepth" "1" "-type" "f"
- "-name" "[0-9]*" "-exec"
- (slot-value engine 'grep-program)
- `("-l" ,@(and grep-options
- (split-string grep-options "\\s-" t))
- "-e" ,regexp "{}" "+"))))
-
+ "find"
+ (delq
+ nil ; nil can be present if GREP-OPTIONS=nil.
+ `(,@(if (eq (car method) 'nnmaildir)
+ (list (concat group "/cur")
+ (concat group "/new"))
+ group)
+ "-maxdepth" "1" "-type" "f"
+ "-name" "[0-9]*" "-exec"
+ ,(slot-value engine 'grep-program)
+ "-l" ,@(and grep-options
+ (split-string grep-options "\\s-" t))
+ "-e" ,regexp "{}" "+")))))
+
+ ;; When searching in a maildir directory, change the
+ ;; filenames to not have cur and new.
+ (when (eq (car method) 'nnmaildir)
+ (save-excursion
+ (while (re-search-forward nnmaildir-strip-regexp nil t)
+ (replace-match nnmaildir-strip-repl t))))
;; Translate relative paths to group names.
(while (not (eobp))
- (let* ((path (split-string
- (buffer-substring
- (point)
- (line-end-position))
- "/" t))
- (art (string-to-number (car (last path)))))
+ (let* ((path (split-string (buffer-substring
+ (point)
+ (line-end-position))
+ "/" t))
+ (art (car (last path))))
(while (string= "." (car path))
(setq path (cdr path)))
(let ((group (mapconcat #'identity
(cl-subseq path 0 -1)
".")))
(push
- (vector (gnus-group-full-name group server) art 0)
+ (vector (gnus-group-full-name group server)
+ ;; FIXME: Code duplication. This is
+ ;; copied over from
+ ;; `gnus-search-indexed-parse-output'.
+ (if (string-match-p "\\`[[:digit:]]+\\'" art)
+ (string-to-number art)
+ (nnmaildir-base-name-to-article-number
+ (substring art 0 (string-search ":" art))
+ group (string-remove-prefix "nnmaildir:" server)))
+ 0)
artlist))
(forward-line 1)))
(gnus-message 7 "Searching %s using find-grep...done"
This bug report was last modified 66 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.