Mercurial > emacs
annotate lisp/avoid.el @ 13561:21b6b8f50143
(XTread_socket): Verify a ButtonPress was actually in the
menu bar before generating a menu_bar_activate_event event.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 15 Nov 1995 23:15:49 +0000 |
parents | 84acc3adcd63 |
children | 187735b53d52 |
rev | line source |
---|---|
13337 | 1 ;;; avoid.el --- make mouse pointer stay out of the way of editing |
5119 | 2 |
5745 | 3 ;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc. |
5119 | 4 |
12082
257af4819582
Change email address for Boris.
Boris Goldowsky <boris@gnu.org>
parents:
11269
diff
changeset
|
5 ;; Author: Boris Goldowsky <boris@gnu.ai.mit.edu> |
5119 | 6 ;; Keywords: mouse |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
24 ;;; Commentary: | |
25 ;;; | |
26 ;;; For those who are annoyed by the mouse pointer obscuring text, | |
27 ;;; this mode moves the mouse pointer - either just a little out of | |
28 ;;; the way, or all the way to the corner of the frame. | |
29 ;;; To use, load or evaluate this file and type M-x mouse-avoidance-mode . | |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
30 ;;; To set up permanently, put the following in your .emacs: |
5119 | 31 ;;; |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
32 ;;; (if window-system (mouse-avoidance-mode 'animate)) |
5119 | 33 ;;; |
7015 | 34 ;;; The 'animate can be 'jump or 'banish or 'exile or 'protean if you prefer. |
5745 | 35 ;;; See the documentation for function `mouse-avoidance-mode' for |
36 ;;; details of the different modes. | |
5119 | 37 ;;; |
38 ;;; For added silliness, make the animatee animate... | |
39 ;;; put something similar to the following into your .emacs: | |
40 ;;; | |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
41 ;;; (if window-system |
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
42 ;;; (mouse-avoidance-set-pointer-shape |
5119 | 43 ;;; (eval (nth (random 4) |
44 ;;; '(x-pointer-man x-pointer-spider | |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
45 ;;; x-pointer-gobbler x-pointer-gumby))))) |
5119 | 46 ;;; |
47 ;;; For completely random pointer shape, replace the setq above with: | |
48 ;;; (setq x-pointer-shape (mouse-avoidance-random-shape)) | |
49 ;;; | |
7015 | 50 ;;; Bugs / Warnings / To-Do: |
5119 | 51 ;;; |
52 ;;; - Using this code does slow emacs down. "banish" mode shouldn't | |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
53 ;;; be too bad, and on my workstation even "animate" is reasonable. |
5119 | 54 ;;; |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
55 ;;; - It ought to find out where any overlapping frames are and avoid them, |
7015 | 56 ;;; rather than always raising the frame. |
5119 | 57 |
58 ;;; Credits: | |
7015 | 59 ;;; This code was helped by all those who contributed suggestions, |
60 ;;; fixes, and additions | |
61 ;;; Joe Harrington (and his advisor), for the original inspiration. | |
62 ;;; Ken Manheimer, for dreaming up the Protean mode. | |
63 ;;; Richard Stallman, for the awful cat-and-mouse pun, among other things. | |
5119 | 64 ;;; Mike Williams, Denis Howe, Bill Benedetto, Chris Moore, Don Morris, |
65 ;;; Simon Marshall, and M.S. Ashton, for their feedback. | |
66 ;;; | |
67 ;;; Code: | |
68 | |
69 (provide 'avoid) | |
70 | |
71 (defvar mouse-avoidance-mode nil | |
72 "Value is t or a symbol if the mouse pointer should avoid the cursor. | |
7556 | 73 See function `mouse-avoidance-mode' for possible values. Changing this |
74 variable is NOT the recommended way to change modes; use that function | |
5119 | 75 instead.") |
76 | |
7015 | 77 (defvar mouse-avoidance-nudge-dist 15 |
5119 | 78 "*Average distance that mouse will be moved when approached by cursor. |
7571
d0c9af68a5ba
(mouse-avoidance-nudge-dist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7556
diff
changeset
|
79 Only applies in mouse-avoidance-mode `jump' and its derivatives. |
7879
e0f3cfb55df7
(mouse-avoidance-threshold): Renamed from ...threshhold.
Richard M. Stallman <rms@gnu.org>
parents:
7849
diff
changeset
|
80 For best results make this larger than `mouse-avoidance-threshold'.") |
5119 | 81 |
7015 | 82 (defvar mouse-avoidance-nudge-var 10 |
7556 | 83 "*Variability of `mouse-avoidance-nudge-dist' (which see).") |
5119 | 84 |
85 (defvar mouse-avoidance-animation-delay .01 | |
86 "Delay between animation steps, in seconds.") | |
87 | |
7879
e0f3cfb55df7
(mouse-avoidance-threshold): Renamed from ...threshhold.
Richard M. Stallman <rms@gnu.org>
parents:
7849
diff
changeset
|
88 (defvar mouse-avoidance-threshold 5 |
5119 | 89 "*Mouse-pointer's flight distance. |
90 If the cursor gets closer than this, the mouse pointer will move away. | |
91 Only applies in mouse-avoidance-modes `animate' and `jump'.") | |
92 | |
7015 | 93 ;; Internal variables |
94 (defvar mouse-avoidance-state nil) | |
5119 | 95 (defvar mouse-avoidance-pointer-shapes nil) |
96 (defvar mouse-avoidance-n-pointer-shapes 0) | |
97 | |
98 ;;; Functions: | |
99 | |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
100 (defsubst mouse-avoidance-set-pointer-shape (shape) |
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
101 "Set the shape of the mouse pointer to SHAPE." |
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
102 (setq x-pointer-shape shape) |
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
103 (set-mouse-color nil)) |
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
104 |
7015 | 105 (defun mouse-avoidance-point-position () |
7556 | 106 "Return the position of point as (FRAME X . Y). |
7015 | 107 Analogous to mouse-position." |
108 (let* ((w (selected-window)) | |
109 (edges (window-edges w)) | |
110 (list | |
7849
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
111 (compute-motion (max (window-start w) (point-min)) ; start pos |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
112 ;; window-start can be < point-min if the |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
113 ;; latter has changed since the last redisplay |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
114 '(0 . 0) ; start XY |
7015 | 115 (point) ; stop pos |
7849
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
116 (cons (window-width) (window-height)); stop XY: none |
7015 | 117 (1- (window-width)) ; width |
7849
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
118 (cons (window-hscroll w) 0) ; 0 may not be right? |
7015 | 119 (selected-window)))) |
120 ;; compute-motion returns (pos HPOS VPOS prevhpos contin) | |
121 ;; we want: (frame hpos . vpos) | |
7849
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
122 (cons (selected-frame) |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
123 (cons (+ (car edges) (car (cdr list))) |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
124 (+ (car (cdr edges)) (car (cdr (cdr list)))))))) |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
125 |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
126 ;(defun mouse-avoidance-point-position-test () |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
127 ; (interactive) |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
128 ; (message (format "point=%s mouse=%s" |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
129 ; (cdr (mouse-avoidance-point-position)) |
bbc7770db51c
(mouse-avoidance-point-position): Fix compute-motion
Richard M. Stallman <rms@gnu.org>
parents:
7571
diff
changeset
|
130 ; (cdr (mouse-position))))) |
7015 | 131 |
132 (defun mouse-avoidance-set-mouse-position (pos) | |
133 ;; Carefully set mouse position to given position (X . Y) | |
134 ;; Ideally, should check if X,Y is in the current frame, and if not, | |
135 ;; leave the mouse where it was. However, this is currently | |
136 ;; difficult to do, so we just raise the frame to avoid frame switches. | |
137 ;; Returns t if it moved the mouse. | |
138 (let ((f (selected-frame))) | |
139 (raise-frame f) | |
140 (set-mouse-position f (car pos) (cdr pos)) | |
141 t)) | |
142 | |
143 (defun mouse-avoidance-too-close-p (mouse) | |
5119 | 144 ;; Return t if mouse pointer and point cursor are too close. |
7879
e0f3cfb55df7
(mouse-avoidance-threshold): Renamed from ...threshhold.
Richard M. Stallman <rms@gnu.org>
parents:
7849
diff
changeset
|
145 ;; Acceptable distance is defined by mouse-avoidance-threshold. |
7015 | 146 (let ((point (mouse-avoidance-point-position))) |
147 (and (eq (car mouse) (car point)) | |
148 (car (cdr mouse)) | |
149 (< (abs (- (car (cdr mouse)) (car (cdr point)))) | |
7879
e0f3cfb55df7
(mouse-avoidance-threshold): Renamed from ...threshhold.
Richard M. Stallman <rms@gnu.org>
parents:
7849
diff
changeset
|
150 mouse-avoidance-threshold) |
7015 | 151 (< (abs (- (cdr (cdr mouse)) (cdr (cdr point)))) |
7879
e0f3cfb55df7
(mouse-avoidance-threshold): Renamed from ...threshhold.
Richard M. Stallman <rms@gnu.org>
parents:
7849
diff
changeset
|
152 mouse-avoidance-threshold)))) |
5119 | 153 |
7015 | 154 (defun mouse-avoidance-banish-destination () |
7556 | 155 "The position to which mouse-avoidance-mode `banish' moves the mouse. |
7015 | 156 You can redefine this if you want the mouse banished to a different corner." |
157 (cons (1- (frame-width)) | |
158 0)) | |
159 | |
5119 | 160 (defun mouse-avoidance-banish-mouse () |
161 ;; Put the mouse pointer in the upper-right corner of the current frame. | |
7015 | 162 (mouse-avoidance-set-mouse-position (mouse-avoidance-banish-destination))) |
163 | |
164 (defsubst mouse-avoidance-delta (cur delta dist var min max) | |
165 ;; Decide how far to move in either dimension. | |
166 ;; Args are the CURRENT location, the desired DELTA for | |
167 ;; warp-conservation, the DISTANCE we like to move, the VARIABILITY | |
168 ;; in distance allowed, and the MIN and MAX possible window positions. | |
169 ;; Returns something as close to DELTA as possible withing the constraints. | |
170 (let ((L1 (max (- min cur) (+ (- dist) (- var)))) | |
171 (R1 (+ (- dist) var )) | |
172 (L2 (+ dist (- var))) | |
173 (R2 (min (- max cur) (+ dist var)))) | |
174 (if (< R1 (- min cur)) (setq L1 nil R1 nil)) | |
175 (if (> L2 (- max cur)) (setq L2 nil R2 nil)) | |
176 (cond ((and L1 (< delta L1)) L1) | |
177 ((and R1 (< delta R1)) delta) | |
178 ((and R1 (< delta 0)) R1) | |
179 ((and L2 (< delta L2)) L2) | |
180 ((and R2 (< delta R2)) delta) | |
181 (R2) | |
182 ((or R1 L2)) | |
183 (t 0)))) | |
5119 | 184 |
185 (defun mouse-avoidance-nudge-mouse () | |
186 ;; Push the mouse a little way away, possibly animating the move | |
7015 | 187 ;; For these modes, state keeps track of the total offset that we've |
188 ;; accumulated, and tries to keep it close to zero. | |
5119 | 189 (let* ((cur (mouse-position)) |
7015 | 190 (cur-frame (car cur)) |
191 (cur-pos (cdr cur)) | |
192 (deltax (mouse-avoidance-delta | |
193 (car cur-pos) (- (random mouse-avoidance-nudge-var) | |
194 (car mouse-avoidance-state)) | |
195 mouse-avoidance-nudge-dist mouse-avoidance-nudge-var | |
196 0 (frame-width))) | |
197 (deltay (mouse-avoidance-delta | |
198 (cdr cur-pos) (- (random mouse-avoidance-nudge-var) | |
199 (cdr mouse-avoidance-state)) | |
200 mouse-avoidance-nudge-dist mouse-avoidance-nudge-var | |
201 0 (frame-height)))) | |
202 (setq mouse-avoidance-state | |
203 (cons (+ (car mouse-avoidance-state) deltax) | |
204 (+ (cdr mouse-avoidance-state) deltay))) | |
5119 | 205 (if (or (eq mouse-avoidance-mode 'animate) |
206 (eq mouse-avoidance-mode 'proteus)) | |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
207 (let ((i 0.0)) |
5119 | 208 (while (<= i 1) |
7015 | 209 (mouse-avoidance-set-mouse-position |
210 (cons (+ (car cur-pos) (round (* i deltax))) | |
211 (+ (cdr cur-pos) (round (* i deltay))))) | |
212 (setq i (+ i (max .1 (/ 1.0 mouse-avoidance-nudge-dist)))) | |
5119 | 213 (if (eq mouse-avoidance-mode 'proteus) |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
214 (mouse-avoidance-set-pointer-shape |
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
215 (mouse-avoidance-random-shape))) |
5119 | 216 (sit-for mouse-avoidance-animation-delay))) |
7556 | 217 (mouse-avoidance-set-mouse-position (cons (+ (car (cdr cur)) deltax) |
218 (+ (cdr (cdr cur)) deltay)))))) | |
5119 | 219 |
220 (defun mouse-avoidance-random-shape () | |
221 "Return a random cursor shape. | |
222 This assumes that any variable whose name begins with x-pointer- and | |
223 has an integer value is a valid cursor shape. You might want to | |
224 redefine this function to suit your own tastes." | |
225 (if (null mouse-avoidance-pointer-shapes) | |
226 (progn | |
227 (setq mouse-avoidance-pointer-shapes | |
228 (mapcar '(lambda (x) (symbol-value (intern x))) | |
229 (all-completions "x-pointer-" obarray | |
230 '(lambda (x) | |
231 (and (boundp x) | |
232 (integerp (symbol-value x))))))) | |
233 (setq mouse-avoidance-n-pointer-shapes | |
234 (length mouse-avoidance-pointer-shapes)))) | |
235 (nth (random mouse-avoidance-n-pointer-shapes) | |
236 mouse-avoidance-pointer-shapes)) | |
237 | |
7015 | 238 (defun mouse-avoidance-banish-hook () |
239 (if (and (not executing-kbd-macro) ; don't check inside macro | |
240 (mouse-avoidance-kbd-command (this-command-keys))) | |
241 (mouse-avoidance-banish-mouse))) | |
242 | |
243 (defun mouse-avoidance-exile-hook () | |
244 ;; For exile mode, the state is nil when the mouse is in its normal | |
245 ;; position, and set to the old mouse-position when the mouse is in exile. | |
246 (if (and (not executing-kbd-macro) | |
247 (mouse-avoidance-kbd-command (this-command-keys))) | |
248 (let ((mp (mouse-position))) | |
249 (cond ((and (not mouse-avoidance-state) | |
250 (mouse-avoidance-too-close-p mp)) | |
251 (setq mouse-avoidance-state mp) | |
252 (mouse-avoidance-banish-mouse)) | |
253 ((and mouse-avoidance-state | |
254 (not (mouse-avoidance-too-close-p mouse-avoidance-state))) | |
255 (if (and (eq (car mp) (selected-frame)) | |
256 (equal (cdr mp) (mouse-avoidance-banish-destination))) | |
257 (mouse-avoidance-set-mouse-position | |
258 ;; move back only if user has not moved mouse | |
259 (cdr mouse-avoidance-state))) | |
260 ;; but clear state anyway, to be ready for another move | |
261 (setq mouse-avoidance-state nil)))))) | |
5119 | 262 |
263 (defun mouse-avoidance-fancy-hook () | |
7015 | 264 ;; Used for the "fancy" modes, ie jump et al. |
265 (if (and (not executing-kbd-macro) ; don't check inside macro | |
266 (mouse-avoidance-kbd-command (this-command-keys)) | |
267 (mouse-avoidance-too-close-p (mouse-position))) | |
5745 | 268 (let ((old-pos (mouse-position))) |
269 (mouse-avoidance-nudge-mouse) | |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
270 (if (not (eq (selected-frame) (car old-pos))) |
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
271 ;; This should never happen. |
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
272 (apply 'set-mouse-position old-pos))))) |
5119 | 273 |
7015 | 274 (defun mouse-avoidance-kbd-command (key) |
5119 | 275 "Return t if the KEYSEQENCE is composed of keyboard events only. |
7556 | 276 Return nil if there are any lists in the key sequence." |
5119 | 277 (cond ((null key) nil) ; Null event seems to be |
278 ; returned occasionally. | |
279 ((not (vectorp key)) t) ; Strings are keyboard events. | |
280 ((catch 'done | |
281 (let ((i 0) | |
282 (l (length key))) | |
283 (while (< i l) | |
284 (if (listp (aref key i)) | |
285 (throw 'done nil)) | |
286 (setq i (1+ i)))) | |
287 t)))) | |
288 | |
11269
26d830b04546
avoid.el Add autoload cookies; doc fixes.
Boris Goldowsky <boris@gnu.org>
parents:
7879
diff
changeset
|
289 ;;;###autoload |
5119 | 290 (defun mouse-avoidance-mode (&optional mode) |
291 "Set cursor avoidance mode to MODE. | |
7015 | 292 MODE should be one of the symbols `banish', `exile', `jump', `animate', |
5745 | 293 `cat-and-mouse', `proteus', or `none'. |
294 | |
7015 | 295 If MODE is nil, toggle mouse avoidance between `none` and `banish' |
5745 | 296 modes. Positive numbers and symbols other than the above are treated |
297 as equivalent to `banish'; negative numbers and `-' are equivalent to `none'. | |
298 | |
299 Effects of the different modes: | |
7556 | 300 * banish: Move the mouse to the upper-right corner on any keypress. |
301 * exile: Move the mouse to the corner only if the cursor gets too close, | |
7015 | 302 and allow it to return once the cursor is out of the way. |
7556 | 303 * jump: If the cursor gets too close to the mouse, displace the mouse |
7015 | 304 a random distance & direction. |
7556 | 305 * animate: As `jump', but shows steps along the way for illusion of motion. |
306 * cat-and-mouse: Same as `animate'. | |
307 * proteus: As `animate', but changes the shape of the mouse pointer too. | |
5745 | 308 |
7015 | 309 Whenever the mouse is moved, the frame is also raised. |
310 | |
7879
e0f3cfb55df7
(mouse-avoidance-threshold): Renamed from ...threshhold.
Richard M. Stallman <rms@gnu.org>
parents:
7849
diff
changeset
|
311 \(see `mouse-avoidance-threshold' for definition of \"too close\", |
5745 | 312 and `mouse-avoidance-nudge-dist' and `mouse-avoidance-nudge-var' for |
313 definition of \"random distance\".)" | |
5119 | 314 (interactive |
315 (list (intern (completing-read | |
316 "Select cursor avoidance technique (SPACE for list): " | |
7015 | 317 '(("banish") ("exile") ("jump") ("animate") |
318 ("cat-and-mouse") ("proteus") ("none")) | |
5119 | 319 nil t)))) |
320 (if (eq mode 'cat-and-mouse) | |
321 (setq mode 'animate)) | |
12940
f7d26ee5ea26
(mouse-avoidance-mode): Use post-command-idle-hook. Use remove-hook.
Richard M. Stallman <rms@gnu.org>
parents:
12082
diff
changeset
|
322 (remove-hook 'post-command-idle-hook 'mouse-avoidance-banish-hook) |
f7d26ee5ea26
(mouse-avoidance-mode): Use post-command-idle-hook. Use remove-hook.
Richard M. Stallman <rms@gnu.org>
parents:
12082
diff
changeset
|
323 (remove-hook 'post-command-idle-hook 'mouse-avoidance-exile-hook) |
f7d26ee5ea26
(mouse-avoidance-mode): Use post-command-idle-hook. Use remove-hook.
Richard M. Stallman <rms@gnu.org>
parents:
12082
diff
changeset
|
324 (remove-hook 'post-command-idle-hook 'mouse-avoidance-fancy-hook) |
5119 | 325 (cond ((eq mode 'none) |
326 (setq mouse-avoidance-mode nil)) | |
327 ((or (eq mode 'jump) | |
328 (eq mode 'animate) | |
329 (eq mode 'proteus)) | |
12940
f7d26ee5ea26
(mouse-avoidance-mode): Use post-command-idle-hook. Use remove-hook.
Richard M. Stallman <rms@gnu.org>
parents:
12082
diff
changeset
|
330 (add-hook 'post-command-idle-hook 'mouse-avoidance-fancy-hook) |
7015 | 331 (setq mouse-avoidance-mode mode |
332 mouse-avoidance-state (cons 0 0))) | |
333 ((eq mode 'exile) | |
12940
f7d26ee5ea26
(mouse-avoidance-mode): Use post-command-idle-hook. Use remove-hook.
Richard M. Stallman <rms@gnu.org>
parents:
12082
diff
changeset
|
334 (add-hook 'post-command-idle-hook 'mouse-avoidance-exile-hook) |
7015 | 335 (setq mouse-avoidance-mode mode |
336 mouse-avoidance-state nil)) | |
5119 | 337 ((or (eq mode 'banish) |
338 (eq mode t) | |
339 (and (null mode) (null mouse-avoidance-mode)) | |
340 (and mode (> (prefix-numeric-value mode) 0))) | |
12940
f7d26ee5ea26
(mouse-avoidance-mode): Use post-command-idle-hook. Use remove-hook.
Richard M. Stallman <rms@gnu.org>
parents:
12082
diff
changeset
|
341 (add-hook 'post-command-idle-hook 'mouse-avoidance-banish-hook) |
5119 | 342 (setq mouse-avoidance-mode 'banish)) |
7015 | 343 (t (setq mouse-avoidance-mode nil))) |
344 (force-mode-line-update)) | |
5119 | 345 |
346 (or (assq 'mouse-avoidance-mode minor-mode-alist) | |
347 (setq minor-mode-alist (cons '(mouse-avoidance-mode " Avoid") | |
348 minor-mode-alist))) | |
349 | |
350 ;;; End of avoid.el |