Subject: bug#78865: 31.0.50; Inconsistency between show-paren-mode and some cursor-movement commands

From: Stephen Berman <[email-masked]>
Date: Mon, 23 Jun 2025 00:07:24 +0200

On Sun, 22 Jun 2025 20:53:39 +0200 Dani Moncayo <[email-masked]> 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