aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2023-01-07 02:02:25 +0200
committerDmitry Gutov2023-01-07 02:02:25 +0200
commitf2ebe43362cab1b8d88674dad60b1ed3c822bb54 (patch)
tree46c59c1f1b74be3dea32a8ac7bb78b3b985e2e4c
parent2ea6ee5cbfac5c5e9a1e27ddda2d88cdedc6a6eb (diff)
downloademacs-f2ebe43362cab1b8d88674dad60b1ed3c822bb54.tar.gz
emacs-f2ebe43362cab1b8d88674dad60b1ed3c822bb54.zip
(treesit-simple-indent-presets): Short-circuit 'and' and 'or'
* lisp/treesit.el (treesit-simple-indent-presets): Short-circuit the 'and' and 'or' matchers. To avoid calling all fns after one returned nil or truthy value, respectively.
-rw-r--r--lisp/treesit.el15
1 files changed, 7 insertions, 8 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 987942c507a..a85eb699ee1 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1179,16 +1179,15 @@ See `treesit-simple-indent-presets'.")
1179 ;; TODO: Document. 1179 ;; TODO: Document.
1180 (cons 'and (lambda (&rest fns) 1180 (cons 'and (lambda (&rest fns)
1181 (lambda (node parent bol &rest _) 1181 (lambda (node parent bol &rest _)
1182 (cl-reduce (lambda (a b) (and a b)) 1182 (not
1183 (mapcar (lambda (fn) 1183 (seq-find
1184 (funcall fn node parent bol)) 1184 (lambda (fn) (not (funcall fn node parent bol)))
1185 fns))))) 1185 fns)))))
1186 (cons 'or (lambda (&rest fns) 1186 (cons 'or (lambda (&rest fns)
1187 (lambda (node parent bol &rest _) 1187 (lambda (node parent bol &rest _)
1188 (cl-reduce (lambda (a b) (or a b)) 1188 (seq-find
1189 (mapcar (lambda (fn) 1189 (lambda (fn) (funcall fn node parent bol))
1190 (funcall fn node parent bol)) 1190 fns))))
1191 fns)))))
1192 (cons 'not (lambda (fn) 1191 (cons 'not (lambda (fn)
1193 (lambda (node parent bol &rest _) 1192 (lambda (node parent bol &rest _)
1194 (not (funcall fn node parent bol))))) 1193 (not (funcall fn node parent bol)))))