GNU bug report logs - #59888
[PATCH] Add 'grep-heading-mode'

Previous Next

Package: emacs;

Reported by: Augusto Stoffel <arstoffel <at> gmail.com>

Date: Wed, 7 Dec 2022 17:58:02 UTC

Severity: wishlist

Tags: patch

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59888 in the body.
You can then email your comments to 59888 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Wed, 07 Dec 2022 17:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Augusto Stoffel <arstoffel <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 07 Dec 2022 17:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Add 'grep-heading-mode'
Date: Wed, 07 Dec 2022 18:57:37 +0100
[Message part 1 (text/plain, inline)]
Tags: patch

This simulates the --heading option of certain grep-like tools.  The
output is like this:

--8<---------------cut here---------------start------------->8---
-*- mode: grep; default-directory: "~/Projects/emacs/" -*-
Grep started at Wed Dec  7 18:43:40

find [...] -exec grep --color=auto -i -nH --null -e test \{\} +

./nextstep/Makefile.in
104:	find ${ns_appdir} -exec test \! -e {} \; -ls

./nextstep/INSTALL
12:Tested on GNU/Linux, may work on other systems.

./nextstep/Makefile
104:	find ${ns_appdir} -exec test \! -e {} \; -ls

./nextstep/README
62:  10.6.8 (Snow Leopard) to the latest official release.
86:* This allows other Emacs developers to test their changes on the NS
--8<---------------cut here---------------end--------------->8---

[0001-Add-grep-heading-mode.patch (text/patch, attachment)]
[Message part 3 (text/plain, inline)]
Some comments:

1. It's necessary to insert text into the grep buffer, which is a bit
   concerning because 'compilation-filter-start' is not a marker, just a
   number.  This could cause other filter functions to get confused.
   This is why I'm adding to 'compilation-filter-hook at a higher depth.
   Perhaps there are better approaches here.

2. One could get rid of the awkward first alternative of
   `grep-heading-regexp' if there was a way to distringuish the grep
   process output from the header and footer added by grep-mode.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Wed, 07 Dec 2022 18:15:02 GMT) Full text and rfc822 format available.

Message #8 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Wed, 07 Dec 2022 20:14:06 +0200
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Date: Wed, 07 Dec 2022 18:57:37 +0100
> 
> +(defcustom grep-heading-regexp
> +  (rx bol
> +      (or
> +       (seq "Grep" (* (any "/a-zA-Z")) " "
> +            (or "started" "finished" "exited" "interrupt" "killed" "terminated")

Cannot these be translated to languages other than English in
localized versions of Grep?

> 2. One could get rid of the awkward first alternative of
>    `grep-heading-regexp' if there was a way to distringuish the grep
>    process output from the header and footer added by grep-mode.

You could put a special text property on the latter, no?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Thu, 08 Dec 2022 00:20:01 GMT) Full text and rfc822 format available.

Message #11 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>, 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Wed, 7 Dec 2022 16:19:30 -0800
Augusto Stoffel <arstoffel <at> gmail.com> writes:

> From 2247f006845000032fedc3dda9a073b14043a270 Mon Sep 17 00:00:00 2001
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Date: Wed, 7 Dec 2022 18:44:07 +0100
> Subject: [PATCH] Add 'grep-heading-mode'
>
> New minor mode to subdivide grep output into sections, as in the
> '--heading' option of certain grep-like programs.
>
> * lisp/progmodes/grep.el (grep-heading-regexp): New user option.
> (grep-heading): New face.
> (grep--heading-format, grep--current-heading, grep--heading-filter):
> Filter function for grep processes and supporting variables.
> (grep-heading-mode): New minor mode.

How about making this into a defcustom instead of a minor mode?

I'm thinking that something like

    (setopt grep-use-headings t)

is a slightly simpler interface to use than

    (add-hook 'grep-mode-hook 'grep-heading-mode)

I also think the former plays a bit better with customize.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Thu, 08 Dec 2022 09:00:02 GMT) Full text and rfc822 format available.

Message #14 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Thu, 08 Dec 2022 09:59:46 +0100
On Wed,  7 Dec 2022 at 20:14, Eli Zaretskii wrote:

