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

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

bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp


From: Dmitry Gutov
Subject: bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp
Date: Thu, 19 Jan 2023 00:06:22 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

On 18/01/2023 20:27, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote:

On 18 January 2023 18:09:29 CET, Juri Linkov<juri@linkov.net>  wrote:
Consider HTML (or anything in SGML club of languages). I would expect
sexp movement to move over a matched pair of tags. It currently does
not; the reason why is understandable when you know how `syntax-ppss'
does (or does not, as it were) work. (You can equally make an argument
that it should simply go to the end of an opening/closing node and not
the pair, but that is personal preference.)

`nxml-mode' handles it properly; Combobulate handles it properly, too.
But Combobulate also falls back to the classic sexp behaviour if it
cannot find a suitable node in the direction of travel.
While ‘forward-sexp’ moves over the next tag, there is also ‘C-c C-f’
(‘sgml-skip-tag-forward’) that moves over the whole element to the end tag.
I'm not sure if sexp movement in nxml-mode is an improvement since
there is no way to move over the tag only.

To support both cases maybe ‘forward-sexp’ should move over the tag,
and ‘forward-sentence’ over the whole element?
Yes! This is what I find intuitive, and have tried to explain in my docstrings 
of the two.

But I'm new in town and want all to at least discuss:)

In my intuition, sexps are expressions which can be nested (a lot).

Sentences are "flat" expressions. I would probably say that in tree-sitter modes sentences should be equivalent to "statements".

So, sexps could be small, and they could be large. For them various list navigation operations make sense (like the previously mentioned ones).

Sentences stand somewhere in the middle, and they're more like sequential. A operation like backward-up-statement wouldn't make a lot of sense, however.

Note quite sure what would correspond to statement in html-mode, but I would put separate tag elements in the category of word, or symbols, or, okay, statements, rather than sexps. A sexp is the tag opener, plus tag contents, plus its closer.





reply via email to

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