Function: treemacs-debounce

treemacs-debounce is a macro defined in treemacs-macros.el.

Signature

(treemacs-debounce GUARD DELAY &rest BODY)

Documentation

Debounce a function call.

Based on a timer GUARD variable run function with the given DELAY and BODY.

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-macros.el
(defmacro treemacs-debounce (guard delay &rest body)
  "Debounce a function call.
Based on a timer GUARD variable run function with the given DELAY and BODY."
  (declare (indent 2))
  `(unless ,guard
     (setf ,guard
           (run-with-idle-timer
            ,delay nil
            (lambda ()
              (unwind-protect
                  (progn ,@body)
                (setf ,guard nil)))))))