GNU bug report logs - #32365
Interactive Highlighting: prefix arg as subexp selector

Previous Next

Package: emacs;

Reported by: Grégory Mounié <Gregory.Mounie <at> imag.fr>

Date: Fri, 3 Aug 2018 21:52:02 UTC

Severity: wishlist

Tags: fixed, patch

Merged with 32362

Fixed in version 27.1

Done: Noam Postavsky <npostavs <at> gmail.com>

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 32365 in the body.
You can then email your comments to 32365 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#32365; Package emacs. (Fri, 03 Aug 2018 21:52:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Grégory Mounié <Gregory.Mounie <at> imag.fr>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 03 Aug 2018 21:52:02 GMT) Full text and rfc822 format available.

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

From: Grégory Mounié <Gregory.Mounie <at> imag.fr>
To: bug-gnu-emacs <at> gnu.org
Subject: Interactive Highlighting: prefix arg as subexp selector
Date: Fri, 3 Aug 2018 23:50:47 +0200
[Message part 1 (text/plain, inline)]
 Dear Maintainers,

 I propose to use the prefix argument in Interactive Highlighting.
 (the interactive function highlight-regexp)

 Without prefix all should stay identical.

 The numeric argument give the subexpression number of the regexp that 
is highlighted by font_lock or overlay.

 This allows to highlight

  - the 80th char of every line  C-u 1 M-s h r  and regexp ^.\{79\}\(.\)

  - the 6th column of a clean CSV file  C-u 1 M-s h r and regexp 
^\(?:[^,]*,\)\{5\}\([^,]*\),

  (clean CSV == with enough coma as you get multi-line matching with 
this regexp)

 I am not fluent with interactive stuff.
 I am not sure either how to treat errors.

 Have a nice day.
 Grégory Mounié


