aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/avoid.el
diff options
context:
space:
mode:
authorJoakim Verona2012-04-26 11:52:04 +0200
committerJoakim Verona2012-04-26 11:52:04 +0200
commitab5b626f97ea7d71a98a06d8cc777fa925a1f716 (patch)
tree7961d0e6b583290e1480771cd0fabd00f4ea7f86 /lisp/avoid.el
parent2ec5843f029c7d55234dbe51d993003b2b3939ec (diff)
parentab036cd7bdd7b087047d241ffb5607d14942179e (diff)
downloademacs-ab5b626f97ea7d71a98a06d8cc777fa925a1f716.tar.gz
emacs-ab5b626f97ea7d71a98a06d8cc777fa925a1f716.zip
upstream partial out of memory
Diffstat (limited to 'lisp/avoid.el')
-rw-r--r--lisp/avoid.el63
1 files changed, 57 insertions, 6 deletions
diff --git a/lisp/avoid.el b/lisp/avoid.el
index 17d99fd6517..eb8a4ad23a2 100644
--- a/lisp/avoid.el
+++ b/lisp/avoid.el
@@ -67,7 +67,7 @@
67 67
68;;; Code: 68;;; Code:
69 69
70(provide 'avoid) 70(eval-when-compile (require 'cl))
71 71
72(defgroup avoid nil 72(defgroup avoid nil
73 "Make mouse pointer stay out of the way of editing." 73 "Make mouse pointer stay out of the way of editing."
@@ -115,6 +115,23 @@ Only applies in Mouse Avoidance modes `animate' and `jump'."
115 :type 'integer 115 :type 'integer
116 :group 'avoid) 116 :group 'avoid)
117 117
118(defcustom mouse-avoidance-banish-position '((frame-or-window . frame)
119 (side . right)
120 (side-pos . 3)
121 (top-or-bottom . top)
122 (top-or-bottom-pos . 0))
123 "Position to which Mouse Avoidance mode `banish' moves the mouse.
124An alist where keywords mean:
125FRAME-OR-WINDOW: banish the mouse to corner of frame or window.
126SIDE: banish the mouse on right or left corner of frame or window.
127SIDE-POS: Distance from right or left edge of frame or window.
128TOP-OR-BOTTOM: banish the mouse to top or bottom of frame or window.
129TOP-OR-BOTTOM-POS: Distance from top or bottom edge of frame or window."
130 :group 'avoid
131 :type '(alist :key-type symbol :value-type symbol)
132 :options '(frame-or-window side (side-pos integer)
133 top-or-bottom (top-or-bottom-pos integer)))
134
118;; Internal variables 135;; Internal variables
119(defvar mouse-avoidance-state nil) 136(defvar mouse-avoidance-state nil)
120(defvar mouse-avoidance-pointer-shapes nil) 137(defvar mouse-avoidance-pointer-shapes nil)
@@ -183,13 +200,45 @@ Acceptable distance is defined by `mouse-avoidance-threshold'."
183 200
184(defun mouse-avoidance-banish-destination () 201(defun mouse-avoidance-banish-destination ()
185 "The position to which Mouse Avoidance mode `banish' moves the mouse. 202 "The position to which Mouse Avoidance mode `banish' moves the mouse.
186You can redefine this if you want the mouse banished to a different corner." 203
187 (let* ((pos (window-edges))) 204If you want the mouse banished to a different corner set
188 (cons (- (nth 2 pos) 2) 205`mouse-avoidance-banish-position' as you need."
189 (nth 1 pos)))) 206 (let* ((fra-or-win (assoc-default
207 'frame-or-window
208 mouse-avoidance-banish-position 'eq))
209 (list-values (case fra-or-win
210 (frame (list 0 0 (frame-width) (frame-height)))
211 (window (window-edges))))
212 (alist (loop for v in list-values
213 for k in '(left top right bottom)
214 collect (cons k v)))
215 (side (assoc-default
216 'side
217 mouse-avoidance-banish-position 'eq))
218 (side-dist (assoc-default
219 'side-pos
220 mouse-avoidance-banish-position 'eq))
221 (top-or-bottom (assoc-default
222 'top-or-bottom
223 mouse-avoidance-banish-position 'eq))
224 (top-or-bottom-dist (assoc-default
225 'top-or-bottom-pos
226 mouse-avoidance-banish-position 'eq))
227 (side-fn (case side
228 (left '+)
229 (right '-)))
230 (top-or-bottom-fn (case top-or-bottom
231 (top '+)
232 (bottom '-))))
233 (cons (funcall side-fn ; -/+
234 (assoc-default side alist 'eq) ; right or left
235 side-dist) ; distance from side
236 (funcall top-or-bottom-fn ; -/+
237 (assoc-default top-or-bottom alist 'eq) ; top/bottom
238 top-or-bottom-dist)))) ; distance from top/bottom
190 239
191(defun mouse-avoidance-banish-mouse () 240(defun mouse-avoidance-banish-mouse ()
192 ;; Put the mouse pointer in the upper-right corner of the current frame. 241 "Put the mouse pointer to `mouse-avoidance-banish-position'."
193 (mouse-avoidance-set-mouse-position (mouse-avoidance-banish-destination))) 242 (mouse-avoidance-set-mouse-position (mouse-avoidance-banish-destination)))
194 243
195(defsubst mouse-avoidance-delta (cur delta dist var min max) 244(defsubst mouse-avoidance-delta (cur delta dist var min max)
@@ -408,4 +457,6 @@ definition of \"random distance\".)"
408(if mouse-avoidance-mode 457(if mouse-avoidance-mode
409 (mouse-avoidance-mode mouse-avoidance-mode)) 458 (mouse-avoidance-mode mouse-avoidance-mode))
410 459
460(provide 'avoid)
461
411;;; avoid.el ends here 462;;; avoid.el ends here