remove sigio blocking
[bpt/emacs.git] / lisp / windmove.el
index 7757417..ff41ebb 100644 (file)
@@ -1,7 +1,6 @@
 ;;; windmove.el --- directional window-selection routines
 ;;
 ;;; windmove.el --- directional window-selection routines
 ;;
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2014 Free Software Foundation, Inc.
 ;;
 ;; Author: Hovav Shacham (hovav@cs.stanford.edu)
 ;; Created: 17 October 1998
 ;;
 ;; Author: Hovav Shacham (hovav@cs.stanford.edu)
 ;; Created: 17 October 1998
@@ -95,7 +94,7 @@
 
 ;; Installation:
 ;;
 
 ;; Installation:
 ;;
-;; Put the following line in your `.emacs' file:
+;; Put the following line in your init file:
 ;;
 ;;     (windmove-default-keybindings)         ; shifted arrow keys
 ;;
 ;;
 ;;     (windmove-default-keybindings)         ; shifted arrow keys
 ;;
 ;;     (setq windmove-window-distance-delta 2)
 ;;
 
 ;;     (setq windmove-window-distance-delta 2)
 ;;
 
-;; Acknowledgements:
+;; Acknowledgments:
 ;;
 ;; Special thanks to Julian Assange (proff@iq.org), whose
 ;; change-windows-intuitively.el predates Windmove, and provided the
 ;;
 ;; Special thanks to Julian Assange (proff@iq.org), whose
 ;; change-windows-intuitively.el predates Windmove, and provided the
@@ -246,7 +245,7 @@ placement bugs in old versions of Emacs."
 ;; Actually, the whole subject of the minibuffer edge of the frame is
 ;; rather messy.  It turns out that with a sufficiently large delta,
 ;; we can fly off the bottom edge of the frame and miss the minibuffer
 ;; Actually, the whole subject of the minibuffer edge of the frame is
 ;; rather messy.  It turns out that with a sufficiently large delta,
 ;; we can fly off the bottom edge of the frame and miss the minibuffer
-;; altogther.  This, I think, is never right: if there's a minibuffer
+;; altogether.  This, I think, is never right: if there's a minibuffer
 ;; and you're not in it, and you move down, the minibuffer should be
 ;; in your way.
 ;;
 ;; and you're not in it, and you move down, the minibuffer should be
 ;; in your way.
 ;;
@@ -374,14 +373,12 @@ Returns the constrained coordinate."
 ;; otherwise would be.  the only complication is that we need to check
 ;; if the minibuffer is active, and, if not, pretend that it's not
 ;; even part of the frame.
 ;; otherwise would be.  the only complication is that we need to check
 ;; if the minibuffer is active, and, if not, pretend that it's not
 ;; even part of the frame.
-(defun windmove-wrap-loc-for-movement (coord window dir)
+(defun windmove-wrap-loc-for-movement (coord window)
   "Takes the constrained COORD and wraps it around for the movement.
 This makes an out-of-range x or y coordinate and wraps it around the
 frame, giving a coordinate (hopefully) in the window on the other edge
 of the frame.  WINDOW is the window that movement is relative to (nil
   "Takes the constrained COORD and wraps it around for the movement.
 This makes an out-of-range x or y coordinate and wraps it around the
 frame, giving a coordinate (hopefully) in the window on the other edge
 of the frame.  WINDOW is the window that movement is relative to (nil
-means the currently selected window); DIR is the direction of the
-movement, one of `left', `up', `right',or `down'.
-Returns the wrapped coordinate."
+means the currently selected window).  Returns the wrapped coordinate."
   (let* ((frame-edges (windmove-frame-edges window))
          (frame-minibuffer (minibuffer-window (if window
                                                   (window-frame window)
   (let* ((frame-edges (windmove-frame-edges window))
          (frame-minibuffer (minibuffer-window (if window
                                                   (window-frame window)
@@ -420,17 +417,17 @@ supplied, if ARG is greater or smaller than zero, respectively."
                               (- (nth 3 edges) 1))))
       (cond
        ((> effective-arg 0)
                               (- (nth 3 edges) 1))))
       (cond
        ((> effective-arg 0)
-          top-left)
+       top-left)
        ((< effective-arg 0)
        ((< effective-arg 0)
-          bottom-right)
+       bottom-right)
        ((= effective-arg 0)
        ((= effective-arg 0)
-          (windmove-coord-add
-             top-left
-            (let ((col-row
-                   (posn-col-row
-                    (posn-at-point (window-point window) window))))
-              (cons (- (car col-row) (window-hscroll window))
-                    (cdr col-row)))))))))
+       (windmove-coord-add
+        top-left
+        ;; Don't care whether window is horizontally scrolled -
+        ;; `posn-at-point' handles that already.  See also:
+        ;; http://lists.gnu.org/archive/html/emacs-devel/2012-01/msg00638.html
+        (posn-col-row
+         (posn-at-point (window-point window) window))))))))
 
 ;; This uses the reference location in the current window (calculated
 ;; by `windmove-reference-loc' above) to find a reference location
 
 ;; This uses the reference location in the current window (calculated
 ;; by `windmove-reference-loc' above) to find a reference location
@@ -462,25 +459,17 @@ movement is relative to."
                windmove-window-distance-delta))) ; (x, y1+d-1)
      (t (error "Invalid direction of movement: %s" dir)))))
 
                windmove-window-distance-delta))) ; (x, y1+d-1)
      (t (error "Invalid direction of movement: %s" dir)))))
 
+;; Rewritten on 2013-12-13 using `window-in-direction'.  After the
+;; pixelwise change the old approach didn't work any more.  martin
 (defun windmove-find-other-window (dir &optional arg window)
   "Return the window object in direction DIR.
 DIR, ARG, and WINDOW are handled as by `windmove-other-window-loc'."
 (defun windmove-find-other-window (dir &optional arg window)
   "Return the window object in direction DIR.
 DIR, ARG, and WINDOW are handled as by `windmove-other-window-loc'."
-  (let* ((actual-current-window (or window (selected-window)))
-         (raw-other-window-loc
-          (windmove-other-window-loc dir arg actual-current-window))
-         (constrained-other-window-loc
-          (windmove-constrain-loc-for-movement raw-other-window-loc
-                                               actual-current-window
-                                               dir))
-         (other-window-loc
-          (if windmove-wrap-around
-            (windmove-wrap-loc-for-movement constrained-other-window-loc
-                                            actual-current-window
-                                            dir)
-            constrained-other-window-loc)))
-    (window-at (car other-window-loc)
-               (cdr other-window-loc))))
-
+  (window-in-direction
+   (cond
+    ((eq dir 'up) 'above)
+    ((eq dir 'down) 'below)
+    (t dir))
+   window nil arg windmove-wrap-around t))
 
 ;; Selects the window that's hopefully at the location returned by
 ;; `windmove-other-window-loc', or screams if there's no window there.
 
 ;; Selects the window that's hopefully at the location returned by
 ;; `windmove-other-window-loc', or screams if there's no window there.
@@ -568,5 +557,4 @@ Default MODIFIER is 'shift."
 
 (provide 'windmove)
 
 
 (provide 'windmove)
 
-;; arch-tag: 56267432-bf1a-4296-a9a0-85c6bd9f2375
 ;;; windmove.el ends here
 ;;; windmove.el ends here