unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master e7f6bb3 1/2: Rework gnus-search-indexed-parse-output
       [not found] ` <20210711032252.A2F662112E@vcs0.savannah.gnu.org>
@ 2021-07-30  1:03   ` Joseph Mingrone
  2021-07-30 16:25     ` Eric Abrahamsen
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph Mingrone @ 2021-07-30  1:03 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-devel

Hello Eric,

After this change, searching for messages with (nnml . notmuch) as part
of the value of `gnus-search-default-engines' always returns 0 results.
The search results look good in the previous commit, 0897ade8f9.

Are there any results that I can share to help debug this?

Regards,

Joe

On Sat, 2021-07-10 at 23:22, eric@ericabrahamsen.net (Eric Abrahamsen) wrote:

> branch: master
> commit e7f6bb38ddb71bfe08bdca87119ff13cd40ecf62
> Author: Eric Abrahamsen <eric@ericabrahamsen.net>
> Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

>     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 70bde26..898b57b 100644
> --- a/lisp/gnus/gnus-search.el
> +++ b/lisp/gnus/gnus-search.el
> @@ -1351,68 +1351,59 @@ Returns a list of [group article score] vectors."

>  (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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: master e7f6bb3 1/2: Rework gnus-search-indexed-parse-output
  2021-07-30  1:03   ` master e7f6bb3 1/2: Rework gnus-search-indexed-parse-output Joseph Mingrone
@ 2021-07-30 16:25     ` Eric Abrahamsen
  2021-07-30 19:22       ` Joseph Mingrone
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Abrahamsen @ 2021-07-30 16:25 UTC (permalink / raw)
  To: Joseph Mingrone; +Cc: emacs-devel

Joseph Mingrone <jrm@ftfl.ca> writes:

> Hello Eric,
>
> After this change, searching for messages with (nnml . notmuch) as part
> of the value of `gnus-search-default-engines' always returns 0 results.
> The search results look good in the previous commit, 0897ade8f9.
>
> Are there any results that I can share to help debug this?

Yes, this is almost certainly a problem that's been reported, with the
below fix. Would you try this and let me know if it solves your situation?

1 file changed, 1 insertion(+), 1 deletion(-)
lisp/gnus/gnus-search.el | 2 +-

modified   lisp/gnus/gnus-search.el
@@ -1384,7 +1384,6 @@ gnus-search-indexed-parse-output
                    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
@@ -1394,6 +1393,7 @@ gnus-search-indexed-parse-output
 		  (nnmaildir-base-name-to-article-number
 		   (substring article 0 (string-match ":" article))
 		   group (string-remove-prefix "nnmaildir:" server))))
+          (setq group (gnus-group-full-name group server))
           (when (and (numberp article)
                      (or (null groups)
                          (member group groups)))



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: master e7f6bb3 1/2: Rework gnus-search-indexed-parse-output
  2021-07-30 16:25     ` Eric Abrahamsen
@ 2021-07-30 19:22       ` Joseph Mingrone
  0 siblings, 0 replies; 3+ messages in thread
From: Joseph Mingrone @ 2021-07-30 19:22 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-devel

On Fri, 2021-07-30 at 09:25, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:

> Joseph Mingrone <jrm@ftfl.ca> writes:

>> Hello Eric,

>> After this change, searching for messages with (nnml . notmuch) as part
>> of the value of `gnus-search-default-engines' always returns 0 results.
>> The search results look good in the previous commit, 0897ade8f9.

>> Are there any results that I can share to help debug this?

> Yes, this is almost certainly a problem that's been reported, with the
> below fix. Would you try this and let me know if it solves your situation?

> 1 file changed, 1 insertion(+), 1 deletion(-)
> lisp/gnus/gnus-search.el | 2 +-

> modified   lisp/gnus/gnus-search.el
> @@ -1384,7 +1384,6 @@ gnus-search-indexed-parse-output
>                     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
> @@ -1394,6 +1393,7 @@ gnus-search-indexed-parse-output
>  		  (nnmaildir-base-name-to-article-number
>  		   (substring article 0 (string-match ":" article))
>  		   group (string-remove-prefix "nnmaildir:" server))))
> +          (setq group (gnus-group-full-name group server))
>            (when (and (numberp article)
>                       (or (null groups)
>                           (member group groups)))

Alexandr's patch still doesn't work for me.  I didn't see the
ding@gnus.org thread before I posted here, so I'll follow up there.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-30 19:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210711032250.31847.28300@vcs0.savannah.gnu.org>
     [not found] ` <20210711032252.A2F662112E@vcs0.savannah.gnu.org>
2021-07-30  1:03   ` master e7f6bb3 1/2: Rework gnus-search-indexed-parse-output Joseph Mingrone
2021-07-30 16:25     ` Eric Abrahamsen
2021-07-30 19:22       ` Joseph Mingrone

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).