all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: 68899@debbugs.gnu.org, casouri@gmail.com
Subject: bug#68899: Treesitter's forward-sexp-function
Date: Fri, 2 Feb 2024 21:47:33 +0000	[thread overview]
Message-ID: <CALDnm52ZbRaafVWXnWuUUoE01noSRUFcLem7XT_LCJ17qpP3ng@mail.gmail.com> (raw)

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





             reply	other threads:[~2024-02-02 21:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 21:47 João Távora [this message]
2024-02-03  0:42 ` bug#68899: Treesitter's forward-sexp-function João Távora
2024-02-03  0:57   ` João Távora
2024-02-04  5:35     ` Yuan Fu
2024-02-04 12:40       ` João Távora
2024-02-05  0:50         ` Yuan Fu
2024-02-05  1:08           ` João Távora
2024-02-06  7:25             ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALDnm52ZbRaafVWXnWuUUoE01noSRUFcLem7XT_LCJ17qpP3ng@mail.gmail.com \
    --to=joaotavora@gmail.com \
    --cc=68899@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.