diff options
| author | Martin Rudalics | 2013-09-02 09:11:26 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2013-09-02 09:11:26 +0200 |
| commit | f167c27b1973c9f2f7a8755c07f23ea671ba1bf1 (patch) | |
| tree | c05a7fcfdef282b9fea0be17af2dc32a50bee818 | |
| parent | de3d0b572de7b7c03ba3a2c4153d89e50f411da9 (diff) | |
| download | emacs-f167c27b1973c9f2f7a8755c07f23ea671ba1bf1.tar.gz emacs-f167c27b1973c9f2f7a8755c07f23ea671ba1bf1.zip | |
In avoid.el handle case where posn-at-point returns nil.
* avoid.el (mouse-avoidance-point-position)
(mouse-avoidance-too-close-p): Handle case where posn-at-point
returns nil.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/avoid.el | 30 |
2 files changed, 23 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f99a4e8b1fb..c9cdc559a17 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-09-02 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * avoid.el (mouse-avoidance-point-position) | ||
| 4 | (mouse-avoidance-too-close-p): Handle case where posn-at-point | ||
| 5 | returns nil. | ||
| 6 | |||
| 1 | 2013-09-02 Fabián Ezequiel Gallina <fgallina@gnu.org> | 7 | 2013-09-02 Fabián Ezequiel Gallina <fgallina@gnu.org> |
| 2 | 8 | ||
| 3 | * progmodes/python.el (python-shell-completion-get-completions): | 9 | * progmodes/python.el (python-shell-completion-get-completions): |
diff --git a/lisp/avoid.el b/lisp/avoid.el index aaccd0974a4..72f90a30ff5 100644 --- a/lisp/avoid.el +++ b/lisp/avoid.el | |||
| @@ -154,13 +154,15 @@ TOP-OR-BOTTOM-POS: Distance from top or bottom edge of frame or window." | |||
| 154 | (defun mouse-avoidance-point-position () | 154 | (defun mouse-avoidance-point-position () |
| 155 | "Return the position of point as (FRAME X . Y). | 155 | "Return the position of point as (FRAME X . Y). |
| 156 | Analogous to `mouse-position'." | 156 | Analogous to `mouse-position'." |
| 157 | (let ((edges (window-inside-edges)) | 157 | (let* ((edges (window-inside-edges)) |
| 158 | (x-y (posn-x-y (posn-at-point)))) | 158 | (posn-at-point (posn-at-point)) |
| 159 | (cons (selected-frame) | 159 | (x-y (and posn-at-point (posn-x-y posn-at-point)))) |
| 160 | (cons (+ (car edges) | 160 | (when x-y |
| 161 | (/ (car x-y) (frame-char-width))) | 161 | (cons (selected-frame) |
| 162 | (+ (car (cdr edges)) | 162 | (cons (+ (car edges) |
| 163 | (/ (cdr x-y) (frame-char-height))))))) | 163 | (/ (car x-y) (frame-char-width))) |
| 164 | (+ (car (cdr edges)) | ||
| 165 | (/ (cdr x-y) (frame-char-height)))))))) | ||
| 164 | 166 | ||
| 165 | ;(defun mouse-avoidance-point-position-test () | 167 | ;(defun mouse-avoidance-point-position-test () |
| 166 | ; (interactive) | 168 | ; (interactive) |
| @@ -185,19 +187,21 @@ MOUSE is the current mouse position as returned by `mouse-position'. | |||
| 185 | Acceptable distance is defined by `mouse-avoidance-threshold'." | 187 | Acceptable distance is defined by `mouse-avoidance-threshold'." |
| 186 | (let* ((frame (car mouse)) | 188 | (let* ((frame (car mouse)) |
| 187 | (mouse-y (cdr (cdr mouse))) | 189 | (mouse-y (cdr (cdr mouse))) |
| 188 | (tool-bar-lines (frame-parameter nil 'tool-bar-lines))) | 190 | (tool-bar-lines (frame-parameter nil 'tool-bar-lines)) |
| 191 | point) | ||
| 189 | (or tool-bar-lines | 192 | (or tool-bar-lines |
| 190 | (setq tool-bar-lines 0)) | 193 | (setq tool-bar-lines 0)) |
| 191 | (if (and mouse-y (< mouse-y tool-bar-lines)) | 194 | (cond |
| 192 | nil | 195 | ((and mouse-y (< mouse-y tool-bar-lines)) |
| 193 | (let ((point (mouse-avoidance-point-position)) | 196 | nil) |
| 194 | (mouse-x (car (cdr mouse)))) | 197 | ((setq point (mouse-avoidance-point-position)) |
| 198 | (let ((mouse-x (car (cdr mouse)))) | ||
| 195 | (and (eq frame (car point)) | 199 | (and (eq frame (car point)) |
| 196 | (not (null mouse-x)) | 200 | (not (null mouse-x)) |
| 197 | (< (abs (- mouse-x (car (cdr point)))) | 201 | (< (abs (- mouse-x (car (cdr point)))) |
| 198 | mouse-avoidance-threshold) | 202 | mouse-avoidance-threshold) |
| 199 | (< (abs (- mouse-y (cdr (cdr point)))) | 203 | (< (abs (- mouse-y (cdr (cdr point)))) |
| 200 | mouse-avoidance-threshold)))))) | 204 | mouse-avoidance-threshold))))))) |
| 201 | 205 | ||
| 202 | (defun mouse-avoidance-banish-destination () | 206 | (defun mouse-avoidance-banish-destination () |
| 203 | "The position to which Mouse Avoidance mode `banish' moves the mouse. | 207 | "The position to which Mouse Avoidance mode `banish' moves the mouse. |