Function: timeout--throttle-advice
timeout--throttle-advice is a byte-compiled function defined in
timeout.el.gz.
Signature
(timeout--throttle-advice &optional TIMEOUT)
Documentation
Return a function that throttles its argument function.
For the meaning of TIMEOUT see timeout-throttle.
When FUNC does not run because of the throttle, the result from the previous successful call is returned.
This is intended for use as function advice.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/timeout.el.gz
(defun timeout--throttle-advice (&optional timeout)
"Return a function that throttles its argument function.
For the meaning of TIMEOUT see `timeout-throttle'.
When FUNC does not run because of the throttle, the result from the
previous successful call is returned.
This is intended for use as function advice."
(let ((throttle-timer)
(timeout-value (or timeout 1.0))
(result))
(lambda (orig-fn &rest args)
"Throttle calls to this function."
(progn
(unless (and throttle-timer (timerp throttle-timer))
(setq result (apply orig-fn args))
(setq throttle-timer
(run-with-timer
(timeout--eval-value timeout-value) nil
(lambda ()
(cancel-timer throttle-timer)
(setq throttle-timer nil)))))
result))))