GNU bug report logs - #78458
31.0.50; treesit.el: thing navigation functions work incorrectly with some Clojure nodes

Previous Next

Package: emacs;

Reported by: Roman Rudakov <rrudakov <at> fastmail.com>

Date: Fri, 16 May 2025 15:38:02 UTC

Severity: normal

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

Full log


Message #26 received at 78458 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Roman Rudakov <rrudakov <at> fastmail.com>
Cc: 78458 <at> debbugs.gnu.org
Subject: Re: bug#78458: 31.0.50; treesit.el: thing navigation functions work
 incorrectly with some Clojure nodes
Date: Mon, 19 May 2025 21:50:37 +0300
>> +      (setq-local down-list-function
>> +                  (lambda (&optional arg)
>> +                    (let ((treesit-sexp-type-regexp 'sexp))
>> +                      (treesit-down-list arg))))
>> +      (setq-local up-list-function
>> +                  (lambda (&optional arg escape-strings no-syntax-crossing)
>> +                    (let ((treesit-sexp-type-regexp 'sexp))
>> +                      (treesit-up-list arg escape-strings no-syntax-crossing))))
>> +
>>        ;; Workaround for treesit-transpose-sexps not correctly working with
>>        ;; treesit-thing-settings on Emacs 30.
>>        ;; Once treesit-transpose-sexps it working again this can be removed
> Thank you very much for the patch Juri. It indeed solves all of the
> problems I mentioned.  However while I was testing the patch I noticed that
> the 'down-list' function behaves a bit odd. If I call it multiple times
> starting from the beginning of the line it moves the point to the following
> positions:
>
> #|(-> (.-value (.-target %)))
> #(->| (.-value (.-target %)))
> #(-> (.-value| (.-target %)))
> #(-> (.-value| (|.-target %)))
> #(-> (.-value| (.-target| %)))
> #(-> (.-value| (.-target %|)))

Then please remove '(setq-local down-list-function ..' from the patch,
it's not needed.

> While it would be more logical to have:
>
> #(|-> (.-value (.-target %)))
> #(-> (|.-value (.-target %)))
> #(-> (.-value (|.-target %)))

Without redefining 'down-list-function'
the 'down-list' function behaves like above.

But we can do nothing to fix the first step:

#|(-> (.-value (.-target %)))

because using treesit nodes, "#" is a child node of
'anon_fn_lit', so 'down-list' goes after it.

Since the treesit grammar can't handle this case,
you could try to use the default function by

  (setq-local down-list-function nil)




This bug report was last modified 28 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.