annotate lisp/packages/avoid.el @ 149:538048ae2ab8 r20-3b1

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