>> From: Augusto Stoffel <arstoffel <at> gmail.com>
>> Date: Wed, 07 Dec 2022 18:57:37 +0100
>> 
>> +(defcustom grep-heading-regexp
>> +  (rx bol
>> +      (or
>> +       (seq "Grep" (* (any "/a-zA-Z")) " "
>> +            (or "started" "finished" "exited" "interrupt" "killed" "terminated")
>
> Cannot these be translated to languages other than English in
> localized versions of Grep?

AFAICT these messages are generated by Emacs itself.

We could also use "^Grep[/a-zA-Z]* [^\0t\]*$" here, which has a slightly
higher change of being confused with actual grep output, but only when
not using grep --null.

>> 2. One could get rid of the awkward first alternative of
>>    `grep-heading-regexp' if there was a way to distringuish the grep
>>    process output from the header and footer added by grep-mode.
>
> You could put a special text property on the latter, no?

That's an option and it would be useful for other extensions as well.
So we would define something like

--8<---------------cut here---------------start------------->8---
(defun compilation-insert-note (&rest args)
  (let ((start (point)))
    (apply #'insert args)
    (put-text-property start (point) 'compilation-note t)))
--8<---------------cut here---------------end--------------->8---

and use throughout compile.el, right?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Thu, 08 Dec 2022 09:08:02 GMT) Full text and rfc822 format available.

Message #17 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Thu, 08 Dec 2022 10:06:58 +0100
On Wed,  7 Dec 2022 at 16:19, Stefan Kangas wrote:

> Augusto Stoffel <arstoffel <at> gmail.com> writes:
>
>> From 2247f006845000032fedc3dda9a073b14043a270 Mon Sep 17 00:00:00 2001
>> From: Augusto Stoffel <arstoffel <at> gmail.com>
>> Date: Wed, 7 Dec 2022 18:44:07 +0100
>> Subject: [PATCH] Add 'grep-heading-mode'
>>
>> New minor mode to subdivide grep output into sections, as in the
>> '--heading' option of certain grep-like programs.
>>
>> * lisp/progmodes/grep.el (grep-heading-regexp): New user option.
>> (grep-heading): New face.
>> (grep--heading-format, grep--current-heading, grep--heading-filter):
>> Filter function for grep processes and supporting variables.
>> (grep-heading-mode): New minor mode.
>
> How about making this into a defcustom instead of a minor mode?
>
> I'm thinking that something like
>
>     (setopt grep-use-headings t)
>
> is a slightly simpler interface to use than
>
>     (add-hook 'grep-mode-hook 'grep-heading-mode)
>
> I also think the former plays a bit better with customize.

This is at the same time less customizable in the sense that something
like

  (add-hook 'grep-mode-hook
    (lambda () (when condition) (setq grep-use-headings t)))

will not work (I think), while conditionally activating a minor mode
certainly works.  But I'm open to both approaches.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Thu, 08 Dec 2022 09:59:01 GMT) Full text and rfc822 format available.

Message #20 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 59888 <at> debbugs.gnu.org
Subject: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Thu, 8 Dec 2022 10:57:59 +0100
No argument about the idea (good to me) or implementation but minor points regarding the regexp:

> +          (group-n 1 (+? any))

Very much prefer `nonl` or `not-newline` to `any`, which is only there for compatibility (shouldn't have been included in the first place).

> +          (any "\0-:="))

Is the range (ASCII 00..1A) intended here, or should that be a literal hyphen?
If the former, it should probably be made more explicit since that range includes all sorts of numbers, symbols and control chars and it kind of looks like it may be a mistake.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Thu, 08 Dec 2022 10:30:02 GMT) Full text and rfc822 format available.

Message #23 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Thu, 08 Dec 2022 11:28:55 +0100
On Thu,  8 Dec 2022 at 10:57, Mattias Engdegård wrote:

> No argument about the idea (good to me) or implementation but minor points regarding the regexp:
>
>> +          (group-n 1 (+? any))
>
> Very much prefer `nonl` or `not-newline` to `any`, which is only there for compatibility (shouldn't have been included in the first place).

Hum, not-newline is too long, so this leaves an option between the
slightly deceiving and the quite obscure.

Okay, now I see `any' is not even documented.

>> +          (any "\0-:="))
>
> Is the range (ASCII 00..1A) intended here, or should that be a literal hyphen?
> If the former, it should probably be made more explicit since that
> range includes all sorts of numbers, symbols and control chars and it
> kind of looks like it may be a mistake.

The literal hyphen, which prefixes context lines in `grep -C <n>'.
Thanks for the heads up.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Thu, 08 Dec 2022 10:49:02 GMT) Full text and rfc822 format available.

Message #26 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Thu, 8 Dec 2022 11:48:13 +0100
8 dec. 2022 kl. 11.28 skrev Augusto Stoffel <arstoffel <at> gmail.com>:

>> Very much prefer `nonl` or `not-newline` to `any`, which is only there for compatibility (shouldn't have been included in the first place).
> 
> Hum, not-newline is too long, so this leaves an option between the
> slightly deceiving and the quite obscure.

Actually `nonl` isn't too bad once you get used to it. Pronounce it 'nonnel', stress on the first syllable.

> Okay, now I see `any' is not even documented.

Yes, it was inherited from the defunct `sregex` package, in hindsight a clear mistake.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Thu, 08 Dec 2022 10:59:02 GMT) Full text and rfc822 format available.

Message #29 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Thu, 08 Dec 2022 12:57:59 +0200
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Cc: 59888 <at> debbugs.gnu.org
> Date: Thu, 08 Dec 2022 09:59:46 +0100
> 
> On Wed,  7 Dec 2022 at 20:14, Eli Zaretskii wrote:
> 
> >> From: Augusto Stoffel <arstoffel <at> gmail.com>
> >> Date: Wed, 07 Dec 2022 18:57:37 +0100
> >> 
> >> +(defcustom grep-heading-regexp
> >> +  (rx bol
> >> +      (or
> >> +       (seq "Grep" (* (any "/a-zA-Z")) " "
> >> +            (or "started" "finished" "exited" "interrupt" "killed" "terminated")
> >
> > Cannot these be translated to languages other than English in
> > localized versions of Grep?
> 
> AFAICT these messages are generated by Emacs itself.

All of them?

> We could also use "^Grep[/a-zA-Z]* [^\0t\]*$" here

The [/a-zA-Z] part is still ASCII-only, and I believe the "/" part
means you want to support file names? then for Windows we also need
the colon ':'.

> >> 2. One could get rid of the awkward first alternative of
> >>    `grep-heading-regexp' if there was a way to distringuish the grep
> >>    process output from the header and footer added by grep-mode.
> >
> > You could put a special text property on the latter, no?
> 
> That's an option and it would be useful for other extensions as well.
> So we would define something like
> 
> --8<---------------cut here---------------start------------->8---
> (defun compilation-insert-note (&rest args)
>   (let ((start (point)))
>     (apply #'insert args)
>     (put-text-property start (point) 'compilation-note t)))
> --8<---------------cut here---------------end--------------->8---
> 
> and use throughout compile.el, right?

Yes, something like this.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Fri, 09 Dec 2022 07:44:03 GMT) Full text and rfc822 format available.

Message #32 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Stefan Kangas <stefankangas <at> gmail.com>, 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Fri, 09 Dec 2022 09:23:46 +0200
>> How about making this into a defcustom instead of a minor mode?
>>
>> I'm thinking that something like
>>
>>     (setopt grep-use-headings t)
>>
>> is a slightly simpler interface to use than
>>
>>     (add-hook 'grep-mode-hook 'grep-heading-mode)
>>
>> I also think the former plays a bit better with customize.
>
> This is at the same time less customizable in the sense that something
> like
>
>   (add-hook 'grep-mode-hook
>     (lambda () (when condition) (setq grep-use-headings t)))
>
> will not work (I think), while conditionally activating a minor mode
> certainly works.  But I'm open to both approaches.

Why not?  (setq-local grep-use-headings t) definitely should do
the right thing.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Fri, 09 Dec 2022 07:44:04 GMT) Full text and rfc822 format available.

Message #35 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Fri, 09 Dec 2022 09:28:53 +0200
> Subject: [PATCH] Add 'grep-heading-mode'
>
> New minor mode to subdivide grep output into sections, as in the
> '--heading' option of certain grep-like programs.
>
> * lisp/progmodes/grep.el (grep-heading-regexp): New user option.
> (grep-heading): New face.
> (grep--heading-format, grep--current-heading, grep--heading-filter):
> Filter function for grep processes and supporting variables.
> (grep-heading-mode): New minor mode.

Thanks, this would be a great addition.

> +(defface grep-heading '((t :inherit font-lock-function-name-face))
> +  "Face of headings when using `grep-heading-mode'.")

I suggest to keep the existing color scheme, thus inheriting from
compilation-info.  This is the same color used by both grep.el and
xref.el by default.

> +(defvar grep--heading-format
> +  #("\n%s\n" 1 3 (font-lock-face grep-heading outline-level 1))

xref.el doesn't insert extra newlines between file sections.
It would be nice to keep the output closer to the existing
output in xref buffers.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Fri, 09 Dec 2022 11:59:01 GMT) Full text and rfc822 format available.

Message #38 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Stefan Kangas <stefankangas <at> gmail.com>, 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Fri, 09 Dec 2022 12:58:06 +0100
On Fri,  9 Dec 2022 at 09:23, Juri Linkov wrote:

>>> How about making this into a defcustom instead of a minor mode?
>>>
>>> I'm thinking that something like
>>>
>>>     (setopt grep-use-headings t)
>>>
>>> is a slightly simpler interface to use than
>>>
>>>     (add-hook 'grep-mode-hook 'grep-heading-mode)
>>>
>>> I also think the former plays a bit better with customize.
>>
>> This is at the same time less customizable in the sense that something
>> like
>>
>>   (add-hook 'grep-mode-hook
>>     (lambda () (when condition) (setq grep-use-headings t)))
>>
>> will not work (I think), while conditionally activating a minor mode
>> certainly works.  But I'm open to both approaches.
>
> Why not?  (setq-local grep-use-headings t) definitely should do
> the right thing.

The variable has to be set at the moment `grep-mode' runs, while a minor
mode could be set at a later point.  But I agree a variable is
sufficient here, so I will make this change.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Fri, 09 Dec 2022 11:59:02 GMT) Full text and rfc822 format available.

Message #41 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Fri, 09 Dec 2022 12:58:49 +0100
On Fri,  9 Dec 2022 at 09:28, Juri Linkov wrote:

>> +(defface grep-heading '((t :inherit font-lock-function-name-face))
>> +  "Face of headings when using `grep-heading-mode'.")
>
> I suggest to keep the existing color scheme, thus inheriting from
> compilation-info.  This is the same color used by both grep.el and
> xref.el by default.

Yes, I came to the same conclusion in the meanwhile.

>> +(defvar grep--heading-format
>> +  #("\n%s\n" 1 3 (font-lock-face grep-heading outline-level 1))
>
> xref.el doesn't insert extra newlines between file sections.
> It would be nice to keep the output closer to the existing
> output in xref buffers.

Okay, I agree with your reasoning and will make the change.  However, I
must say find the result less appealing.  Note that, because of the lack
of newlines, xref-file-header was naturally chosen as a heavier face.

But it's all customizable anyway.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Fri, 09 Dec 2022 12:19:01 GMT) Full text and rfc822 format available.

Message #44 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, Eli Zaretskii <eliz <at> gnu.org>,
 Stefan Kangas <stefankangas <at> gmail.com>, 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Fri, 09 Dec 2022 13:18:02 +0100
[Message part 1 (text/plain, inline)]
Here is an updated patch for the “grep headings” feature.

As discussed before, I introduced a text property so that one can tell
without guessing which parts of the compilation buffer are not coming
from the external process.  This seems to supersede the
'compilation-header-end' property introduced by Lars in commit
07f748da43, so I replaced its uses by the new 'compilation-aside'
property.  I could easily revert that, but it seemed reasonable to
uniformize things in this case.

I've also incorporated all other suggestions from other messages.  (And
Juri, nevermind what I said about some faces, it only applies to the
Modus theme.)

[0001-Introduce-compilation-aside-text-property.patch (text/x-patch, attachment)]
[0002-New-user-option-grep-use-headings.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Fri, 09 Dec 2022 19:37:02 GMT) Full text and rfc822 format available.

Message #47 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: larsi <at> gnus.org, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org,
 juri <at> linkov.net
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Fri, 09 Dec 2022 21:36:28 +0200
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Cc: Stefan Kangas <stefankangas <at> gmail.com>,  59888 <at> debbugs.gnu.org, Eli
>  Zaretskii <eliz <at> gnu.org>, Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Fri, 09 Dec 2022 13:18:02 +0100
> 
> As discussed before, I introduced a text property so that one can tell
> without guessing which parts of the compilation buffer are not coming
> from the external process.  This seems to supersede the
> 'compilation-header-end' property introduced by Lars in commit
> 07f748da43, so I replaced its uses by the new 'compilation-aside'
> property.  I could easily revert that, but it seemed reasonable to
> uniformize things in this case.

Thanks, but please find a better name for this property.  Something
like compilation-meta-data, perhaps?

> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -41,6 +41,14 @@ connection.
>  
>  * Changes in Specialized Modes and Packages in Emacs 30.1
>  
> +** Compile
> +
> +*** New user option 'grep-use-headings'.
> +When non-nil, the grep output is split into sections, one for each
                     ^^^^
"Grep", capitalized.  Or maybe even "the output of Grep".

> +file, instead of having file names prefixed to each line.  It is
> +equivalent to the --heading option of some tools such as 'git grep'
> +and 'rg.
       ^^^
'rg'




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Fri, 09 Dec 2022 20:04:02 GMT) Full text and rfc822 format available.

Message #50 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org,
 juri <at> linkov.net
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Fri, 09 Dec 2022 21:03:17 +0100
On Fri,  9 Dec 2022 at 21:36, Eli Zaretskii wrote:

>> As discussed before, I introduced a text property so that one can tell
>> without guessing which parts of the compilation buffer are not coming
>> from the external process.  This seems to supersede the
>> 'compilation-header-end' property introduced by Lars in commit
>> 07f748da43, so I replaced its uses by the new 'compilation-aside'
>> property.  I could easily revert that, but it seemed reasonable to
>> uniformize things in this case.
>
> Thanks, but please find a better name for this property.  Something
> like compilation-meta-data, perhaps?

All right, but since it's just a t-or-nil marking, I don't think
metadata is a very good description.  I considered 'compilation-info'
but that seems related to compiler warnings and errors.

I was looking for something that generally describes headers and
footers, prefaces and epilogues, etc., but I'm missing a good word for
that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Fri, 09 Dec 2022 20:30:02 GMT) Full text and rfc822 format available.

Message #53 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: larsi <at> gnus.org, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org,
 juri <at> linkov.net
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Fri, 09 Dec 2022 22:29:10 +0200
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Cc: juri <at> linkov.net,  stefankangas <at> gmail.com,  59888 <at> debbugs.gnu.org,
>   larsi <at> gnus.org
> Date: Fri, 09 Dec 2022 21:03:17 +0100
> 
> > Thanks, but please find a better name for this property.  Something
> > like compilation-meta-data, perhaps?
> 
> All right, but since it's just a t-or-nil marking, I don't think
> metadata is a very good description.  I considered 'compilation-info'
> but that seems related to compiler warnings and errors.

How about 'compilation-details'?

> I was looking for something that generally describes headers and
> footers, prefaces and epilogues, etc., but I'm missing a good word for
> that.

If "details" doesn't fit the bill, how about "decorations"?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Fri, 09 Dec 2022 20:41:02 GMT) Full text and rfc822 format available.

Message #56 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, juri <at> linkov.net, larsi <at> gnus.org,
 59888 <at> debbugs.gnu.org, stefankangas <at> gmail.com
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Fri, 09 Dec 2022 20:40:54 +0000
>
> I was looking for something that generally describes headers and 
> footers, prefaces and epilogues, etc., but I'm missing a good word for 
> that.
>

Decorations?  Frills?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Sat, 10 Dec 2022 17:48:02 GMT) Full text and rfc822 format available.

Message #59 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: larsi <at> gnus.org, Eli Zaretskii <eliz <at> gnu.org>, stefankangas <at> gmail.com,
 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Sat, 10 Dec 2022 19:24:27 +0200
> I was looking for something that generally describes headers and
> footers, prefaces and epilogues, etc., but I'm missing a good word for
> that.

This suggests "marginals":
https://english.stackexchange.com/questions/24060/what-word-defines-a-category-suited-for-both-header-and-footer




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Sat, 10 Dec 2022 20:09:02 GMT) Full text and rfc822 format available.

Message #62 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: larsi <at> gnus.org, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org,
 juri <at> linkov.net
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Sat, 10 Dec 2022 21:08:05 +0100
On Fri,  9 Dec 2022 at 22:29, Eli Zaretskii wrote:

>> From: Augusto Stoffel <arstoffel <at> gmail.com>
>> Cc: juri <at> linkov.net,  stefankangas <at> gmail.com,  59888 <at> debbugs.gnu.org,
>>   larsi <at> gnus.org
>> Date: Fri, 09 Dec 2022 21:03:17 +0100
>> 
>> > Thanks, but please find a better name for this property.  Something
>> > like compilation-meta-data, perhaps?
>> 
>> All right, but since it's just a t-or-nil marking, I don't think
>> metadata is a very good description.  I considered 'compilation-info'
>> but that seems related to compiler warnings and errors.
>
> How about 'compilation-details'?
>
>> I was looking for something that generally describes headers and
>> footers, prefaces and epilogues, etc., but I'm missing a good word for
>> that.
>
> If "details" doesn't fit the bill, how about "decorations"?

Would you be okay with 'compilation-annotation'?  "Decoration" sounds
good, but I like "annotation" slightly better.

Thanks for all the suggestions.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Sat, 10 Dec 2022 20:17:01 GMT) Full text and rfc822 format available.

Message #65 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: larsi <at> gnus.org, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org,
 juri <at> linkov.net
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Sat, 10 Dec 2022 22:16:04 +0200
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Cc: juri <at> linkov.net,  stefankangas <at> gmail.com,  59888 <at> debbugs.gnu.org,
>   larsi <at> gnus.org
> Date: Sat, 10 Dec 2022 21:08:05 +0100
> 
> On Fri,  9 Dec 2022 at 22:29, Eli Zaretskii wrote:
> 
> >> From: Augusto Stoffel <arstoffel <at> gmail.com>
> >> Cc: juri <at> linkov.net,  stefankangas <at> gmail.com,  59888 <at> debbugs.gnu.org,
> >>   larsi <at> gnus.org
> >> Date: Fri, 09 Dec 2022 21:03:17 +0100
> >> 
> >> > Thanks, but please find a better name for this property.  Something
> >> > like compilation-meta-data, perhaps?
> >> 
> >> All right, but since it's just a t-or-nil marking, I don't think
> >> metadata is a very good description.  I considered 'compilation-info'
> >> but that seems related to compiler warnings and errors.
> >
> > How about 'compilation-details'?
> >
> >> I was looking for something that generally describes headers and
> >> footers, prefaces and epilogues, etc., but I'm missing a good word for
> >> that.
> >
> > If "details" doesn't fit the bill, how about "decorations"?
> 
> Would you be okay with 'compilation-annotation'?  "Decoration" sounds
> good, but I like "annotation" slightly better.

Could be.  Or how about compilation-aux-data?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Sun, 11 Dec 2022 11:31:02 GMT) Full text and rfc822 format available.

