unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Yuan Fu <casouri@gmail.com>, Juri Linkov <juri@linkov.net>
Cc: 62158@debbugs.gnu.org
Subject: bug#62158: treesit-end-of-defun error
Date: Mon, 20 Mar 2023 20:43:51 +0200	[thread overview]
Message-ID: <f523e2f6-3cbc-0081-9662-de9c7eca74a1@yandex.ru> (raw)
In-Reply-To: <48E5D6CC-3249-4A5E-82B6-D3B9BF37D40A@gmail.com>

On 14/03/2023 00:04, Yuan Fu wrote:
> We tried that initially, but end-of-defun doesn’t have the notion of nested defuns, which leads to problems when end-of-defun-function recognizes nested defuns. In the following code
> 
> (defun xxx ()
>    |
>    (defun yyy () ...)
> 
>    (defun zzz () ...)
>    )
> 
> If point is at “|” and you call end-of-defun, you’d expect point to move to the end of yyy, but instead it moves to the end of xxx. That’s because end-of-defun first runs (beginning-of-defun -1) followed by (end-of-defun 1) to check if the starting point is in a defun or between two defuns. This is fine in non-nested defuns, but in this example, the point first goes to the beginning of xxx, then goes to the end of xxx. And end-of-defun thinks that we started in a defun and now is at an end of defun, job’s done, and finishes.
> 
> The plan is to improve end-of-defun to support nested defuns in Emacs 30. For now we rebind end-of-defun to treesit-end-of-defun.

That makes sense, thanks!

I guess one of the things to try is to call end-of-defun-function first, 
followed by beginning-of-defun-function. And see if the resulting 
position is below the original point.





  parent reply	other threads:[~2023-03-20 18:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13  7:28 bug#62158: treesit-end-of-defun error Juri Linkov
2023-03-13 22:04 ` Yuan Fu
2023-03-20 18:21   ` Juri Linkov
2023-03-20 18:43   ` Dmitry Gutov [this message]
2023-03-21 21:26     ` 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=f523e2f6-3cbc-0081-9662-de9c7eca74a1@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=62158@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=juri@linkov.net \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).