[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp
From: |
Theodor Thornhill |
Subject: |
bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp |
Date: |
Tue, 17 Jan 2023 21:44:35 +0100 |
Hi Emacs (also Juri and Mickey as you've expressed some interest for this)
This is an example patch for sexp movement with tree sitter. I want to
put it out here to hopefully produce some discussion, sooner rather than
later.
Three initial questions:
1. What should a sexp be?
Is it basically "everything", or is there a distincition between
"word", "sexp" and "sentence"? For lisp forward-sexp looks like a
"jump over words, or a balanced pair of parens". In other languages
that can look a little weird - consider:
```
foo().|bar().baz(); -> foo().bar|().baz(); -> foo().bar()|.baz();
```
In a sense it could be considered "better", or at least distinct from
forward-word to:
```
foo().|bar().baz(); -> foo().bar()|.baz(); -> foo().bar().baz()|;
```
2. Should this new function be leveraged in transpose-sexps?
IMO if the forward-sexp gets too close to forward-word, or
forward-sentence we lose some nice properties with the current
'treesit-transpose-sexps', namely (among others):
```
f(String foo,| Integer bar) -> void foo(Integer bar, String foo|)
```
I know you Mickey have expressed some dissatisfaction with the current
implementation - now is a good time to make some worthwhile
improvements.
3. What are the "rules"?
In c-mode, elisp-mode without paredit forward-sexp won't jump out of
the current scope, however with paredit enabled it will.
If we simply want some code similar to this to live and slowly evolve I
guess we can install something like this patch after some tweaks and
iterate when we have more experience.
Anyway, I hope these questions and thoughs will spark some discussion,
Theo
0001-Add-treesit-forward-sexp.patch
Description: Text Data
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp,
Theodor Thornhill <=
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp, Dmitry Gutov, 2023/01/17
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp, Theodor Thornhill, 2023/01/17
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp, Dmitry Gutov, 2023/01/17
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp, Theodor Thornhill, 2023/01/18
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp, Eli Zaretskii, 2023/01/18
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp, Dmitry Gutov, 2023/01/18
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp, Theodor Thornhill, 2023/01/18
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp, Stefan Monnier, 2023/01/18
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp, Dmitry Gutov, 2023/01/18
- bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp, Stefan Monnier, 2023/01/18