Subject: bug#76784: 31.0.50; up-list works incorrectly on emacs-30 if forward-sexp-function is set to treesit-forward-sexp

From: Roman Rudakov <[email-masked]>
Date: Fri, 07 Mar 2025 11:28:57 +0100

Juri Linkov <[email-masked]> writes:

>> The bug is reproducible for clojure-ts-mode. If "sexp" thing is 
>> defined for
>> tree-sitter mode, forward-sexp-function is set to 
>> treesit-forward-sexp
>> (https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/treesit.el?h=emacs-30#n3147)
>>
>> This setting triggers condition in the up-list function
>> (https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-lisp/lisp.el?h=emacs-30#n258)
>>
>> If point is outside of a top-level sexp, up-list function calls
>> forward-list until point position reaches the bottom of the buffer.
>>
>> Expected behavior: point stays at the end of sexp and message "At 
>> the top
>> level" is shown in the echo area.
>>
>> On master branch this issue can be fixed by setting 
>> up-list-function to
>> treesit-up-list, but on emacs-30 up-list-function doesn't exist.
>
> Thanks for the bug report.  This can be fixed for Emacs 31 
> (i.e. current
> master) by such patch.  Also please note that 
> treesit-transpose-sexps
> is working again on Emacs 31.
>

Thank you for the patch Juri! I tried it locally and it works well for 
Emacs 31. I'll suggest to apply it to clojure-ts-mode.

>> Would it be possible to fix the issue in the next bugfix release 
>> (if it's
>> planned)?
>
> You could try to convince our maintainers to consider backporting 
> the fix
> from master to the release branch.
>

--
Best regards, Roman