bug#81587: c-ts-mode narrowing disturbs the indirect buffer

Tomas Nordin <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
Hello

Using c-ts-mode, cloning the buffer, narrowing the direct buffer, doing
some navigation in the indirect buffer, seem problematic. Like this for
example:

$ emacs -Q lib-src/asset-directory-tool.c

M-x c-ts-mode
C-s main_1 RET
C-x 4 c
C-x o
C-x n d
C-x o

We should now be in the indirect buffer after having narrowed the
main_1() function in the direct buffer.

Do some C-M-e and C-M-a and shortly observe

Error running timer ‘show-paren-function’: (args-out-of-range 3271)

If I skip the 'M-x c-ts-mode' step the problem is not reproduced.

I have a small edit in my local build, the following diff:

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 5f064716a89..fa09cb21b34 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -503,7 +503,8 @@ c-ts-mode--simple-indent-rules
                                 "enum_specifier"
                                 "union_specifier"
                                 "function_declarator"
-                                "template_declaration")))
+                                "template_declaration"
+                                "concatenated_string")))
             standalone-parent 0)
            ;; This is for the trailing-star stype:  int *
            ;;                                       func()

But I was thinking it should not be related.

In GNU Emacs 31.0.91 (build 2, x86_64-pc-linux-gnu, GTK+ Version
 3.24.49, cairo version 1.18.4) of 2026-08-03 built on fliptop2
Repository revision: afda8c2779b297ada39379a38e0056cb2b21b1fb
Repository branch: emacs-31-local
Windowing system distributor 'The X.Org Foundation', version 11.0.12101016
System Description: Debian GNU/Linux 13 (trixie)

Configured using:
 'configure LDFLAGS=-L/usr/local/lib'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINERAMA XINPUT2 XPM
XRANDR GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: sv_SE.UTF-8
  value of $LC_NUMERIC: sv_SE.UTF-8
  value of $LC_TIME: sv_SE.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Messages

Minor modes in effect:
  tooltip-mode: t
  global-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-nonselected-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: 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

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
rfc6068 epg-config gnus-util text-property-search time-date subr-x
mule-util mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader
sendmail mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils misearch multi-isearch cl-seq c++-ts-mode
c-ts-mode c-ts-common treesit comp-run comp-common rx byte-opt gv
bytecomp byte-compile vc-git diff-mode track-changes easy-mmode files-x
vc vc-dispatcher bug-reference thingatpt cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo gtk
x-toolkit xinput2 x multi-tty move-toolbar make-network-process
tty-child-frames native-compile emacs)

Memory information:
((conses 16 106727 11496) (symbols 48 9800 0) (strings 32 26864 3051)
 (string-bytes 1 969582) (vectors 16 15188)
 (vector-slots 8 206803 7143) (floats 8 33 2) (intervals 56 995 0)
 (buffers 1064 12))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.