GNU bug report logs -
#78458
31.0.50; treesit.el: thing navigation functions work incorrectly with some Clojure nodes
Previous Next
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>
Bug is archived. No further changes may be made.
Full log
Message #20 received at 78458 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> + (sexp-default
>> + ;; For `C-M-f' in "#|(a)"
>> + ("(" . ,(lambda (node)
>> + (and (eq (char-before (point)) ?\#)
>> + (equal (treesit-node-type (treesit-node-parent node))
>> + "anon_fn_lit")))))
> Thanks Juri. I tried your patch and for some reason it doesn't solve the
> issue neither with 'raise-sexp' nor with 'C-M-f' navigation. The point is
> moved from:
>
> #|(-> (.-value (.-target %)))
>
> to
>
> #(-> (.-value (.-target %))|)
I tested that this patch fixes 'C-M-f' navigation where point moves to
#(-> (.-value (.-target %)))|
> and 'raise-sexp' called from:
>
> #(-> |(.-value (.-target %)))
>
> produces:
>
> #(.-value (.-target %)))
Indeed, it didn't fix this case. For down/up-list it needs
to use 'sexp' thing instead of 'list' thing. Probably the simplest
setting would be to redefine down-list-function/up-list-function.
Ok, here is a complete tested patch that fixes all your test cases:
[clojure-ts-mode-sexp.patch (text/x-diff, inline)]
diff --git a/clojure-ts-mode.el b/clojure-ts-mode.el
index 8b6bca7..6ae8e16 100644
--- a/clojure-ts-mode.el
+++ b/clojure-ts-mode.el
@@ -1549,6 +1549,12 @@ clojure-ts--thing-settings
`((clojure
(sexp ,(regexp-opt clojure-ts--sexp-nodes))
(list ,(regexp-opt clojure-ts--list-nodes))
+ (sexp-default
+ ;; For `C-M-f' in "#|(a)"
+ ("(" . ,(lambda (node)
+ (and (eq (char-before (point)) ?\#)
+ (equal (treesit-node-type (treesit-node-parent node))
+ "anon_fn_lit")))))
(text ,(regexp-opt '("comment")))
(defun ,#'clojure-ts--defun-node-p))
(when clojure-ts-use-markdown-inline
@@ -2601,6 +2607,15 @@ clojure-ts-mode
0
t)
+ (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
This bug report was last modified today.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.