GNU bug report logs -
#78458
31.0.50; treesit.el: thing navigation functions work incorrectly with some Clojure nodes
Previous Next
Full log
View this message in rfc822 format
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.