PS: Sorry for generating noise with my previous patch (BUG: 32362)
[0001-Interactive-Highlighting-prefix-argument-to-select-s.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32365; Package emacs. (Mon, 06 Aug 2018 03:08:02 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Grégory Mounié <Gregory.Mounie <at> imag.fr>
Cc: 32365 <at> debbugs.gnu.org
Subject: Re: bug#32365: Interactive Highlighting: prefix arg as subexp selector
Date: Sun, 05 Aug 2018 23:07:46 -0400
tags 32365 + patch
forcemerge 32362 32365
quit

Grégory Mounié <Gregory.Mounie <at> imag.fr> writes:

> PS: Sorry for generating noise with my previous patch (BUG: 32362)

No problem, I'll just merge the bugs.  Next time, you can respond to
your own bug report by sending mail to xxxxx <at> debbugs.gnu.org, and the
new patch would be added to the same thread.

>>From 6b6291ce1974a363080f535b40f06d5772ffa1be Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Gr=C3=A9gory=20Mouni=C3=A9?= <Gregory.Mounie <at> imag.fr>
> Date: Fri, 3 Aug 2018 23:08:10 +0200
> Subject: [PATCH] Interactive Highlighting: prefix argument to select subexp
>
> Use prefix-argument to highlight only the corresponding
> subexpression of the regexp.
>
> * lisp/hi-lock.el (hi-lock-face-buffer, hi-lock-set-pattern)

The message should go after the ChangeLog entry, as in

* lisp/hi-lock.el (hi-lock-face-buffer, hi-lock-set-pattern): Use
prefix-argument to highlight only the corresponding subexpression of the
regexp.

And I think we should have a NEWS entry mentioning the new feature too.

> -(defun hi-lock-face-buffer (regexp &optional face)
> +(defun hi-lock-face-buffer (regexp &optional face subexp)
>    "Set face of each match of REGEXP to FACE.
>  Interactively, prompt for REGEXP using `read-regexp', then FACE.
>  Use the global history list for FACE.

> -(defun hi-lock-set-pattern (regexp face)
> +(defun hi-lock-set-pattern (regexp face &optional arg)
>    "Highlight REGEXP with face FACE."

You should mention the new arg in the docstrings.
  
> +  (let* ((subexp (if (null arg) 0 arg))

This kind of thing is usually expressesd as (or arg 0).  Though since
`arg' is a bit vague, it might be clearer to rename arg as subexp, and
then inside the function do

    (setq subexp (or subexp 0))

> +                (let ((overlay (make-overlay (match-beginning subexp)
> +                                             (match-end subexp))))
> +                  (overlay-put overlay 'hi-lock-overlay t)
> +                (overlay-put overlay 'hi-lock-orverlay-regexp regexp)
                                                 ^^^^^^^^
Looks like a typo.




Added tag(s) patch. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 06 Aug 2018 03:08:02 GMT) Full text and rfc822 format available.

Forcibly Merged 32362 32365. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 06 Aug 2018 03:08:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32365; Package emacs. (Wed, 08 Aug 2018 14:11:01 GMT) Full text and rfc822 format available.

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

From: Grégory Mounié <Gregory.Mounie <at> imag.fr>
To: 32365 <at> debbugs.gnu.org
Subject: Re: bug#32365: Interactive Highlighting: prefix arg as subexp selector
Date: Wed, 8 Aug 2018 16:10:43 +0200
 Here the patch for modifying Automatic Interactive Highlighting 
(hi-lock.el) for adding prefix-argument to highlight-regexp

 I add a line documenting the option in the corresponding 
hightlight-regexp documentation in doc/emacs/display.texi and a section 
in NEWS.


 Thanks a lot for the feedback and comments.
 Grégory Mounié




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32365; Package emacs. (Wed, 08 Aug 2018 14:13:02 GMT) Full text and rfc822 format available.

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

From: Grégory Mounié <Gregory.Mounie <at> imag.fr>
To: 32365 <at> debbugs.gnu.org
Subject: Re: bug#32365: Interactive Highlighting: prefix arg as subexp selector
Date: Wed, 8 Aug 2018 16:12:36 +0200
[Message part 1 (text/plain, inline)]
 Here the patch for modifying Automatic Interactive Highlighting 
(hi-lock.el) for adding prefix-argument to highlight-regexp

 I add a line documenting the option in the corresponding 
hightlight-regexp documentation in doc/emacs/display.texi and a section 
in NEWS.


 Thanks a lot for the feedback and comments.
 Grégory Mounié

PS: it is even better with the patch
[0001-Interactive-Highlighting-prefix-argument-to-select-s.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32365; Package emacs. (Tue, 14 Aug 2018 23:50:02 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Grégory Mounié <Gregory.Mounie <at> imag.fr>
Cc: 32365 <at> debbugs.gnu.org
Subject: Re: bug#32365: Interactive Highlighting: prefix arg as subexp selector
Date: Tue, 14 Aug 2018 19:49:12 -0400
tags 32365 fixed
close 32365 27.1
quit

Grégory Mounié <Gregory.Mounie <at> imag.fr> writes:

>  Here the patch for modifying Automatic Interactive Highlighting
> (hi-lock.el) for adding prefix-argument to highlight-regexp
>
>  I add a line documenting the option in the corresponding
> hightlight-regexp documentation in doc/emacs/display.texi and a
> section in NEWS.

Thanks, pushed to master [1: cc5a23d40b].  I fixed a couple of minor
things (we use double spacing at end-of-sentence, NEWS entries
should first line should be a whole sentence, and some
whitespace/indentation issues).

[1: cc5a23d40b]: 2018-08-14 19:38:21 -0400
  Interactive Highlighting: prefix argument to select subexp
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=cc5a23d40bfa7a832f7a6fb7a016557ac1416559




Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 14 Aug 2018 23:50:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 32365 <at> debbugs.gnu.org and Grégory Mounié <Gregory.Mounie <at> imag.fr> Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 14 Aug 2018 23:50:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 12 Sep 2018 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 280 days ago.

Previous Next


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