Function: mouse-avoidance-mode
mouse-avoidance-mode is an autoloaded, interactive and byte-compiled
function defined in avoid.el.gz.
Signature
(mouse-avoidance-mode &optional MODE)
Documentation
Set Mouse Avoidance mode to MODE.
MODE should be one of the symbols banish, exile, jump, animate,
cat-and-mouse, proteus, or none.
If MODE is nil, toggle mouse avoidance between none and banish
modes. Positive numbers and symbols other than the above are treated
as equivalent to banish; negative numbers and - are equivalent to none.
Effects of the different modes:
* banish: Move the mouse to the upper-right corner on any keypress.
* exile: Move the mouse to the corner only if the cursor gets too close,
and allow it to return once the cursor is out of the way.
* jump: If the cursor gets too close to the mouse, displace the mouse
a random distance & direction.
* animate: As jump, but shows steps along the way for illusion of motion.
* cat-and-mouse: Same as animate.
* proteus: As animate, but changes the shape of the mouse pointer too.
(See mouse-avoidance-threshold for definition of "too close",
and mouse-avoidance-nudge-dist and mouse-avoidance-nudge-var for
definition of "random distance".)
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/avoid.el.gz
;;;###autoload
(defun mouse-avoidance-mode (&optional mode)
"Set Mouse Avoidance mode to MODE.
MODE should be one of the symbols `banish', `exile', `jump', `animate',
`cat-and-mouse', `proteus', or `none'.
If MODE is nil, toggle mouse avoidance between `none' and `banish'
modes. Positive numbers and symbols other than the above are treated
as equivalent to `banish'; negative numbers and `-' are equivalent to `none'.
Effects of the different modes:
* banish: Move the mouse to the upper-right corner on any keypress.
* exile: Move the mouse to the corner only if the cursor gets too close,
and allow it to return once the cursor is out of the way.
* jump: If the cursor gets too close to the mouse, displace the mouse
a random distance & direction.
* animate: As `jump', but shows steps along the way for illusion of motion.
* cat-and-mouse: Same as `animate'.
* proteus: As `animate', but changes the shape of the mouse pointer too.
\(See `mouse-avoidance-threshold' for definition of \"too close\",
and `mouse-avoidance-nudge-dist' and `mouse-avoidance-nudge-var' for
definition of \"random distance\".)"
(interactive
(list (intern (completing-read
"Select cursor avoidance technique (SPACE for list): "
'(("banish") ("exile") ("jump") ("animate")
("cat-and-mouse") ("proteus") ("none"))
nil t))))
(if (eq mode 'cat-and-mouse)
(setq mode 'animate))
(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)
(mouse-avoidance-set-pointer-shape mouse-avoidance-old-pointer-shape))
;; Do additional setup depending on version of mode requested
(cond ((eq mode 'none)
(setq mouse-avoidance-mode nil))
((or (eq mode 'jump)
(eq mode 'animate)
(eq mode 'proteus))
(setq mouse-avoidance-timer
(run-with-idle-timer 0.1 t 'mouse-avoidance-fancy))
(setq mouse-avoidance-mode mode
mouse-avoidance-state (cons 0 0)
mouse-avoidance-old-pointer-shape
(and (boundp 'x-pointer-shape) x-pointer-shape)))
((eq mode 'exile)
(setq mouse-avoidance-timer
(run-with-idle-timer 0.1 t 'mouse-avoidance-exile))
(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)))
(setq mouse-avoidance-timer
(run-with-idle-timer 0.1 t 'mouse-avoidance-banish))
(setq mouse-avoidance-mode 'banish))
(t (setq mouse-avoidance-mode nil)))
(force-mode-line-update))