GNU bug report logs - #59693
29.0.50; treesitter in base buffer doesn't respond to modifications in indirect buffer correctly

Previous Next

Package: emacs;

Reported by: miha <at> kamnitnik.top

Date: Tue, 29 Nov 2022 20:21:01 UTC

Severity: normal

Found in version 29.0.50

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #26 received at 59693 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Yuan Fu <casouri <at> gmail.com>, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 59693 <at> debbugs.gnu.org, miha <at> kamnitnik.top
Subject: Re: bug#59693: 29.0.50; treesitter in base buffer doesn't respond to
 modifications in indirect buffer correctly
Date: Sun, 04 Dec 2022 09:46:13 +0200
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Sat, 3 Dec 2022 23:20:59 -0800
> Cc: miha <at> kamnitnik.top,
>  59693 <at> debbugs.gnu.org
> 
> >>> We don’t want indirect buffer and base buffers to share parsers, since they can have different narrowing, and semantically indirect buffers should share anything but the text with the base buffer.
> >> 
> >> Yes, the parsers should not be shared.
> >> 
> >>> How about this: we change current_buffer->parser_list from a plain list of parsers to a cons (PARSER-LIST . INDIRECT-PARSER-LIST), where PARSER-LIST is as before. But for base buffers, INDIRECT-PARSER-LIST includes all the parsers of its indirect buffers; and for indirect buffers, INDIRECT-PARSER-LIST is nil.
> >> 
> >> You can maybe have the indirect buffers in the list, not their parsers.
> >> That could make it easier to access other treesit-related information of the
> >> indirect buffers, if needed.
> > 
> > Good idea, it’s easier to know when to remove the reference with buffers, aka when buffer is killed.
> 
> I now have a patch that fixes this problem. WDYT? I added a new buffer field since it’s cleaner than turning ts_parser_list into a cons, hopefully that’s not frowned upon. 

Thanks.

If we are adding to the buffer object a field that holds the list of
indirect buffers, then:

  . the name of the field should not include "treesit" in it, and it
    shouldn't be conditioned on HAVE_TREE_SITTER
  . I wonder if a flat list is a good idea, i.e. scalable enough? also,
    treesit_reap_indirect_buffers conses a lot as result
  . I vaguely remember that adding built-in fields to the buffer object had
    some caveats, but I don't recall the details (did you bootstrap?)

Stefan, any comments on this?  Are there better ideas of how to track buffer
text changes in indirect buffers?




This bug report was last modified 2 years and 163 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.