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 #32 received at 78458 <at> debbugs.gnu.org (full text, mbox):

From: Roman Rudakov <rrudakov <at> fastmail.com>
To: Juri Linkov <juri <at> linkov.net>
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:29:53 +0200
Roman Rudakov <rrudakov <at> fastmail.com> writes:

> Juri Linkov <juri <at> linkov.net> writes:
>
>>>> +      (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)
> Thank you! That is very helpful. I was able to use your patch with
> small modifications to make it work for function literals and sets
> (that have the same # marker node).  I'll try to discuss with the
> author of the grammar possibility to modify it to have just one
> 'open:' node instead of two.
>
> I think this bug can be closed now.
One more question.  Will the trick with defining 'sexp-default' work 
in Emacs 30?  Or is it a new "thing" which is only available in 
master?
--
Best regards, Roman




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.