unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Yuan Fu <casouri@gmail.com>
Cc: 59693@debbugs.gnu.org, monnier@iro.umontreal.ca, miha@kamnitnik.top
Subject: bug#59693: 29.0.50; treesitter in base buffer doesn't respond to modifications in indirect buffer correctly
Date: Thu, 08 Dec 2022 08:47:13 +0200	[thread overview]
Message-ID: <83zgby2xzi.fsf@gnu.org> (raw)
In-Reply-To: <77899171-04F5-4BB2-BE26-4C999DAB0CA0@gmail.com> (message from Yuan Fu on Wed, 7 Dec 2022 15:13:19 -0800)

> From: Yuan Fu <casouri@gmail.com>
> Date: Wed, 7 Dec 2022 15:13:19 -0800
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
>  59693@debbugs.gnu.org,
>  miha@kamnitnik.top
> 
> >> 1. Only allow base buffer to have parsers, no change is needed for insdel.c, treesit_record_change can find the base buffer and update its parsers. We can ask indirect buffers to use their base buffer’s parser. Unless the base buffer is narrowed, I think it will work fine. 
> > 
> > I think this is fine, but we need to document it.
> > 
> >> I remember that there were a discussion along the lines of user-narrow vs low-level narrow, what was the outcome of that discussion?
> > 
> > Nothing in particular, and I don't think it's relevant.  If some mode needs
> > to widen, it can.
> > 
> > Thanks.
> 
> Here is a patch that does #1.

Thanks, a few minor comments for documentation below.

> +If @var{buffer} (or the current buffer) is an indirect buffer, its
> +base buffer is used instead.  That is, indirect buffers uses their
                                          ^^^^^^^^^^^^^^^^^^^^^
"use", in plural.

> @@ -447,7 +455,9 @@ Using Parser
>  @defun treesit-parser-list &optional buffer
>  This function returns the parser list of @var{buffer}.  If
>  @var{buffer} is @code{nil} or omitted, it defaults to the current
> -buffer.
> +buffer.  If @var{buffer} (or the current buffer) is an indirect
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I'd say more concisely

  If that buffer is an indirect buffer, ...

And please add a cross-reference to the node where indirect buffers
are described.

> +buffer, its base buffer is used instead.  That is, indirect buffers
> +uses their base buffer's parsers.
   ^^^^
"use".

> +   Parsers in indirect buffers: We make indirect buffers to share the
> +   parser of its base buffer.  See bug#59693 for reasoning.  */

I'd rather have a short summary of the reasoning here than ask the
readers to go to the bug tracker and read a long discussion.  Just
explain why indirect buffers present a problem for a parser, and then
say that we decided to do this as the easiest, simplest solution.

> +If BUFFER (or the current buffer) is an indirect buffer, its base
> +buffer is used instead.  That is, indirect buffers uses their base
                                                      ^^^^
"use"

> +buffer's parsers.  If the base buffer is narrowed, an indirect buffer
> +might not be able to retrieve information of the portion of the buffer
> +text that are invisible in the base buffer.  Lisp programs should
> +widen as necessary should they want to use a parser in an indirect
> +buffer.  */)

Here I would remove the second sentence: it is appropriate for the
manual, but is redundant in the doc string, since the next sentence
says it all.

> @@ -1329,7 +1345,10 @@ DEFUN ("treesit-parser-list",
>         Ftreesit_parser_list, Streesit_parser_list,
>         0, 1, 0,
>         doc: /* Return BUFFER's parser list.
> -BUFFER defaults to the current buffer.  */)
> +
> +BUFFER defaults to the current buffer.  If BUFFER (or the current
> +buffer) is an indirect buffer, its base buffer is used instead.  That
> +is, indirect buffers uses their base buffer's parsers.  */)
                        ^^^^
"use"

Otherwise, LGTM.





  reply	other threads:[~2022-12-08  6:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29 20:21 bug#59693: 29.0.50; treesitter in base buffer doesn't respond to modifications in indirect buffer correctly miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-30 10:17 ` Yuan Fu
2022-11-30 14:05   ` Eli Zaretskii
2022-12-02  5:05     ` Yuan Fu
2022-12-02  8:33       ` Eli Zaretskii
2022-12-03  1:01         ` Yuan Fu
2022-12-04  7:20           ` Yuan Fu
2022-12-04  7:46             ` Eli Zaretskii
2022-12-04 23:21               ` Yuan Fu
2022-12-05  3:49       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05  8:19         ` Eli Zaretskii
2022-12-05 15:29           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05 15:44             ` Eli Zaretskii
2022-12-05 20:14               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-06  2:15               ` Yuan Fu
2022-12-06  3:57                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-06 12:17                 ` Eli Zaretskii
2022-12-07 23:13                   ` Yuan Fu
2022-12-08  6:47                     ` Eli Zaretskii [this message]
2022-12-10  1:41 ` 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=83zgby2xzi.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=59693@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=miha@kamnitnik.top \
    --cc=monnier@iro.umontreal.ca \
    /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).