]> git.eshelyaron.com Git - emacs.git/commitdiff
Make treesit--simple-indent-eval more permissive (bug#78065)
authorYuan Fu <casouri@gmail.com>
Wed, 7 May 2025 03:57:06 +0000 (20:57 -0700)
committerEshel Yaron <me@eshelyaron.com>
Sat, 10 May 2025 14:04:18 +0000 (16:04 +0200)
* lisp/treesit.el (treesit--simple-indent-eval): Allow EXP to be
anything, so higher-order indent presets can take anything as an
argument: t, nil, symbols, keywords, etc.

(cherry picked from commit 0b4eb525b69822c6b503982ef49980c72c8d0232)

lisp/treesit.el

index 17b55362ab11e6408390237105f708a82150e7bd..9cbf063be1d8ea33cf54df307d2ca6df1fb2795c 100644 (file)
@@ -2520,14 +2520,12 @@ the function."
         ;; `functionp'.
         ((alist-get exp treesit-simple-indent-presets))
         ((functionp exp) exp)
-        ((symbolp exp)
-         (if (null exp)
-             exp
-           ;; Matchers only return lambdas, anchors only return
-           ;; integer, so we should never see a variable.
-           (signal 'treesit-indent-error
-                   (list "Couldn't find the preset corresponding to expression"
-                         exp))))
+        ;; There are higher-order presets that take arguments, like
+        ;; (nth-sibling 1 t), so it's possible for exp to be something
+        ;; other than numbers and functions.  Don't signal an error if
+        ;; exp isn't a function nor a number.  In fact, allow exp to be
+        ;; any symbol or keyword, so users can define higher-order
+        ;; presets that takes keyword or symbol as arguments.
         (t exp)))
 
 ;; This variable might seem unnecessary: why split