Function: timeout-throttle
timeout-throttle is an autoloaded and byte-compiled function defined
in timeout.el.gz.
Signature
(timeout-throttle FUNC &optional THROTTLE)
Documentation
Make FUNC run no more frequently than once every THROTTLE seconds.
THROTTLE defaults to 1 second. THROTTLE can be a number, a symbol (whose value is a number), or a function (that evaluates to a number). When passed a symbol or function, it is evaluated at runtime for dynamic duration. Using a throttle of 0 removes any throttle advice.
When FUNC does not run because of the throttle, the result from the previous successful call is returned.
Aliases
timeout-throttle! (obsolete since v2.0)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/timeout.el.gz
;;;###autoload
(defun timeout-throttle (func &optional throttle)
"Make FUNC run no more frequently than once every THROTTLE seconds.
THROTTLE defaults to 1 second. THROTTLE can be a number, a symbol (whose
value is a number), or a function (that evaluates to a number). When
passed a symbol or function, it is evaluated at runtime for dynamic
duration. Using a throttle of 0 removes any throttle advice.
When FUNC does not run because of the throttle, the result from the
previous successful call is returned."
(if (and throttle (eq throttle 0))
(advice-remove func 'throttle)
(advice-add func :around (timeout--throttle-advice throttle)
'((name . throttle)
(depth . -98)))))