summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/timer.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2019-11-30 23:16:03 +0200
committerJuri Linkov <juri@linkov.net>2019-11-30 23:16:03 +0200
commitd64ea182fb6e2bf3af8ac8a289e8029ded36407e (patch)
tree0e7835bc8f2f2b62a64a1fed3f72871abf3ad611 /lisp/emacs-lisp/timer.el
parent9ac78ef56c184b757f9866edc3092eb62e259c90 (diff)
downloademacs-d64ea182fb6e2bf3af8ac8a289e8029ded36407e.tar.gz
emacs-d64ea182fb6e2bf3af8ac8a289e8029ded36407e.tar.bz2
emacs-d64ea182fb6e2bf3af8ac8a289e8029ded36407e.zip
Use run-with-idle-timer instead of debounce for responsive image scaling.
* lisp/emacs-lisp/timer.el (debounce, debounce-reduce): Revert macro addition. https://lists.gnu.org/archive/html/emacs-devel/2019-11/msg01133.html * lisp/image.el (image-increase-size, image-decrease-size): Use run-with-idle-timer. (image--change-size): Rename back from image--change-size-function. * lisp/image-mode.el (image-mode--setup-mode): Remove hooks window-size-change-functions and window-selection-change-functions (bug#32672) (image-fit-to-window): Rename from image--window-change-function. (image--window-state-change): Rename from image--window-change. Use run-with-idle-timer.
Diffstat (limited to 'lisp/emacs-lisp/timer.el')
-rw-r--r--lisp/emacs-lisp/timer.el44
1 files changed, 0 insertions, 44 deletions
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index 5fdf9a426a7..561cc70078f 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -488,50 +488,6 @@ The argument should be a value previously returned by `with-timeout-suspend'."
If the user does not answer after SECONDS seconds, return DEFAULT-VALUE."
(with-timeout (seconds default-value)
(y-or-n-p prompt)))
-
-(defmacro debounce (secs function)
- "Call FUNCTION after SECS seconds have elapsed.
-Postpone FUNCTION call until after SECS seconds have elapsed since the
-last time it was invoked. On consecutive calls within the interval of
-SECS seconds, cancel all previous calls that occur rapidly in quick succession,
-and execute only the last call. This improves performance of event processing."
- (declare (indent 1) (debug t))
- (let ((timer-sym (make-symbol "timer")))
- `(let (,timer-sym)
- (lambda (&rest args)
- (when (timerp ,timer-sym)
- (cancel-timer ,timer-sym))
- (setq ,timer-sym
- (run-with-timer
- ,secs nil (lambda ()
- (apply ,function args))))))))
-
-(defmacro debounce-reduce (secs initial-state state-function function)
- "Call FUNCTION after SECS seconds have elapsed.
-Postpone FUNCTION call until after SECS seconds have elapsed since the
-last time it was invoked. On consecutive calls within the interval of
-SECS seconds, cancel all previous calls that occur rapidly in quick succession,
-and execute only the last call. This improves performance of event processing.
-
-STATE-FUNCTION can be used to accumulate the state on consecutive calls
-starting with the value of INITIAL-STATE, and then execute the last call
-with the collected state value."
- (declare (indent 1) (debug t))
- (let ((timer-sym (make-symbol "timer"))
- (state-sym (make-symbol "state")))
- `(let (,timer-sym (,state-sym ,initial-state))
- (lambda (&rest args)
- (setq ,state-sym (apply ,state-function ,state-sym args))
- (when (timerp ,timer-sym)
- (cancel-timer ,timer-sym))
- (setq ,timer-sym
- (run-with-timer
- ,secs nil (lambda ()
- (apply ,function (if (listp ,state-sym)
- ,state-sym
- (list ,state-sym)))
- (setq ,state-sym ,initial-state))))))))
-
(defconst timer-duration-words
(list (cons "microsec" 0.000001)