GNU bug report logs -
#78396
[PATCH] Add option for not highlight parens inside comments or strings.
Previous Next
To reply to this bug, email your comments to 78396 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Mon, 12 May 2025 18:53:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Elijah Gabe Pérez <eg642616 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 12 May 2025 18:53:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Tags: patch
Sometimes show-paren will highlight the parens that are inside a
comment/string which looks annoying and somewhat confusing.
e.g.
show-paren will highlight this paren:
;; :^)| <- cursor
^ paren highlighted as mismatch
or:
v
(
;; )| <- cursor
^ both parens highlighted
I've made an option for disable/control this behavior, by default its
disabled but I wonder if this should be activated instead.
[0001-Add-option-for-not-highlight-parens-inside-comments-.patch (text/patch, attachment)]
[Message part 3 (text/plain, inline)]
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Sat, 17 May 2025 09:25:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 78396 <at> debbugs.gnu.org (full text, mbox):
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Date: Mon, 12 May 2025 12:51:57 -0600
>
> Sometimes show-paren will highlight the parens that are inside a
> comment/string which looks annoying and somewhat confusing.
>
> e.g.
> show-paren will highlight this paren:
>
> ;; :^)| <- cursor
> ^ paren highlighted as mismatch
>
> or:
> v
> (
> ;; )| <- cursor
> ^ both parens highlighted
>
> I've made an option for disable/control this behavior, by default its
> disabled but I wonder if this should be activated instead.
I'm worried by using syntax-ppss-context here: couldn't it sometimes
significantly slow down the highlighting of parens? Stefan, WDYT?
> +@vindex show-paren-not-in-comments-or-strings
> +@code{show-paren-not-in-comments-or-strings}, If set to @code{all}, do
^^
That "If" should be in lower case.
> +not highlight all the parens that are inside comments or strings. If
> +set to @code{on-mismatch}, only don't highlight if paren mismatched. If set
> +to @code{nil} (by default), highlight the paren wherever it is.
The style here is not appropriate for the manual, it is a style for
the doc string. I'd use something like
If the value of @code{show-paren-not-in-comments-or-strings} is
@code{all}, delimiters inside comments and strings will not be
highlighted.
> +** New user option 'show-paren-not-in-comments-or-strings'
The period at the end of this heading line is missing.
> +This option tells show-paren don't highlight the parens that are inside
^^^^^^^^^^^^^^^
"not to highlight"
> +(defcustom show-paren-not-in-comments-or-strings nil
> + "Do not highlight the parens that are inside a comment or string.
> +If set to `all', do not highlight all the parens that are inside comments
> +or strings.
> +If set to `on-mismatch', only don't highlight if paren mismatched.
> +If set to nil (by default), highlight the paren wherever it is."
> + :type '(choice
> + (const :tag "Enable" all)
"Enable" is not a good tag here, because this feature actually
_disables_ highlighting. I would use "Never highlight" instead.
> + (const :tag "Only on mismatch" on-mismatch)
And here I'd use "Don't highlight when mismatched".
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Tue, 20 May 2025 02:55:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 78396 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> I've made an option for disable/control this behavior, by default its
>> disabled but I wonder if this should be activated instead.
>
> I'm worried by using syntax-ppss-context here: couldn't it sometimes
> significantly slow down the highlighting of parens?
I've tried it but haven't noticed any slow down (maybe because of the
machine I have(?))
But if syntax-ppss is slow, isn't there a better alternative?
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Wed, 21 May 2025 11:13:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 78396 <at> debbugs.gnu.org (full text, mbox):
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 78396 <at> debbugs.gnu.org
> Date: Mon, 19 May 2025 20:54:15 -0600
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> I've made an option for disable/control this behavior, by default its
> >> disabled but I wonder if this should be activated instead.
> >
> > I'm worried by using syntax-ppss-context here: couldn't it sometimes
> > significantly slow down the highlighting of parens?
>
> I've tried it but haven't noticed any slow down (maybe because of the
> machine I have(?))
>
> But if syntax-ppss is slow, isn't there a better alternative?
I hope Stefan will chime in and provide his opinions on this.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Tue, 27 May 2025 21:03:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 78396 <at> debbugs.gnu.org (full text, mbox):
>> Sometimes show-paren will highlight the parens that are inside a
>> comment/string which looks annoying and somewhat confusing.
>>
>> e.g.
>> show-paren will highlight this paren:
>>
>> ;; :^)| <- cursor
>> ^ paren highlighted as mismatch
>>
>> or:
>> v
>> (
>> ;; )| <- cursor
>> ^ both parens highlighted
Ideally, we'd want to match closing-parens-in-comments with
opening-parens-in-comments. But yes, it's good to refrain from giving
the above bogus highlighting.
>> I've made an option for disable/control this behavior, by default its
>> disabled but I wonder if this should be activated instead.
> I'm worried by using syntax-ppss-context here: couldn't it sometimes
> significantly slow down the highlighting of parens? Stefan, WDYT?
`syntax-ppss` is not cheap, but here it's not used inside a loop and
should be called only once per user-interaction so I'm not worried.
I see there are two calls, tho, so I'd try to consolidate them so we call
it at most once.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Tue, 27 May 2025 23:08:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 78396 <at> debbugs.gnu.org (full text, mbox):
> Ideally, we'd want to match closing-parens-in-comments with
> opening-parens-in-comments.
We would? A comment can contain anything. A paren in
a comment isn't necessarily a delimiter. "Parsing"
comments in an a priori way is misguided, on the whole.
What we'd really want is a way _to be able_ to match
closing parens (or other closing delimiters, per the
major mode) within comments. IOW, this should be an
option (and preferably opt-in, not out).
Just one opinion. And caveat: I'm not following this
thread - piping up in ignorance of context, including
knowing what might be important for this bug report.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Sat, 31 May 2025 11:49:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 78396 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Elijah Gabe Pérez <eg642616 <at> gmail.com>,
> 78396 <at> debbugs.gnu.org
> Date: Tue, 27 May 2025 17:02:20 -0400
>
> Ideally, we'd want to match closing-parens-in-comments with
> opening-parens-in-comments. But yes, it's good to refrain from giving
> the above bogus highlighting.
>
> >> I've made an option for disable/control this behavior, by default its
> >> disabled but I wonder if this should be activated instead.
> > I'm worried by using syntax-ppss-context here: couldn't it sometimes
> > significantly slow down the highlighting of parens? Stefan, WDYT?
>
> `syntax-ppss` is not cheap, but here it's not used inside a loop and
> should be called only once per user-interaction so I'm not worried.
> I see there are two calls, tho, so I'd try to consolidate them so we call
> it at most once.
Thanks.
Elijah, would you like to update your patch as suggested by Stefan
above?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Sat, 31 May 2025 14:59:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 78396 <at> debbugs.gnu.org (full text, mbox):
>> `syntax-ppss` is not cheap, but here it's not used inside a loop and
>> should be called only once per user-interaction so I'm not worried.
>> I see there are two calls, tho, so I'd try to consolidate them so we call
>> it at most once.
>
> Thanks.
>
> Elijah, would you like to update your patch as suggested by Stefan
> above?
Actually, I now see that the two calls can never happen at the same
time, so there's no change necessary.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Sat, 31 May 2025 18:22:03 GMT)
Full text and
rfc822 format available.
Message #29 received at 78396 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> Thanks.
>>
>> Elijah, would you like to update your patch as suggested by Stefan
>> above?
>
> Actually, I now see that the two calls can never happen at the same
> time, so there's no change necessary.
Anyways I'm sending here an updated version of the patch with Eli's
suggestions
[0001-Add-option-for-not-highlight-parens-inside-comments-.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
--
- E.G via GNU Emacs and Org.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Sun, 01 Jun 2025 09:50:04 GMT)
Full text and
rfc822 format available.
Message #32 received at 78396 <at> debbugs.gnu.org (full text, mbox):
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 78396 <at> debbugs.gnu.org
> Date: Sat, 31 May 2025 12:20:52 -0600
>
> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
> >> Thanks.
> >>
> >> Elijah, would you like to update your patch as suggested by Stefan
> >> above?
> >
> > Actually, I now see that the two calls can never happen at the same
> > time, so there's no change necessary.
>
> Anyways I'm sending here an updated version of the patch with Eli's
> suggestions
Thanks, a few minor comments below:
> * lisp/paren.el (show-paren-not-in-comments-or-strings):
> New user option. (bug#78396)
^^
Two spaces there, and "Bug" should be capitalized.
> (show-paren-function): Enclose code in `catch` function.
^^^^^^^
Please quote 'like this' in log messages.
> * doc/emacs/programs.texi: Document new option.
Please mention the node where you made the changes (in parentheses, as
if it were a function).
> +@item
> +@vindex show-paren-not-in-comments-or-strings
> +If the value of @code{show-paren-not-in-comments-or-strings} is
> +@code{all}, delimiters inside comments and strings will not be
> +highlighted. Otherwise if the value is set to @code{on-mismatch}, the
> +delimiters mismatched inside comments will not be highlighted.
^^^^^^^^^^^^^^^^^^^^^
"mismatched delimiters", i.e. reverse the order.
> +** New user option 'show-paren-not-in-comments-or-strings'
> +This option tells show-paren not to highlight the paren that are inside
^^^^^
"parens", plural. Also, this is not only about parentheses, right?
> +a comment or string. If set to 'all', do not highlight the paren that
^^^^^
"parens"
> +are inside comments or strings. If set to 'on-mismatch', the paren
^^^^^
And here.
> +mismatched inside comments will not be highlighted. If set to nil (by
> +default), highlight the paren wherever it is. ^^^
^^^^^^^^
We say "(the default)". Also, "highlight the parens wherever they
are", in plural again.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78396
; Package
emacs
.
(Fri, 06 Jun 2025 05:08:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 78396 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Anyways I'm sending here an updated version of the patch with Eli's
>> suggestions
>
> Thanks, a few minor comments below:
>
[...]
Thanks, sending fixed version:
[0001-Add-option-for-not-highlight-parens-inside-comments-.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
--
- E.G via GNU Emacs and Org.
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Sat, 07 Jun 2025 10:35:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Elijah Gabe Pérez <eg642616 <at> gmail.com>
:
bug acknowledged by developer.
(Sat, 07 Jun 2025 10:35:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 78396-done <at> debbugs.gnu.org (full text, mbox):
> From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
> Cc: monnier <at> iro.umontreal.ca, 78396 <at> debbugs.gnu.org
> Date: Thu, 05 Jun 2025 23:06:51 -0600
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> Anyways I'm sending here an updated version of the patch with Eli's
> >> suggestions
> >
> > Thanks, a few minor comments below:
> >
>
> [...]
>
> Thanks, sending fixed version:
Thanks, installed on the master branch (with a couple of followup
minor changes), and closing the bug.
This bug report was last modified 10 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.