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

From: Dani Moncayo <[email-masked]>
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