From 85a3cf62223ff3cb045f94ea822c67ed755f7973 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 20 Apr 2025 20:46:31 +0300 Subject: [PATCH] * lisp/treesit.el (treesit-cycle-sexp-type): Add optional arg 'interactive'. Display the message only for interactive usage. (cherry picked from commit d7b56fc2ee9d32f6fd9f3b6e8d3772fb714f0f32) --- lisp/treesit.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index 10384c93365..59a159825b8 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -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. -- 2.39.5