bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#67262: python-ts-mode cannot identify triple-quoted-strings


From: Dmitry Gutov
Subject: bug#67262: python-ts-mode cannot identify triple-quoted-strings
Date: Sun, 17 Dec 2023 15:46:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 17/12/2023 01:36, Yuan Fu wrote:
How do you think of this patch? This extends the patch in bug#66732, and adds 
correct text property to the quotes (I think).

I do believe the common pattern should be followed here: a syntax-propertize-function and a call to syntax-ppss-flush-cache to invalidate when appropriate. See my patch in this bug for reference.

The reasons are performance (deferring work) and keeping state management logic in one place.

With your patch in particular, try this:

1. Type """foo -- no text properties.
2. Add """. Check the 3rd and 4th quote characters with 'C-u C-x ='. Both should have the (15) 'syntax-table' text property applied. 4. Backspace. Syntax highlighting changes -- the string is not highlighted now (that's good, I guess). But both 3rd and 4th quote chars retain the text property. (python-info-triple-quoted-string-p) still returns the same value, and, more importantly, (syntax-ppss) does too. 5. Backspace 2 more times (the text in the buffer is now '"""foo'). The 4th quote is gone now, but the 3rd still has the text property.

(nth 3 (syntax-ppss)) still returns t, and (python-info-triple-quoted-string-p) still returns the same value.

On steps 1 and 5 the buffer contents are the same, but the syntax-table properties are different.

It doesn’t handle the case of “””””” (no content inside the quotes), but I 
think that’s fine?

It might be important for some callers of (python-info-triple-quoted-string-p). But it should be pretty easy to fix, now or later.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]