bug#81587: c-ts-mode narrowing disturbs the indirect buffer
Yuan Fu <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
> On Aug 9, 2026, at 3:24 AM, Eli Zaretskii <[email protected]> wrote: > >> From: Tomas Nordin <[email protected]> >> Date: Sun, 09 Aug 2026 10:08:13 +0000 >> >> 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. > > The doc string of treesit-parser-create says: > > If that buffer is an indirect buffer, its base buffer is used instead. > That is, indirect buffers use their base buffer's parsers. Lisp > programs should widen as necessary should they want to use a parser in > an indirect buffer. > > Yuan, any comments or suggestions? Hmm I didn’t manage to reproduce it. I’ll try again later, on top of my mind I don’t have a guess to why this happens. And I should fix the docstring: even though the indirect buffer still uses the base parser’s parser list, indirect buffer uses their own parsers now. (See e4cd26defc0e1a6deafbe4b2310ebdb3ffa4578f) Yuan