]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/treesit.el (treesit-cycle-sexp-type): Add optional arg 'interactive'.
authorJuri Linkov <juri@linkov.net>
Sun, 20 Apr 2025 17:46:31 +0000 (20:46 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 21 Apr 2025 20:42:19 +0000 (22:42 +0200)
Display the message only for interactive usage.

(cherry picked from commit d7b56fc2ee9d32f6fd9f3b6e8d3772fb714f0f32)

lisp/treesit.el

index 10384c933657a369a9e0d449c94834ca9f624063..59a159825b8b8fefe7e04259e66d3aa2bfbedd7c 100644 (file)
@@ -3192,7 +3192,7 @@ ARG is described in the docstring of `up-list'."
                             (point) (point))))))
       (setq cnt (- cnt inc)))))
 
-(defun treesit-cycle-sexp-type ()
+(defun treesit-cycle-sexp-type (&optional interactive)
   "Cycle the type of navigation for sexp and list commands.
 This type affects navigation commands such as `treesit-forward-sexp',
 `treesit-forward-list', `treesit-down-list', `treesit-up-list'.
@@ -3206,9 +3206,9 @@ navigate symbols and treesit definition to navigate lists.
 The `sexp' type uses the `sexp' thing defined in `treesit-thing-settings'.
 With this type commands use only the treesit definition of parser nodes,
 without distinction between symbols and lists."
-  (interactive)
+  (interactive "p")
   (if (not (treesit-thing-defined-p 'list (treesit-language-at (point))))
-      (message "No `list' thing is defined in `treesit-thing-settings'")
+      (user-error "No `list' thing is defined in `treesit-thing-settings'")
     (setq-local treesit-sexp-type-regexp
                 (unless treesit-sexp-type-regexp
                   (if (treesit-thing-defined-p
@@ -3219,10 +3219,11 @@ without distinction between symbols and lists."
                 (if treesit-sexp-type-regexp
                     #'treesit-forward-sexp
                   #'treesit-forward-sexp-list))
-    (message "Cycle sexp type to navigate %s"
-             (or (and treesit-sexp-type-regexp
-                      "treesit nodes")
-                 "syntax symbols and treesit lists"))))
+    (when interactive
+      (message "Cycle sexp type to navigate %s"
+               (or (and treesit-sexp-type-regexp
+                        "treesit nodes")
+                   "syntax symbols and treesit lists")))))
 
 (defun treesit-transpose-sexps (&optional arg)
   "Tree-sitter `transpose-sexps' function.