GNU bug report logs - #78865
31.0.50; Inconsistency between show-paren-mode and some cursor-movement commands

Previous Next

Package: emacs;

Reported by: Dani Moncayo <dmoncayo <at> gmail.com>

Date: Sun, 22 Jun 2025 18:55:02 UTC

Severity: normal

Tags: notabug, wontfix

Fixed in version 31.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 78865 in the body.
You can then email your comments to 78865 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#78865; Package emacs. (Sun, 22 Jun 2025 18:55:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dani Moncayo <dmoncayo <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 22 Jun 2025 18:55:03 GMT) Full text and rfc822 format available.

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

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: bug-gnu-emacs <bug-gnu-emacs <at> gnu.org>
Subject: 31.0.50; Inconsistency between show-paren-mode and some
 cursor-movement commands
Date: Sun, 22 Jun 2025 20:53:39 +0200
Consider a C source file like the one created with the shell command below [1].

If I visit that file with Emacs and move the cursor just before the
"[", I see that both square brackets are highlighted -- perfect.

But then, if I type C-M-n from that point, I'd expect the cursor to
jump from the "[" to the "]".  Well, it does not. Instead, the cursor
jumps just after "f1()".

This behavior seems inconsistent to me, and also doesn't allow me to
move between those "comment-marks" I like to put sometimes in my code
to define a kind of logical grouping.