Message #68 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Sun, 11 Dec 2022 12:30:42 +0100
[Message part 1 (text/plain, inline)]
I've attached a new version of the patch incorporating the latest
discussions.

[0001-Introduce-compilation-annotation-text-property.patch (text/x-patch, attachment)]
[0002-New-user-option-grep-use-headings.patch (text/x-patch, attachment)]
[Message part 4 (text/plain, inline)]
There is still an issue I'm aware of: if one saves a grep buffer to a
file and later opens the file, the headings are inserted a second time.
I've tried a bit to display the headings only using text display
properties (instead of inserting the actual text into the buffer), but
wasn't successful so far.  Other, less elegant solutions are possible
(e.g. deleting all headings either when saving or when reading again the
file).

We could install this change now and polish it later or continue this
discussion -- both are fine by me.

Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 13 Dec 2022 01:05:06 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Thu, 15 Dec 2022 08:33:02 GMT) Full text and rfc822 format available.

Message #73 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Thu, 15 Dec 2022 10:05:39 +0200
> There is still an issue I'm aware of: if one saves a grep buffer to a
> file and later opens the file, the headings are inserted a second time.
> I've tried a bit to display the headings only using text display
> properties (instead of inserting the actual text into the buffer), but
> wasn't successful so far.  Other, less elegant solutions are possible
> (e.g. deleting all headings either when saving or when reading again the
> file).

