* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
@ 2024-10-24 4:06 Yuan Fu
2024-11-09 9:11 ` Eli Zaretskii
0 siblings, 1 reply; 13+ messages in thread
From: Yuan Fu @ 2024-10-24 4:06 UTC (permalink / raw)
To: 73978; +Cc: theo
X-Debbugs-CC: theo@thornhill.no
In tsx-ts-mode we use this query to apply syntax properties:
(defvar tsx-ts--s-p-query
(when (treesit-available-p)
(treesit-query-compile 'tsx
'(((regex pattern: (regex_pattern) @regexp))
((variable_declarator value: (jsx_element) @jsx))
((assignment_expression right: (jsx_element) @jsx))
((arguments (jsx_element) @jsx))
((parenthesized_expression (jsx_element) @jsx))
((return_statement (jsx_element) @jsx))))))
And then in tsx-ts--syntax-propertize-captures we mark everything
enclosed by the captured jsx_element nodes in text fences.
Then for the following code
<button onClick={() => {
func();
return true;
}}>
Text
{func();}
</button>
All the func() and other code will be considered text because the whole
jsx tag (<button>...</button>) are wrapped in string fences. Theo,
what’s the original intention for marking jsx_elements as text? Can we
only mark jsx_text as string?
Yuan
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-10-24 4:06 bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode Yuan Fu
@ 2024-11-09 9:11 ` Eli Zaretskii
2024-11-09 16:49 ` Yuan Fu
0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2024-11-09 9:11 UTC (permalink / raw)
To: Yuan Fu, theo; +Cc: 73978
Ping! Theo, can you answer Yuan's questions?
> Cc: theo@thornhill.no
> From: Yuan Fu <casouri@gmail.com>
> Date: Wed, 23 Oct 2024 21:06:40 -0700
>
> X-Debbugs-CC: theo@thornhill.no
>
> In tsx-ts-mode we use this query to apply syntax properties:
>
>
> (defvar tsx-ts--s-p-query
> (when (treesit-available-p)
> (treesit-query-compile 'tsx
> '(((regex pattern: (regex_pattern) @regexp))
> ((variable_declarator value: (jsx_element) @jsx))
> ((assignment_expression right: (jsx_element) @jsx))
> ((arguments (jsx_element) @jsx))
> ((parenthesized_expression (jsx_element) @jsx))
> ((return_statement (jsx_element) @jsx))))))
>
>
> And then in tsx-ts--syntax-propertize-captures we mark everything
> enclosed by the captured jsx_element nodes in text fences.
>
> Then for the following code
>
> <button onClick={() => {
> func();
> return true;
> }}>
> Text
> {func();}
> </button>
>
> All the func() and other code will be considered text because the whole
> jsx tag (<button>...</button>) are wrapped in string fences. Theo,
> what’s the original intention for marking jsx_elements as text? Can we
> only mark jsx_text as string?
>
> Yuan
>
>
>
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-11-09 9:11 ` Eli Zaretskii
@ 2024-11-09 16:49 ` Yuan Fu
2024-11-23 12:15 ` Eli Zaretskii
0 siblings, 1 reply; 13+ messages in thread
From: Yuan Fu @ 2024-11-09 16:49 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Theodor Thornhill, 73978
> On Nov 9, 2024, at 1:11 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
> Ping! Theo, can you answer Yuan's questions?
I’ve been using my local fix at work for a while now and it seems to work fine. I’ll make a patch and apply in a few days.
Yuan
>
>> Cc: theo@thornhill.no
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Wed, 23 Oct 2024 21:06:40 -0700
>>
>> X-Debbugs-CC: theo@thornhill.no
>>
>> In tsx-ts-mode we use this query to apply syntax properties:
>>
>>
>> (defvar tsx-ts--s-p-query
>> (when (treesit-available-p)
>> (treesit-query-compile 'tsx
>> '(((regex pattern: (regex_pattern) @regexp))
>> ((variable_declarator value: (jsx_element) @jsx))
>> ((assignment_expression right: (jsx_element) @jsx))
>> ((arguments (jsx_element) @jsx))
>> ((parenthesized_expression (jsx_element) @jsx))
>> ((return_statement (jsx_element) @jsx))))))
>>
>>
>> And then in tsx-ts--syntax-propertize-captures we mark everything
>> enclosed by the captured jsx_element nodes in text fences.
>>
>> Then for the following code
>>
>> <button onClick={() => {
>> func();
>> return true;
>> }}>
>> Text
>> {func();}
>> </button>
>>
>> All the func() and other code will be considered text because the whole
>> jsx tag (<button>...</button>) are wrapped in string fences. Theo,
>> what’s the original intention for marking jsx_elements as text? Can we
>> only mark jsx_text as string?
>>
>> Yuan
>>
>>
>>
>>
>>
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-11-09 16:49 ` Yuan Fu
@ 2024-11-23 12:15 ` Eli Zaretskii
2024-11-24 5:25 ` Yuan Fu
0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2024-11-23 12:15 UTC (permalink / raw)
To: Yuan Fu; +Cc: theo, 73978
> From: Yuan Fu <casouri@gmail.com>
> Date: Sat, 9 Nov 2024 08:49:55 -0800
> Cc: Theodor Thornhill <theo@thornhill.no>,
> 73978@debbugs.gnu.org
>
>
>
> > On Nov 9, 2024, at 1:11 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> >
> > Ping! Theo, can you answer Yuan's questions?
>
> I’ve been using my local fix at work for a while now and it seems to work fine. I’ll make a patch and apply in a few days.
Did you have an opportunity to install such a patch?
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-11-23 12:15 ` Eli Zaretskii
@ 2024-11-24 5:25 ` Yuan Fu
2024-11-24 7:47 ` Eli Zaretskii
0 siblings, 1 reply; 13+ messages in thread
From: Yuan Fu @ 2024-11-24 5:25 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Theodor Thornhill, 73978
> On Nov 23, 2024, at 4:15 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Sat, 9 Nov 2024 08:49:55 -0800
>> Cc: Theodor Thornhill <theo@thornhill.no>,
>> 73978@debbugs.gnu.org
>>
>>
>>
>>> On Nov 9, 2024, at 1:11 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>>>
>>> Ping! Theo, can you answer Yuan's questions?
>>
>> I’ve been using my local fix at work for a while now and it seems to work fine. I’ll make a patch and apply in a few days.
>
> Did you have an opportunity to install such a patch?
Hey sorry, I haven’t applied the patch. Actually, I want to ask you a question before I do: is there a way to mark a single character in buffer in string syntax? The only way I’m aware of is to mark string delimiter syntax to the start and end of the string, but that doesn’t work for a single character.
Take the following snippet as an example:
<button>a<button>
I want to apply string syntax to “a”.
If there’s no such way, I guess just not applying the string syntax in such case is also an option.
Yuan
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-11-24 5:25 ` Yuan Fu
@ 2024-11-24 7:47 ` Eli Zaretskii
2024-11-24 13:45 ` Dmitry Gutov
0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2024-11-24 7:47 UTC (permalink / raw)
To: Yuan Fu; +Cc: theo, 73978
> From: Yuan Fu <casouri@gmail.com>
> Date: Sat, 23 Nov 2024 21:25:50 -0800
> Cc: Theodor Thornhill <theo@thornhill.no>,
> 73978@debbugs.gnu.org
>
> >> I’ve been using my local fix at work for a while now and it seems to work fine. I’ll make a patch and apply in a few days.
> >
> > Did you have an opportunity to install such a patch?
>
> Hey sorry, I haven’t applied the patch. Actually, I want to ask you a question before I do: is there a way to mark a single character in buffer in string syntax? The only way I’m aware of is to mark string delimiter syntax to the start and end of the string, but that doesn’t work for a single character.
>
> Take the following snippet as an example:
>
> <button>a<button>
>
> I want to apply string syntax to “a”.
>
> If there’s no such way, I guess just not applying the string syntax in such case is also an option.
There's a syntax-table text property, see the node "Syntax Properties"
in the ELisp manual. Would that do the job?
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-11-24 7:47 ` Eli Zaretskii
@ 2024-11-24 13:45 ` Dmitry Gutov
2024-11-25 1:27 ` Yuan Fu
0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Gutov @ 2024-11-24 13:45 UTC (permalink / raw)
To: Eli Zaretskii, Yuan Fu; +Cc: theo, 73978
On 24/11/2024 09:47, Eli Zaretskii wrote:
>> Hey sorry, I haven’t applied the patch. Actually, I want to ask you a question before I do: is there a way to mark a single character in buffer in string syntax? The only way I’m aware of is to mark string delimiter syntax to the start and end of the string, but that doesn’t work for a single character.
>>
>> Take the following snippet as an example:
>>
>> <button>a<button>
>>
>> I want to apply string syntax to “a”.
>>
>> If there’s no such way, I guess just not applying the string syntax in such case is also an option.
> There's a syntax-table text property, see the node "Syntax Properties"
> in the ELisp manual. Would that do the job?
In particular, the "generic string" syntax property, this one
(string-to-syntax "|")
You put it on the first and the last chars of a "generic string".
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-11-24 13:45 ` Dmitry Gutov
@ 2024-11-25 1:27 ` Yuan Fu
2024-12-11 4:52 ` Yuan Fu
0 siblings, 1 reply; 13+ messages in thread
From: Yuan Fu @ 2024-11-25 1:27 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: Eli Zaretskii, Theodor Thornhill, 73978
> On Nov 24, 2024, at 5:45 AM, Dmitry Gutov <dmitry@gutov.dev> wrote:
>
> On 24/11/2024 09:47, Eli Zaretskii wrote:
>>> Hey sorry, I haven’t applied the patch. Actually, I want to ask you a question before I do: is there a way to mark a single character in buffer in string syntax? The only way I’m aware of is to mark string delimiter syntax to the start and end of the string, but that doesn’t work for a single character.
>>>
>>> Take the following snippet as an example:
>>>
>>> <button>a<button>
>>>
>>> I want to apply string syntax to “a”.
>>>
>>> If there’s no such way, I guess just not applying the string syntax in such case is also an option.
>> There's a syntax-table text property, see the node "Syntax Properties"
>> in the ELisp manual. Would that do the job?
>
> In particular, the "generic string" syntax property, this one
>
> (string-to-syntax "|")
>
> You put it on the first and the last chars of a "generic string”.
The problem is, that doesn’t work when there’s only one character. Take the snippet as an example:
<button>a</button>
You can’t put the string fence syntax on the “a”, because there isn’t a closing fence to close it.
Yuan
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-11-25 1:27 ` Yuan Fu
@ 2024-12-11 4:52 ` Yuan Fu
2024-12-12 2:52 ` Dmitry Gutov
0 siblings, 1 reply; 13+ messages in thread
From: Yuan Fu @ 2024-12-11 4:52 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: Eli Zaretskii, Theodor Thornhill, 73978
> On Nov 24, 2024, at 5:27 PM, Yuan Fu <casouri@gmail.com> wrote:
>
>
>
>> On Nov 24, 2024, at 5:45 AM, Dmitry Gutov <dmitry@gutov.dev> wrote:
>>
>> On 24/11/2024 09:47, Eli Zaretskii wrote:
>>>> Hey sorry, I haven’t applied the patch. Actually, I want to ask you a question before I do: is there a way to mark a single character in buffer in string syntax? The only way I’m aware of is to mark string delimiter syntax to the start and end of the string, but that doesn’t work for a single character.
>>>>
>>>> Take the following snippet as an example:
>>>>
>>>> <button>a<button>
>>>>
>>>> I want to apply string syntax to “a”.
>>>>
>>>> If there’s no such way, I guess just not applying the string syntax in such case is also an option.
>>> There's a syntax-table text property, see the node "Syntax Properties"
>>> in the ELisp manual. Would that do the job?
>>
>> In particular, the "generic string" syntax property, this one
>>
>> (string-to-syntax "|")
>>
>> You put it on the first and the last chars of a "generic string”.
>
> The problem is, that doesn’t work when there’s only one character. Take the snippet as an example:
>
> <button>a</button>
>
> You can’t put the string fence syntax on the “a”, because there isn’t a closing fence to close it.
>
> Yuan
Circling back on this. I don’t think there’s a way to apply string syntax to a single character.
Yuan
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-12-11 4:52 ` Yuan Fu
@ 2024-12-12 2:52 ` Dmitry Gutov
2024-12-12 4:56 ` Yuan Fu
0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Gutov @ 2024-12-12 2:52 UTC (permalink / raw)
To: Yuan Fu; +Cc: Eli Zaretskii, Theodor Thornhill, 73978
On 11/12/2024 06:52, Yuan Fu wrote:
>> The problem is, that doesn’t work when there’s only one character. Take the snippet as an example:
>>
>> <button>a</button>
>>
>> You can’t put the string fence syntax on the “a”, because there isn’t a closing fence to close it.
>>
>> Yuan
> Circling back on this. I don’t think there’s a way to apply string syntax to a single character.
Indeed, sorry.
There needs to be a separate char as a "closing fence" like you say
because it's treated as a part of the string. So it's 2 chars minimum.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-12-12 2:52 ` Dmitry Gutov
@ 2024-12-12 4:56 ` Yuan Fu
2024-12-12 17:19 ` Dmitry Gutov
0 siblings, 1 reply; 13+ messages in thread
From: Yuan Fu @ 2024-12-12 4:56 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: Eli Zaretskii, Theodor Thornhill, 73978
> On Dec 11, 2024, at 6:52 PM, Dmitry Gutov <dmitry@gutov.dev> wrote:
>
> On 11/12/2024 06:52, Yuan Fu wrote:
>>> The problem is, that doesn’t work when there’s only one character. Take the snippet as an example:
>>>
>>> <button>a</button>
>>>
>>> You can’t put the string fence syntax on the “a”, because there isn’t a closing fence to close it.
>>>
>>> Yuan
>> Circling back on this. I don’t think there’s a way to apply string syntax to a single character.
>
> Indeed, sorry.
>
> There needs to be a separate char as a "closing fence" like you say because it's treated as a part of the string. So it's 2 chars minimum.
How hard is it to add a new syntax for this case? Or is there some way to work around this? We can’t just not apply the string syntax, because if the “a” is a parenthesis, etc, it would mess up the parenthesis balancing after it.
Maybe just give it a whitespace syntax?
Yuan
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-12-12 4:56 ` Yuan Fu
@ 2024-12-12 17:19 ` Dmitry Gutov
2024-12-13 5:47 ` Yuan Fu
0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Gutov @ 2024-12-12 17:19 UTC (permalink / raw)
To: Yuan Fu; +Cc: Eli Zaretskii, Theodor Thornhill, 73978
On 12/12/2024 06:56, Yuan Fu wrote:
> How hard is it to add a new syntax for this case? Or is there some way to work around this? We can’t just not apply the string syntax, because if the “a” is a parenthesis, etc, it would mess up the parenthesis balancing after it.
Probably not very hard, but that seems like it'd affect the total set of
syntax classes - which means adding it to the manual, etc.
> Maybe just give it a whitespace syntax?
Right, in such cases I applied the "whitespace" or "punctuation" syntax
to the whole character span, like in
https://github.com/dgutov/mmm-mode/blob/master/mmm-erb.el#L97
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode
2024-12-12 17:19 ` Dmitry Gutov
@ 2024-12-13 5:47 ` Yuan Fu
0 siblings, 0 replies; 13+ messages in thread
From: Yuan Fu @ 2024-12-13 5:47 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: Eli Zaretskii, Theodor Thornhill, 73978-done
> On Dec 12, 2024, at 9:19 AM, Dmitry Gutov <dmitry@gutov.dev> wrote:
>
> On 12/12/2024 06:56, Yuan Fu wrote:
>> How hard is it to add a new syntax for this case? Or is there some way to work around this? We can’t just not apply the string syntax, because if the “a” is a parenthesis, etc, it would mess up the parenthesis balancing after it.
>
> Probably not very hard, but that seems like it'd affect the total set of syntax classes - which means adding it to the manual, etc.
>
>> Maybe just give it a whitespace syntax?
>
> Right, in such cases I applied the "whitespace" or "punctuation" syntax to the whole character span, like in https://github.com/dgutov/mmm-mode/blob/master/mmm-erb.el#L97
Thanks. I went with the whitespace trick and pushed my patch to master.
Yuan
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2024-12-13 5:47 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-24 4:06 bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode Yuan Fu
2024-11-09 9:11 ` Eli Zaretskii
2024-11-09 16:49 ` Yuan Fu
2024-11-23 12:15 ` Eli Zaretskii
2024-11-24 5:25 ` Yuan Fu
2024-11-24 7:47 ` Eli Zaretskii
2024-11-24 13:45 ` Dmitry Gutov
2024-11-25 1:27 ` Yuan Fu
2024-12-11 4:52 ` Yuan Fu
2024-12-12 2:52 ` Dmitry Gutov
2024-12-12 4:56 ` Yuan Fu
2024-12-12 17:19 ` Dmitry Gutov
2024-12-13 5:47 ` Yuan Fu
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.