And BTW, if I change the major mode to text-mode, I get the behavior I
want -- I can even type C-M-u from anywhere inside that "logical
group" and jump to its beginning "[".

--
Dani Moncayo

Footnote [1]:
$ cat <<eof > file1.c
//[ begin of group foo

int void f1()
{
  //...
}
int void f2()
{
  //...
}

//] end of group foo
eof

--
In GNU Emacs 31.0.50 (build 31, x86_64-pc-linux-gnu, GTK+ Version
 3.24.41, cairo version 1.18.0) of 2025-06-22 built on C11-Q8YAKWONJX0
Repository revision: e5ad9ae10090ab34a4d71139e6f928c11f0c029c
Repository branch: master
Windowing system distributor 'Microsoft Corporation', version 11.0.12010000
System Description: Ubuntu 24.04.2 LTS

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG
LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINERAMA
XINPUT2 XPM XRANDR GTK3 ZLIB

Important settings:
  value of $LANG: C.UTF-8
  locale-coding-system: utf-8-unix

Major mode: C/*l

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-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
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  abbrev-mode: t




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78865; Package emacs. (Sun, 22 Jun 2025 22:08:02 GMT) Full text and rfc822 format available.

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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 78865 <at> debbugs.gnu.org
Subject: Re: bug#78865: 31.0.50; Inconsistency between show-paren-mode and
 some cursor-movement commands
Date: Mon, 23 Jun 2025 00:07:24 +0200
On Sun, 22 Jun 2025 20:53:39 +0200 Dani Moncayo <dmoncayo <at> gmail.com> wrote:

> Consider a C source file like the one created with the shell command below [1].
>
> If I visit that file with Emacs and move the cursor just before the
> "[", I see that both square brackets are highlighted -- perfect.
>
> But then, if I type C-M-n from that point, I'd expect the cursor to
> jump from the "[" to the "]".  Well, it does not. Instead, the cursor
> jumps just after "f1()".
>
> This behavior seems inconsistent to me, and also doesn't allow me to
> move between those "comment-marks" I like to put sometimes in my code
> to define a kind of logical grouping.

`C-M-n' runs the command `forward-list', whose doc string says: "This
command assumes point is not in a string or comment."

> And BTW, if I change the major mode to text-mode, I get the behavior I
> want -- I can even type C-M-u from anywhere inside that "logical
> group" and jump to its beginning "[".

That's because "//" does not mark a comment in text-mode, which defines
no comment syntax by default.  But text-mode recognizes "[" and "]" as
balanced delimiters, so C-M-n and C-M-u work as expected with them.

Steve Berman

> Footnote [1]:
> $ cat <<eof > file1.c
> //[ begin of group foo
>
> int void f1()
> {
>   //...
> }
> int void f2()
> {
>   //...
> }
>
> //] end of group foo
> eof




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78865; Package emacs. (Mon, 23 Jun 2025 06:43:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 78865 <at> debbugs.gnu.org
Subject: Re: bug#78865: 31.0.50; Inconsistency between show-paren-mode and
 some cursor-movement commands
Date: Mon, 23 Jun 2025 09:37:51 +0300
> Consider a C source file like the one created with the shell command below [1].
>
> If I visit that file with Emacs and move the cursor just before the
> "[", I see that both square brackets are highlighted -- perfect.
>
> But then, if I type C-M-n from that point, I'd expect the cursor to
> jump from the "[" to the "]".  Well, it does not. Instead, the cursor
> jumps just after "f1()".

Is this in c-mode or c-ts-mode?  Are there any differences in this regard
between c-mode or c-ts-mode?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78865; Package emacs. (Mon, 23 Jun 2025 07:20:02 GMT) Full text and rfc822 format available.

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

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 78865 <at> debbugs.gnu.org
Subject: Re: bug#78865: 31.0.50; Inconsistency between show-paren-mode and
 some cursor-movement commands
Date: Mon, 23 Jun 2025 09:19:07 +0200
On Mon, Jun 23, 2025 at 8:42 AM Juri Linkov <juri <at> linkov.net> wrote:
>
> > Consider a C source file like the one created with the shell command below [1].
> >
> > If I visit that file with Emacs and move the cursor just before the
> > "[", I see that both square brackets are highlighted -- perfect.
> >
> > But then, if I type C-M-n from that point, I'd expect the cursor to
> > jump from the "[" to the "]".  Well, it does not. Instead, the cursor
> > jumps just after "f1()".
>
> Is this in c-mode or c-ts-mode?

This was using c-ts-mode.

> Are there any differences in this regard
> between c-mode or c-ts-mode?

I've now tried using c-mode: the highlighting is the same, but
pressing C-M-n results in an error: 'No next group'.

-- 
Dani Moncayo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78865; Package emacs. (Mon, 23 Jun 2025 11:18:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 78865 <at> debbugs.gnu.org
Subject: Re: bug#78865: 31.0.50;
 Inconsistency between show-paren-mode and some cursor-movement
 commands
Date: Mon, 23 Jun 2025 14:17:24 +0300
> From: Dani Moncayo <dmoncayo <at> gmail.com>
> Date: Sun, 22 Jun 2025 20:53:39 +0200
> 
> Consider a C source file like the one created with the shell command below [1].
> 
> If I visit that file with Emacs and move the cursor just before the
> "[", I see that both square brackets are highlighted -- perfect.
> 
> But then, if I type C-M-n from that point, I'd expect the cursor to
> jump from the "[" to the "]".  Well, it does not. Instead, the cursor
> jumps just after "f1()".

Why do you expect C-M-n to do that when the brackets are in comments?
That's not what C-M-n and its ilk are about: they allow to move by
code chunks, not by arbitrary text fragments.

Try this with brackets in code, and I think you will see the behavior
you expect.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78865; Package emacs. (Mon, 23 Jun 2025 11:42:04 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: 78865 <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#78865: 31.0.50;
 Inconsistency between show-paren-mode and some cursor-movement
 commands
Date: Mon, 23 Jun 2025 14:41:38 +0300
> Cc: 78865 <at> debbugs.gnu.org
> From: Dani Moncayo <dmoncayo <at> gmail.com>
> Date: Mon, 23 Jun 2025 09:19:07 +0200
> 
> > Are there any differences in this regard
> > between c-mode or c-ts-mode?
> 
> I've now tried using c-mode: the highlighting is the same, but
> pressing C-M-n results in an error: 'No next group'.

Exactly.  Which is one more evidence that this is not supposed to do
what you expected, because the brackets are in comments, where they
lose their usual syntactic meaning assigned by the programming
language.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78865; Package emacs. (Mon, 23 Jun 2025 12:05:04 GMT) Full text and rfc822 format available.

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

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78865 <at> debbugs.gnu.org
Subject: Re: bug#78865: 31.0.50; Inconsistency between show-paren-mode and
 some cursor-movement commands
Date: Mon, 23 Jun 2025 14:03:51 +0200
On Mon, Jun 23, 2025 at 1:17 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
> Why do you expect C-M-n to do that when the brackets are in comments?

Because I saw the highlighting of both brackets, and I intuitively
felt that I could navigate between them (In fact, I'd prefer
show-paren-mode to be consistent with cursor motion commands line
C-M-n).

I still think that the behavior I did envision would make sense and
would be useful. -- as I explained, I sometimes write such comments in
code, with the intent to delimit/identify/annotate certain chunks of
code.  Being able to move around that meta-syntactic structure would
be great.

> That's not what C-M-n and its ilk are about: they allow to move by
> code chunks, not by arbitrary text fragments.
>
> Try this with brackets in code, and I think you will see the behavior
> you expect.

If what I'm trying to achieve doesn't make sense to you guys, then
let's close this ticket.  No problem :).

Thanks.

-- 
Dani Moncayo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78865; Package emacs. (Mon, 23 Jun 2025 17:14:03 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 78865 <at> debbugs.gnu.org
Subject: Re: bug#78865: 31.0.50; Inconsistency between show-paren-mode and
 some cursor-movement commands
Date: Mon, 23 Jun 2025 20:12:24 +0300
tags 78865 + notabug wontfix
close 78865 31.0.50
thanks

>> Try this with brackets in code, and I think you will see the behavior
>> you expect.
>
> If what I'm trying to achieve doesn't make sense to you guys, then
> let's close this ticket.  No problem :).

The problem is that 'prog-mode' contains:

  (setq-local parse-sexp-ignore-comments t)

When you set it back to nil, then your test case works as you want.
So now closing this report.




Added tag(s) notabug and wontfix. Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 23 Jun 2025 17:14:05 GMT) Full text and rfc822 format available.

bug marked as fixed in version 31.0.50, send any further explanations to 78865 <at> debbugs.gnu.org and Dani Moncayo <dmoncayo <at> gmail.com> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Mon, 23 Jun 2025 17:14:06 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78865; Package emacs. (Mon, 23 Jun 2025 17:25:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Dani Moncayo <dmoncayo <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 78865 <at> debbugs.gnu.org
Subject: Re: bug#78865: 31.0.50; Inconsistency between show-paren-mode and
 some cursor-movement commands
Date: Mon, 23 Jun 2025 20:23:42 +0300
>   (setq-local parse-sexp-ignore-comments t)
>
> When you set it back to nil, then your test case works as you want.

Sorry, forgot to mention that you also need to add

  (sexp-default "comment")

to c-ts-mode--thing-settings.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 22 Jul 2025 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 5 days ago.

Previous Next


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