# HG changeset patch # User Richard M. Stallman # Date 871410000 0 # Node ID b686f7cb68490776eabb47c3117512e957dcaf46 # Parent cc9e75f82cdbbcf68d00defaadb77cdfd457ce96 (mouse-avoidance-timer): New variable. (mouse-avoidance-mode): Create or cancel a time, instead of using post-command-idle-hook. diff -r cc9e75f82cdb -r b686f7cb6849 lisp/avoid.el --- a/lisp/avoid.el Tue Aug 12 17:23:14 1997 +0000 +++ b/lisp/avoid.el Tue Aug 12 18:20:00 1997 +0000 @@ -111,6 +111,9 @@ (defvar mouse-avoidance-n-pointer-shapes 0) (defvar mouse-avoidance-old-pointer-shape nil) +;; This timer is used to run something when Emacs is idle. +(defvar mouse-avoidance-timer nil) + ;;; Functions: (defsubst mouse-avoidance-set-pointer-shape (shape) @@ -335,9 +338,9 @@ nil t)))) (if (eq mode 'cat-and-mouse) (setq mode 'animate)) - (remove-hook 'post-command-idle-hook 'mouse-avoidance-banish-hook) - (remove-hook 'post-command-idle-hook 'mouse-avoidance-exile-hook) - (remove-hook 'post-command-idle-hook 'mouse-avoidance-fancy-hook) + (if mouse-avoidance-timer + (cancel-timer mouse-avoidance-timer)) + (setq mouse-avoidance-timer nil) ;; Restore pointer shape if necessary (if (eq mouse-avoidance-mode 'proteus) @@ -349,19 +352,22 @@ ((or (eq mode 'jump) (eq mode 'animate) (eq mode 'proteus)) - (add-hook 'post-command-idle-hook 'mouse-avoidance-fancy-hook) + (setq mouse-avoidance-timer + (run-with-idle-timer 0.1 t 'mouse-avoidance-fancy-hook)) (setq mouse-avoidance-mode mode mouse-avoidance-state (cons 0 0) mouse-avoidance-old-pointer-shape x-pointer-shape)) ((eq mode 'exile) - (add-hook 'post-command-idle-hook 'mouse-avoidance-exile-hook) + (setq mouse-avoidance-timer + (run-with-idle-timer 0.1 t 'mouse-avoidance-exile-hook)) (setq mouse-avoidance-mode mode mouse-avoidance-state nil)) ((or (eq mode 'banish) (eq mode t) (and (null mode) (null mouse-avoidance-mode)) (and mode (> (prefix-numeric-value mode) 0))) - (add-hook 'post-command-idle-hook 'mouse-avoidance-banish-hook) + (setq mouse-avoidance-timer + (run-with-idle-timer 0.1 t 'mouse-avoidance-banish-hook)) (setq mouse-avoidance-mode 'banish)) (t (setq mouse-avoidance-mode nil))) (force-mode-line-update))