]> code.delx.au - gnu-emacs/blobdiff - lisp/avoid.el
(comint-postoutput-scroll-to-bottom): Cope with unset
[gnu-emacs] / lisp / avoid.el
index 1d80ed9f8c1bf5f3870afa2e9c63d81593e01f4c..0ce9e479229334343760ba900cd2724bb9e77b52 100644 (file)
@@ -89,7 +89,8 @@ You must modify via \\[customize] for this variable to have an effect."
                 (const animate) (const exile) (const proteus)
                 )
   :group 'avoid
-  :require 'avoid)
+  :require 'avoid
+  :version "20.3")
 
 
 (defcustom mouse-avoidance-nudge-dist 15
@@ -267,21 +268,30 @@ redefine this function to suit your own tastes."
 
 (defun mouse-avoidance-banish-hook ()
   (if (and (not executing-kbd-macro)   ; don't check inside macro
-          ;; Don't check while mouse is down.
+          ;; Don't do anything if last event was a mouse event.
           (not (and (consp last-input-event)
                     (symbolp (car last-input-event))
-                    (memq 'down (event-modifiers (car last-input-event)))))
-          (mouse-avoidance-kbd-command (this-command-keys)))
+                    (let ((modifiers (event-modifiers (car last-input-event))))
+                      (or (memq (car last-input-event)
+                                '(mouse-movement scroll-bar-movement))
+                          (memq 'click modifiers)
+                          (memq 'drag modifiers)
+                          (memq 'down modifiers))))))
       (mouse-avoidance-banish-mouse)))
 
 (defun mouse-avoidance-exile-hook ()
   ;; For exile mode, the state is nil when the mouse is in its normal
   ;; position, and set to the old mouse-position when the mouse is in exile.
   (if (and (not executing-kbd-macro)
+          ;; Don't do anything if last event was a mouse event.
           (not (and (consp last-input-event)
                     (symbolp (car last-input-event))
-                    (memq 'down (event-modifiers (car last-input-event)))))
-          (mouse-avoidance-kbd-command (this-command-keys)))
+                    (let ((modifiers (event-modifiers (car last-input-event))))
+                      (or (memq (car last-input-event)
+                                '(mouse-movement scroll-bar-movement))
+                          (memq 'click modifiers)
+                          (memq 'drag modifiers)
+                          (memq 'down modifiers))))))
       (let ((mp (mouse-position)))
        (cond ((and (not mouse-avoidance-state)
                    (mouse-avoidance-too-close-p mp))
@@ -300,10 +310,15 @@ redefine this function to suit your own tastes."
 (defun mouse-avoidance-fancy-hook ()
   ;; Used for the "fancy" modes, ie jump et al.
   (if (and (not executing-kbd-macro)   ; don't check inside macro
+          ;; Don't do anything if last event was a mouse event.
           (not (and (consp last-input-event)
                     (symbolp (car last-input-event))
-                    (memq 'down (event-modifiers (car last-input-event)))))
-          (mouse-avoidance-kbd-command (this-command-keys))
+                    (let ((modifiers (event-modifiers (car last-input-event))))
+                      (or (memq (car last-input-event)
+                                '(mouse-movement scroll-bar-movement))
+                          (memq 'click modifiers)
+                          (memq 'drag modifiers)
+                          (memq 'down modifiers)))))
           (mouse-avoidance-too-close-p (mouse-position)))
       (let ((old-pos (mouse-position)))
        (mouse-avoidance-nudge-mouse)
@@ -311,21 +326,6 @@ redefine this function to suit your own tastes."
            ;; This should never happen.
            (apply 'set-mouse-position old-pos)))))
 
-(defun mouse-avoidance-kbd-command (key)
-  "Return t if the KEYSEQENCE is composed of keyboard events only.
-Return nil if there are any lists in the key sequence."
-  (cond ((null key) nil)               ; Null event seems to be
-                                       ; returned occasionally.
-       ((not (vectorp key)) t)         ; Strings are keyboard events.
-       ((catch 'done
-          (let ((i 0)
-                (l (length key)))
-            (while (< i l)
-              (if (listp (aref key i))
-                  (throw 'done nil))
-              (setq i (1+ i))))
-          t))))
-
 ;;;###autoload
 (defun mouse-avoidance-mode (&optional mode)
   "Set cursor avoidance mode to MODE.