This reminds a similar problem that the file etc/grep.txt
can't be edited in grep-mode because then it will lose
all grep-filtered escape sequences on saving.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Sat, 25 Feb 2023 08:36:02 GMT) Full text and rfc822 format available.

Message #76 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Sat, 25 Feb 2023 09:34:56 +0100
[Message part 1 (text/plain, inline)]
I've been using the grep-use-headings locally for a long time and it
works well.  Should the the patches be installed?

[0002-New-user-option-grep-use-headings.patch (text/x-patch, attachment)]
[0001-Introduce-compilation-annotation-text-property.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Sat, 25 Feb 2023 18:03:01 GMT) Full text and rfc822 format available.

Message #79 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Sat, 25 Feb 2023 20:00:35 +0200
> I've been using the grep-use-headings locally for a long time and it
> works well.  Should the the patches be installed?

Thanks, I'd like to try out your patches for a few days.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Sun, 26 Feb 2023 13:18:02 GMT) Full text and rfc822 format available.

Message #82 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Sun, 26 Feb 2023 14:17:17 +0100
>>>>> On Sat, 25 Feb 2023 09:34:56 +0100, Augusto Stoffel <arstoffel <at> gmail.com> said:

    Augusto> I've been using the grep-use-headings locally for a long time and it
    Augusto> works well.  Should the the patches be installed?

    Augusto> From 77ea46f6dc50a8f463bd2f51ce9d0585de0bb55c Mon Sep 17 00:00:00 2001
    Augusto> From: Augusto Stoffel <arstoffel <at> gmail.com>
    Augusto> Date: Wed, 7 Dec 2022 18:44:07 +0100
    Augusto> Subject: [PATCH 2/2] New user option 'grep-use-headings'

    Augusto> * lisp/progmodes/grep.el (grep-heading-regexp): New user option.
    Augusto> (grep-heading): New face.
    Augusto> (grep--heading-format, grep--heading-state, grep--heading-filter):
    Augusto> Filter function for grep processes and supporting variables.
    Augusto> (grep-use-headings): New user option.
    Augusto> (grep-mode): Use the above, if applicable.
    Augusto> ---
    Augusto>  etc/NEWS                          |  8 ++++
    Augusto>  lisp/progmodes/grep.el            | 69 +++++++++++++++++++++++++++++++
    Augusto>  test/lisp/progmodes/grep-tests.el | 14 +++++++
    Augusto>  3 files changed, 91 insertions(+)

    Augusto> diff --git a/etc/NEWS b/etc/NEWS
    Augusto> index 4b0e4e6bd46..ca2e8011510 100644
    Augusto> --- a/etc/NEWS
    Augusto> +++ b/etc/NEWS
    Augusto> @@ -95,6 +95,14 @@ If you want to get back the old behavior, set the user option to the value
    Augusto>      (setopt gdb-locals-table-row-config
    Augusto>              `((type . 0) (name . 0) (value . ,gdb-locals-value-limit)))
 
    Augusto> +** Compile
    Augusto> +
    Augusto> +*** New user option 'grep-use-headings'.
    Augusto> +When non-nil, the output of Grep is split into sections, one for each
    Augusto> +file, instead of having file names prefixed to each line.  It is
    Augusto> +equivalent to the --heading option of some tools such as 'git grep'
    Augusto> +and 'rg'.
    Augusto> +

You also add a face and a user option for the regexp, they should be
mentioned in NEWS (and the manual, if relevant)
 
    Augusto> +(defvar grep--heading-format
    Augusto> +  (eval-when-compile
    Augusto> +    (let ((title (propertize "%s"
    Augusto> +                             'font-lock-face 'grep-heading
    Augusto> +                             'outline-level 1)))
    Augusto> +      (propertize (concat title "\n") 'compilation-annotation t)))
    Augusto> +  "Format string of grep headings.
    Augusto> +This is passed to `format' with one argument, the text of the
    Augusto> +first capture group of `grep-heading-regexp'.")
    Augusto> +
    Augusto> +(defvar-local grep--heading-state nil
    Augusto> +  "Variable to keep track of the `grep--heading-filter' state.")
    Augusto> +
    Augusto> +(defun grep--heading-filter ()
    Augusto> +  "Filter function to add headings to output of a grep process."
    Augusto> +  (unless grep--heading-state
    Augusto> +    (setq grep--heading-state (cons (point-min-marker) nil)))
    Augusto> +  (save-excursion
    Augusto> +    (let ((limit (car grep--heading-state)))
    Augusto> +      ;; Move point to the old limit and update limit marker.
    Augusto> +      (move-marker limit (prog1 (pos-bol) (goto-char limit)))
    Augusto> +      (while (re-search-forward grep-heading-regexp limit t)
    Augusto> +        (unless (get-text-property (point) 'compilation-annotation)
    Augusto> +          (let ((heading (match-string-no-properties 1))
    Augusto> +                (start (match-beginning 2))
    Augusto> +                (end (match-end 2)))
    Augusto> +            (when start
    Augusto> +              (put-text-property start end 'invisible t))
    Augusto> +            (when (and heading (not (equal heading (cdr grep--heading-state))))
    Augusto> +              (save-excursion
    Augusto> +                (forward-line 0)

Thatʼs the same as (goto-char (pos-bol)) because of a wrinkle in the
implementation of `forward-line'.  It might even be faster, but Iʼve
not measured it :-)

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Sun, 26 Feb 2023 15:08:01 GMT) Full text and rfc822 format available.

Message #85 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Sun, 26 Feb 2023 16:07:13 +0100
On Sun, 26 Feb 2023 at 14:17, Robert Pluim wrote:

> You also add a face and a user option for the regexp, they should be
> mentioned in NEWS (and the manual, if relevant)

Thanks, I added the face to the NEWS (but not the regexp, which is not a
user option although it can be modified if you are desperate).

>     Augusto> +                (forward-line 0)
>
> Thatʼs the same as (goto-char (pos-bol)) because of a wrinkle in the
> implementation of `forward-line'.  It might even be faster, but Iʼve
> not measured it :-)

Ugh, that was an anachronism.  It will be fixed when I send the final
patch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Mon, 27 Feb 2023 06:25:01 GMT) Full text and rfc822 format available.

Message #88 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Juri Linkov <juri <at> linkov.net>,
 stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Mon, 27 Feb 2023 07:24:19 +0100
>>>>> On Sun, 26 Feb 2023 16:07:13 +0100, Augusto Stoffel <arstoffel <at> gmail.com> said:

    Augusto> On Sun, 26 Feb 2023 at 14:17, Robert Pluim wrote:
    >> You also add a face and a user option for the regexp, they should be
    >> mentioned in NEWS (and the manual, if relevant)

    Augusto> Thanks, I added the face to the NEWS (but not the regexp, which is not a
    Augusto> user option although it can be modified if you are desperate).

Itʼs a `defcustom', so by definition itʼs a user option. If youʼre not
expecting it to be modified, maybe make it a `defvar'.

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Mon, 27 Feb 2023 11:27:01 GMT) Full text and rfc822 format available.

Message #91 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Juri Linkov <juri <at> linkov.net>,
 stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Mon, 27 Feb 2023 12:26:08 +0100
On Mon, 27 Feb 2023 at 07:24, Robert Pluim wrote:

> Itʼs a `defcustom', so by definition itʼs a user option. If youʼre not
> expecting it to be modified, maybe make it a `defvar'.

Oops, I wrote this a couple months back and had forgotten.

I don't know if you have an opinion.  `grep-regexp-alist' is a defconst,
which seems exaggerated, but `grep-match-regexp' is a defcustom although
nobody should want to change this except to work around bugs.

My new variable has a similar "degree of technicality" and I think that
asks for be a defvar.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Mon, 27 Feb 2023 14:19:02 GMT) Full text and rfc822 format available.

Message #94 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-heading-mode'
Date: Mon, 27 Feb 2023 15:18:20 +0100
> +(eval-when-compile (require 'rx))

Is this needed? The `rx` macro is autoloaded.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Mon, 27 Feb 2023 16:52:01 GMT) Full text and rfc822 format available.

Message #97 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stefankangas <at> gmail.com, 59888 <at> debbugs.gnu.org,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Mon, 27 Feb 2023 17:51:33 +0100
>>>>> On Mon, 27 Feb 2023 12:26:08 +0100, Augusto Stoffel <arstoffel <at> gmail.com> said:

    Augusto> On Mon, 27 Feb 2023 at 07:24, Robert Pluim wrote:
    >> Itʼs a `defcustom', so by definition itʼs a user option. If youʼre not
    >> expecting it to be modified, maybe make it a `defvar'.

    Augusto> Oops, I wrote this a couple months back and had forgotten.

    Augusto> I don't know if you have an opinion.  `grep-regexp-alist' is a defconst,
    Augusto> which seems exaggerated, but `grep-match-regexp' is a defcustom although
    Augusto> nobody should want to change this except to work around bugs.

    Augusto> My new variable has a similar "degree of technicality" and I think that
    Augusto> asks for be a defvar.

I think I agree.

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Mon, 27 Feb 2023 18:55:02 GMT) Full text and rfc822 format available.

Message #100 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Robert Pluim <rpluim <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>,
 59888 <at> debbugs.gnu.org, stefankangas <at> gmail.com
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Mon, 27 Feb 2023 20:53:44 +0200
>> Thatʼs the same as (goto-char (pos-bol)) because of a wrinkle in the
>> implementation of `forward-line'.  It might even be faster, but Iʼve
>> not measured it :-)
>
> Ugh, that was an anachronism.  It will be fixed when I send the final
> patch.

I tried out your patch, and everything works nicely.
So I guess it could be pushed when you send the final version.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Mon, 27 Feb 2023 19:07:02 GMT) Full text and rfc822 format available.

Message #103 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Robert Pluim <rpluim <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>,
 59888 <at> debbugs.gnu.org, stefankangas <at> gmail.com
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Mon, 27 Feb 2023 20:06:07 +0100
[Message part 1 (text/plain, inline)]
On Mon, 27 Feb 2023 at 20:53, Juri Linkov wrote:

> I tried out your patch, and everything works nicely.
> So I guess it could be pushed when you send the final version.

There you go :-)

[0002-New-user-option-grep-use-headings.patch (text/x-patch, attachment)]
[0001-Introduce-compilation-annotation-text-property.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Mon, 27 Feb 2023 19:19:02 GMT) Full text and rfc822 format available.

Message #106 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: Robert Pluim <rpluim <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>,
 59888 <at> debbugs.gnu.org, stefankangas <at> gmail.com
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Mon, 27 Feb 2023 21:15:57 +0200
close 59888 30.0.50
thanks

>> I tried out your patch, and everything works nicely.
>> So I guess it could be pushed when you send the final version.
>
> There you go :-)

Thanks for this useful feature.  Now pushed to master.
(And immediately customized it to t ;-)




bug marked as fixed in version 30.0.50, send any further explanations to 59888 <at> debbugs.gnu.org and Augusto Stoffel <arstoffel <at> gmail.com> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 27 Feb 2023 19:19:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Tue, 28 Feb 2023 17:35:04 GMT) Full text and rfc822 format available.

Message #111 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Tue, 28 Feb 2023 19:24:58 +0200
> +(defvar grep-heading-regexp
> +  (rx bol
> +      (or
> +       (group-n 2
> +         (group-n 1 (+ (not (any 0 ?\n))))
> +         0)
> +       (group-n 2
> +        (group-n 1 (+? nonl))
> +        (any ?: ?- ?=)))
> +      (+ digit)
> +      (any ?: ?- ?=))

I wonder what is the reason for this regexp to be different
from grep-regexp-alist?  Especially with such additional characters
as ?- and ?=.  This mismatch causes wrong handling of files when
file names contain these characters.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Tue, 28 Feb 2023 18:18:01 GMT) Full text and rfc822 format available.

Message #114 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Tue, 28 Feb 2023 19:17:45 +0100
On Tue, 28 Feb 2023 at 19:24, Juri Linkov wrote:

>> +(defvar grep-heading-regexp
>> +  (rx bol
>> +      (or
>> +       (group-n 2
>> +         (group-n 1 (+ (not (any 0 ?\n))))
>> +         0)
>> +       (group-n 2
>> +        (group-n 1 (+? nonl))
>> +        (any ?: ?- ?=)))
>> +      (+ digit)
>> +      (any ?: ?- ?=))
>
> I wonder what is the reason for this regexp to be different
> from grep-regexp-alist?  Especially with such additional characters
> as ?- and ?=.  This mismatch causes wrong handling of files when
> file names contain these characters.

This is because of context lines:

--8<---------------cut here---------------start------------->8---
$ git grep -nC 1 grep-use-headings
etc/NEWS-99-
etc/NEWS:100:*** New user option 'grep-use-headings'.
etc/NEWS-101-When non-nil, the output of Grep is split into sections, one for each
--
lisp/progmodes/grep.el-459-
lisp/progmodes/grep.el:460:(defcustom grep-use-headings nil
lisp/progmodes/grep.el-461-  "If non-nil, subdivide grep output into sections, one per file."
--
lisp/progmodes/grep.el-465-(defface grep-heading `((t :inherit ,grep-hit-face))
lisp/progmodes/grep.el:466:  "Face of headings when `grep-use-headings' is non-nil."
lisp/progmodes/grep.el-467-  :version "30.1")
--
lisp/progmodes/grep.el-969-                  (string-replace "\0" ":" string)))
lisp/progmodes/grep.el:970:  (when grep-use-headings
lisp/progmodes/grep.el-971-    (add-hook 'compilation-filter-hook #'grep--heading-filter 80 t)
--8<---------------cut here---------------end--------------->8---

(I forget which program uses the =LINE= syntax)

At least when using grep --null, I think there is no confusion possible.  I
wrote a unit test that purports to prove that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59888; Package emacs. (Wed, 01 Mar 2023 17:59:02 GMT) Full text and rfc822 format available.

Message #117 received at 59888 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 59888 <at> debbugs.gnu.org
Subject: Re: bug#59888: [PATCH] Add 'grep-use-headings'
Date: Wed, 01 Mar 2023 19:52:53 +0200
>>> +      (any ?: ?- ?=))
>>
>> I wonder what is the reason for this regexp to be different
>> from grep-regexp-alist?  Especially with such additional characters
>> as ?- and ?=.  This mismatch causes wrong handling of files when
>> file names contain these characters.
>
> This is because of context lines:
>
> $ git grep -nC 1 grep-use-headings
> lisp/progmodes/grep.el-459-
> lisp/progmodes/grep.el:460:(defcustom grep-use-headings nil
> lisp/progmodes/grep.el-461-  "If non-nil, subdivide grep output into sections, one per file."
> ...
> At least when using grep --null, I think there is no confusion possible.  I
> wrote a unit test that purports to prove that.

Thanks for mentioning --null, I completely forgot about it.
I've customized 'grep-find-template' to "rg --no-heading"
because ripgrep is fast, but since its headings are not
supported by grep.el, so also needed "--no-heading".
And now after adding "--null" to "rg --no-heading --null"
'grep-use-headings' correctly handles context lines
and file names with numbers separated by dashes.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 30 Mar 2023 11:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.