all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: Yuan Fu <casouri@gmail.com>, JD Smith <jdtsmith@gmail.com>,
	Eli Zaretskii <eliz@gnu.org>
Cc: 67262@debbugs.gnu.org
Subject: bug#67262: python-ts-mode cannot identify triple-quoted-strings
Date: Tue, 12 Dec 2023 23:55:43 +0200	[thread overview]
Message-ID: <a3a0547c-6697-feef-53fd-6395bbeedaeb@gutov.dev> (raw)
In-Reply-To: <bb5f649d-4c7a-4fbd-a593-1ae9f872756b@gmail.com>

On 12/12/2023 10:32, Yuan Fu wrote:

>> syntax-ppss-flush-cache is called by edits (and by the re-parse). It 
>> seems like it will be odd to have execution the other way around 
>> and/or add some hook into it which would call the re-parse and extend 
>> the region to be invalidated.
>>
>> syntax-propertize could have another hook added, yes. Or an advice.
>>
>> But it seems better to reuse some of the existing hooks, such as 
>> syntax-propertize-extend-region-functions. It treesit.c provided a way 
>> to fetch the newly-invalidated region, the treesit-major-mode-setup 
>> could add a new function to syntax-propertize-extend-region-functions 
>> which would invoke that feature. But even now it can instantiate the 
>> parse, which would call treesit-force-reparse internally, and then 
>> collect the info from the callbacks.
> syntax-propertize-extend-region-functions looks perfect. We just need to 
> force a reparse in it and the notifier will do the rest.
>>
>> And yet another way - is to extend the region to be propertized from 
>> inside the major mode's syntax-propertize-function, invalidating some 
>> earlier entries too. The main problem with that, I think, is that 
>> every ts mode will have to repeat that trick. And that authors would 
>> have to know to do that. How to make that easier and more obvious, is 
>> a question.
>>
>> Finally, if I'm right that bug#66732 has a similar cause, then a 
>> shared solution that can be reused by syntax and font-lock (or 
>> preferably just fix both in the same place) would be ideal.
>>
>>> I'm not quite sure about how do we cause this re-parse. The 
>>> straightforward approach would be calling treesit-force-reparse[1] in 
>>> syntax-propertize/syntax-ppss-flush-cache. But ideally I'd like to 
>>> keep tree-sitter transparent for syntax.el. Maybe we can add a hook 
>>> in syntax-propertize/syntax-ppss-flush-cache.
>>>
>>> [1] This function doesn't exist yet, but it's easy to define in lisp.
>>
>> treesit-parser-root-node calls it anyway and does little else, so we 
>> could get by with just using it.
>>
> Yep.

For the casual observer: I posted a solution using the above method in 
comments to bug#66732 yesterday.





  reply	other threads:[~2023-12-12 21:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-18 15:52 bug#67262: python-ts-mode cannot identify triple-quoted-strings JD Smith
2023-11-18 16:29 ` Eli Zaretskii
2023-11-18 17:18   ` JD Smith
2023-11-18 22:52     ` Dmitry Gutov
2023-11-25 10:01       ` Eli Zaretskii
2023-11-25 14:42         ` JD Smith
2023-11-26  2:04           ` Dmitry Gutov
2023-11-26 14:58             ` Dmitry Gutov
2023-11-26 23:43               ` Yuan Fu
2023-11-27  0:05                 ` Dmitry Gutov
2023-12-12  8:32                   ` Yuan Fu
2023-12-12 21:55                     ` Dmitry Gutov [this message]
2023-12-16 12:47                       ` Eli Zaretskii
2023-12-16 13:37                         ` Dmitry Gutov
2023-12-16 13:59                           ` Eli Zaretskii
2023-12-16 15:11                             ` JD Smith
2023-12-16 15:21                             ` Dmitry Gutov
2023-12-16 15:57                               ` Eli Zaretskii
2023-12-16 23:36                           ` Yuan Fu
2023-12-17 13:46                             ` Dmitry Gutov
2023-12-23  9:52                               ` Eli Zaretskii
2023-12-23 18:03                                 ` Yuan Fu
2023-12-23 21:01                                   ` Dmitry Gutov
2023-12-23 23:51                                     ` Yuan Fu
2023-12-24  0:45                                       ` Dmitry Gutov
2023-12-24  3:10                                         ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a3a0547c-6697-feef-53fd-6395bbeedaeb@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=67262@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=jdtsmith@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.