(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.
This commit is contained in:
parent
2ea6ee5cbf
commit
f2ebe43362
1 changed files with 7 additions and 8 deletions
|
@ -1179,16 +1179,15 @@ See `treesit-simple-indent-presets'.")
|
||||||
;; TODO: Document.
|
;; TODO: Document.
|
||||||
(cons 'and (lambda (&rest fns)
|
(cons 'and (lambda (&rest fns)
|
||||||
(lambda (node parent bol &rest _)
|
(lambda (node parent bol &rest _)
|
||||||
(cl-reduce (lambda (a b) (and a b))
|
(not
|
||||||
(mapcar (lambda (fn)
|
(seq-find
|
||||||
(funcall fn node parent bol))
|
(lambda (fn) (not (funcall fn node parent bol)))
|
||||||
fns)))))
|
fns)))))
|
||||||
(cons 'or (lambda (&rest fns)
|
(cons 'or (lambda (&rest fns)
|
||||||
(lambda (node parent bol &rest _)
|
(lambda (node parent bol &rest _)
|
||||||
(cl-reduce (lambda (a b) (or a b))
|
(seq-find
|
||||||
(mapcar (lambda (fn)
|
(lambda (fn) (funcall fn node parent bol))
|
||||||
(funcall fn node parent bol))
|
fns))))
|
||||||
fns)))))
|
|
||||||
(cons 'not (lambda (fn)
|
(cons 'not (lambda (fn)
|
||||||
(lambda (node parent bol &rest _)
|
(lambda (node parent bol &rest _)
|
||||||
(not (funcall fn node parent bol)))))
|
(not (funcall fn node parent bol)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue