[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#68899: Treesitter's forward-sexp-function
From: |
João Távora |
Subject: |
bug#68899: Treesitter's forward-sexp-function |
Date: |
Fri, 2 Feb 2024 21:47:33 +0000 |
Hello Yuan,
In c++-mode, python-mode, and all other modes I know, pressing
C-M-f with point anywhere in the characters of a symbol brings
you to the end of that symbol.
In c++-ts-mode it only does something if you're in the beginning
of the symbol. Everywhere else point stays where it is. I know
there are some intended differences for c++-ts-mode's
forward-sexp-function vs c++-mode's, but would this be one
such difference?
Here's a quick repro, in case you don't follow
emacs -Q /tmp/something.cpp -f c++-ts-mode
int main() {}
If point is 5 (on the 'm' of main), C-M-f will bring me to the
space after the closing ')'. This is different from c++-mode,
but I think I can learn to live with this, in fact I think I like
it. However if point is anywhere on 'ain', point stays put, and
that's very jarring when compared to every other mode I've ever
worked with in Emacs.
Shouldn't the intervening treesit-end-of-thing go to the end of the
current thing?, i.e. to the '('? I think it should, at least judging
from its docstring, and this patch makes that happen:
- (setq pos (funcall advance (if (> arg 0) next prev)))
+ (setq pos (funcall advance (or (if (> arg 0) next prev)
+ parent)))
This doesn't seem to break tests, assuming it's not in these 3 there
were skipped because I don't have the grammar installed.
s treesit-defun-navigation-nested-3
s treesit-defun-navigation-nested-4
s treesit-multi-lang
If this patch isn't acceptable, is it possible to make this
customizable somehow? I know I can set forward-sexp-function to
something else, but I now am actually getting used to this f-s-f,
only this bit is putting me off.
João
- bug#68899: Treesitter's forward-sexp-function,
João Távora <=
- bug#68899: Treesitter's forward-sexp-function, João Távora, 2024/02/02
- bug#68899: Treesitter's forward-sexp-function, João Távora, 2024/02/02
- bug#68899: Treesitter's forward-sexp-function, Yuan Fu, 2024/02/04
- bug#68899: Treesitter's forward-sexp-function, João Távora, 2024/02/04
- bug#68899: Treesitter's forward-sexp-function, Yuan Fu, 2024/02/04
- bug#68899: Treesitter's forward-sexp-function, João Távora, 2024/02/04
- bug#68899: Treesitter's forward-sexp-function, Yuan Fu, 2024/02/06