GNU bug report logs -
#68899
Treesitter's forward-sexp-function
Previous Next
Reported by: João Távora <joaotavora <at> gmail.com>
Date: Fri, 2 Feb 2024 21:49:01 UTC
Severity: normal
Fixed in version 30.1
Done: Yuan Fu <casouri <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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
This bug report was last modified 1 year and 102 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.