GNU bug report logs -
#11982
24.1.50; (Contains ERT Test) show-paren-mode doesn't work in C comments if there's a quote between the parenthesis (affects c-mode and modes derived from it)
Previous Next
Reported by: Rolando Pereira <rolando_pereira <at> sapo.pt>
Date: Wed, 18 Jul 2012 20:23:01 UTC
Severity: minor
Tags: confirmed, fixed
Found in versions 25.3, 25.2, 24.1.50
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 11982 in the body.
You can then email your comments to 11982 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11982
; Package
emacs
.
(Wed, 18 Jul 2012 20:23:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Rolando Pereira <rolando_pereira <at> sapo.pt>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 18 Jul 2012 20:23:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
In c-mode if you type the following comment with M-x show-paren-mode
activated, the closing parenthesis is highlighted correctly:
// Lorem ipsum (dolor sit amet)
However, if the ' character appears inside the parenthesis, then
show-paren-mode won't match them.
For example, when typing the following comment, show-paren-mode highlights
the closing parenthesis using show-paren-mismatch:
// Comments are good (aren't they?)
I tried to make an ERT test that would check if the parenthesis was
highlighted correctly, but I couldn't get the overlay that
show-paren-mode uses.
However I found out that forward-sexp also doesn't work when the '
character appears between parenthesis, which makes me think the problem
may be somewhere in the syntax-table used by c-mode.
Here's the ERT test:
(ert-deftest cc-mode-should-forward-sexp-with-quotes-inside ()
"Check if `forward-sexp' works in c-mode when the cursor is
inside a comment and there's a ' character inside the
parenthesis"
(with-temp-buffer
(c-mode)
(insert "// Comments are good (aren't they?)")
(goto-char (point-min))
(search-forward "(")
(backward-char 1)
(forward-sexp)
(ert-should (= (point) 36))))
Also, the reason I think that the problem only affects c-mode and modes that
derive from it is because this problem doesn't show up in
emacs-lisp-mode or lisp-mode.
Here's how to see the problem when starting emacs with the -Q flag:
1. Create the temporary buffer "temp-buffer" with C-x b temp-buffer RET
2. Activate c-mode with M-x c-mode
3. Activate show-paren-mode with M-x show-paren-mode
4. Write "// Comments are good (aren't they?)"
5. When typing the closing parenthesis, notice that it's highlighted
with the face show-paren-mismatch
Another test that can be used that doesn't use show-paren-mode but still
shows wrong behaviour is the following:
1. Create the temporary buffer as before
2. Activate c-mode as before
2. Write "// Comments are good (aren't they?)"
3. When typing the closing parenthesis, notice that the minibuffer shows
the message "No matching parenthesis found".
In GNU Emacs 24.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.20.1)
of 2012-07-15 on rolando-desktop
Bzr revision: 109096 dmantipov <at> yandex.ru-20120715111709-pa3d1hni2gmjdux0
Windowing system distributor `The X.Org Foundation', version 11.0.10706000
Important settings:
value of $LANG: pt_PT.utf8
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
M-x r e p o r <tab> <return>
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Starting new Ispell process [/usr/bin/aspell::default] ...
Checking spelling of PARENTHESIS...
byte-code: Window #<window 4 on *Minibuf-1*> too small for splitting
Load-path shadows:
None found.
Features:
(shadow sort gnus-util mail-extr ispell emacsbug message format-spec
rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils time-date tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)
bug Marked as found in versions 25.2.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sat, 25 Mar 2017 03:28:01 GMT)
Full text and
rfc822 format available.
Added tag(s) confirmed.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sat, 25 Mar 2017 03:28:01 GMT)
Full text and
rfc822 format available.
Severity set to 'minor' from 'normal'
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sat, 25 Mar 2017 03:28:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11982
; Package
emacs
.
(Thu, 22 Aug 2019 13:46:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 11982 <at> debbugs.gnu.org (full text, mbox):
On 2012-07-18 21:16:17 +0100, Rolando Pereira wrote:
> In c-mode if you type the following comment with M-x show-paren-mode
> activated, the closing parenthesis is highlighted correctly:
>
> // Lorem ipsum (dolor sit amet)
>
> However, if the ' character appears inside the parenthesis, then
> show-paren-mode won't match them.
>
> For example, when typing the following comment, show-paren-mode highlights
> the closing parenthesis using show-paren-mismatch:
>
> // Comments are good (aren't they?)
I can reproduce this bug with Emacs 26.1 from the Debian package,
but the current development version seems fine. Has this bug been
fixed?
--
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11982
; Package
emacs
.
(Thu, 22 Aug 2019 15:06:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 11982 <at> debbugs.gnu.org (full text, mbox):
found 11982 25.3
tags 11982 fixed
close 11982 26.1
quit
Vincent Lefevre <vincent <at> vinc17.net> writes:
> On 2012-07-18 21:16:17 +0100, Rolando Pereira wrote:
>> In c-mode[...] when typing the following comment, show-paren-mode highlights
>> the closing parenthesis using show-paren-mismatch:
>>
>> // Comments are good (aren't they?)
>
> I can reproduce this bug with Emacs 26.1 from the Debian package,
> but the current development version seems fine. Has this bug been
> fixed?
I can reproduce up to 25.3, but it seems to be fixed in 26.1.
bug Marked as found in versions 25.3.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 22 Aug 2019 15:06:02 GMT)
Full text and
rfc822 format available.
Added tag(s) fixed.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 22 Aug 2019 15:06:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 26.1, send any further explanations to
11982 <at> debbugs.gnu.org and Rolando Pereira <rolando_pereira <at> sapo.pt>
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 22 Aug 2019 15:06:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11982
; Package
emacs
.
(Thu, 22 Aug 2019 15:21:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 11982 <at> debbugs.gnu.org (full text, mbox):
On 2019-08-22 11:05:04 -0400, Noam Postavsky wrote:
> I can reproduce up to 25.3, but it seems to be fixed in 26.1.
No, not fixed in 26.1, where this depends on some context.
This is rather random, but here's a way to reproduce the
bug in Debian:
1. emacs-gtk -Q foo.c
(where foo.c does not exist)
2. Paste "// Comments are good (aren't they?)"
3. Type C-M-p
I get an error:
forward-list: Scan error: "Unbalanced parentheses", 35, 1
This problem does not occur without the apostrophe.
--
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11982
; Package
emacs
.
(Thu, 22 Aug 2019 15:49:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 11982 <at> debbugs.gnu.org (full text, mbox):
fixed 11982 27.1
notfixed 11982 26.1
quit
Vincent Lefevre <vincent <at> vinc17.net> writes:
> On 2019-08-22 11:05:04 -0400, Noam Postavsky wrote:
>> I can reproduce up to 25.3, but it seems to be fixed in 26.1.
>
> No, not fixed in 26.1, where this depends on some context.
> This is rather random, but here's a way to reproduce the
> bug in Debian:
>
> 1. emacs-gtk -Q foo.c
> (where foo.c does not exist)
>
> 2. Paste "// Comments are good (aren't they?)"
>
> 3. Type C-M-p
>
> I get an error:
>
> forward-list: Scan error: "Unbalanced parentheses", 35, 1
>
> This problem does not occur without the apostrophe.
Oh, interesting, if I delete and re-insert the apostrophe, it stops
happening, i.e., there is some hidden state which affects things as
well.
bug Marked as fixed in versions 27.1.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 22 Aug 2019 15:49:02 GMT)
Full text and
rfc822 format available.
bug No longer marked as fixed in versions 26.1.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 22 Aug 2019 15:49:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11982
; Package
emacs
.
(Sun, 25 Aug 2019 15:04:02 GMT)
Full text and
rfc822 format available.
Message #36 received at 11982 <at> debbugs.gnu.org (full text, mbox):
Hello, Vincent and Noam.
In article <mailman.72.1566487266.1922.bug-gnu-emacs <at> gnu.org> you wrote:
> On 2019-08-22 11:05:04 -0400, Noam Postavsky wrote:
>> I can reproduce up to 25.3, but it seems to be fixed in 26.1.
> No, not fixed in 26.1, where this depends on some context.
This "context" is a syntax-table text property on the apostrophe which
"neutralises" it's normal string syntax. Without this text property,
the apostrophe, a string opener, breaks the association of the two
parentheses.
The code which applies and removes these syntax-table text properties is
somewhat involved. I believe it is working correctly in the master
branch, but wasn't in Emacs-26.
> This is rather random, but here's a way to reproduce the
> bug in Debian:
> 1. emacs-gtk -Q foo.c
> (where foo.c does not exist)
> 2. Paste "// Comments are good (aren't they?)"
For some value of "paste". Inserting the text on a Linux tty with the GPM
mouse utility (in 26.1) causes the text property to be correctly set.
Killing the entire line with C-k, followed by yanking it with C-y leaves
the text property unset (again in 26.1).
> 3. Type C-M-p
> I get an error:
> forward-list: Scan error: "Unbalanced parentheses", 35, 1
> This problem does not occur without the apostrophe.
No. The apostrophe is a "string opener", see above. It's normal use is
to delimit character constants, as:
char foo = 'F';
> --
> Vincent Lefèvre <vincent <at> vinc17.net> - Web: <https://www.vinc17.net/>
> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
--
Alan Mackenzie (Nuremberg, Germany).
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 23 Sep 2019 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 236 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.