From: Dmitry Gutov <dmitry@gutov.dev>
To: Yuan Fu <casouri@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, dvzubarev@yandex.ru, 67977@debbugs.gnu.org
Subject: bug#67977: 30.0.50; tree-sitter: Emacs crashes when accessing treesit-nodes in a narrowed buffer
Date: Fri, 29 Dec 2023 14:48:32 +0200 [thread overview]
Message-ID: <52f3f5c0-fc5a-46fa-949f-33437fd8878a@gutov.dev> (raw)
In-Reply-To: <E0DA9858-2C41-436D-9FFE-37B5FF10CA1A@gmail.com>
On 29/12/2023 09:00, Yuan Fu wrote:
>
>
>> On Dec 28, 2023, at 8:16 AM, Dmitry Gutov <dmitry@gutov.dev> wrote:
>>
>> On 28/12/2023 15:53, Eli Zaretskii wrote:
>>>> Date: Thu, 28 Dec 2023 13:44:43 +0200
>>>> Cc: Denis Zubarev<dvzubarev@yandex.ru>,67977@debbugs.gnu.org
>>>> From: Dmitry Gutov<dmitry@gutov.dev>
>>>>
>>>>>> Could font-lock-dont-widen help, perhaps?
>>>>> Yes. If font-lock doesn’t widen, then there wouldn’t be back-and-forth reparses.
>>>> But then treesit major modes will be affected by user narrowing (e.g. if
>>>> the user narrowed to inside the string, the buffer won't be highlighted
>>>> as a string).
>>> Why is that a problem? When the user narrows the buffer, the part
>>> outside the narrowing doesn't exist as far as Emacs is concerned.
>>
>> That's not how it works in most major modes, at least since the introduction of font-lock-dont-widen 20 years ago.
>>
>> Like its docstring says, the exceptions were supposed to be weird modes like RMAIL and Info which use narrowing for their own purposes (that seems buggy in Info's case, when 'C-x n w' breaks the intended display right away). But even Info-mode doesn't actually change font-lock-dont-widen, actually, because the apparent behavior would be the same. But it could.
>>
>> I don't have a personal stake in this (I never use narrowing interactively). But maybe you'll want to make a poll, to ask the users that do.
>
> I guess that depends on how you view narrowing, I assume most of the time the user considers narrowing to be something that narrows the view to a region, rather than effectively removing the rest of the buffer. IIRC We’ve had discussions on adding “types” to narrows but to no conclusion.
Indeed.
> Anyway, if the reparse caused by narrowing prove to be problematic, I can implement the optimization I mentioned earlier, where we use two parsers, one for when buffer is widened and one for when buffer is narrowed. This will be in C and is transparent to lisp.
This definitely can work, but perhaps we should examine concrete use
cases first. It could be that the caller would want the full parse tree
available anyway, when the view was narrowed interactively by the user.
Then the actual advice from us would be to (save-restriction (widen
...)) anyway, and the second parse tree would stay mostly unused.
It's a good thing to have fixed the crash, though, so the developers can
try it both ways and decide what's best for them.
next prev parent reply other threads:[~2023-12-29 12:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-22 23:18 bug#67977: 30.0.50; tree-sitter: Emacs crashes when accessing treesit-nodes in a narrowed buffer Denis Zubarev
2023-12-23 7:26 ` Eli Zaretskii
2023-12-23 8:08 ` Yuan Fu
2023-12-24 3:00 ` Yuan Fu
2023-12-24 7:11 ` Eli Zaretskii
2023-12-27 4:15 ` Yuan Fu
2023-12-27 12:57 ` Eli Zaretskii
2023-12-28 8:07 ` Yuan Fu
2023-12-28 11:44 ` Dmitry Gutov
2023-12-28 13:53 ` Eli Zaretskii
2023-12-28 16:16 ` Dmitry Gutov
2023-12-29 7:00 ` Yuan Fu
2023-12-29 12:48 ` Dmitry Gutov [this message]
2023-12-30 4:35 ` Yuan Fu
2023-12-30 16:21 ` Denis Zubarev
2023-12-30 20:23 ` Yuan Fu
2023-12-31 0:08 ` Dmitry Gutov
2023-12-31 10:39 ` Denis Zubarev
2023-12-31 12:56 ` Eli Zaretskii
2023-12-31 13:40 ` Dmitry Gutov
2024-01-02 4:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-02 13:34 ` Dmitry Gutov
2024-01-02 22:58 ` Yuan Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52f3f5c0-fc5a-46fa-949f-33437fd8878a@gutov.dev \
--to=dmitry@gutov.dev \
--cc=67977@debbugs.gnu.org \
--cc=casouri@gmail.com \
--cc=dvzubarev@yandex.ru \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).