(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.
|
||||
(cons 'and (lambda (&rest fns)
|
||||
(lambda (node parent bol &rest _)
|
||||
(cl-reduce (lambda (a b) (and a b))
|
||||
(mapcar (lambda (fn)
|
||||
(funcall fn node parent bol))
|
||||
fns)))))
|
||||
(not
|
||||
(seq-find
|
||||
(lambda (fn) (not (funcall fn node parent bol)))
|
||||
fns)))))
|
||||
(cons 'or (lambda (&rest fns)
|
||||
(lambda (node parent bol &rest _)
|
||||
(cl-reduce (lambda (a b) (or a b))
|
||||
(mapcar (lambda (fn)
|
||||
(funcall fn node parent bol))
|
||||
fns)))))
|
||||
(seq-find
|
||||
(lambda (fn) (funcall fn node parent bol))
|
||||
fns))))
|
||||
(cons 'not (lambda (fn)
|
||||
(lambda (node parent bol &rest _)
|
||||
(not (funcall fn node parent bol)))))
|
||||
|
|
Loading…
Add table
Reference in a new issue