X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/615a3b8d0d2c88cd664f1e0beb5a32b5b8e08f90..0e963201d03d9229bb8ac4323291d2b0119526ed:/lisp/windmove.el diff --git a/lisp/windmove.el b/lisp/windmove.el index 1deaa44c7d..7cfb7d5946 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -1,6 +1,6 @@ ;;; windmove.el --- directional window-selection routines ;; -;; Copyright (C) 1998-2011 Free Software Foundation, Inc. +;; Copyright (C) 1998-2016 Free Software Foundation, Inc. ;; ;; Author: Hovav Shacham (hovav@cs.stanford.edu) ;; Created: 17 October 1998 @@ -94,7 +94,7 @@ ;; Installation: ;; -;; Put the following line in your `.emacs' file: +;; Put the following line in your init file: ;; ;; (windmove-default-keybindings) ; shifted arrow keys ;; @@ -118,7 +118,7 @@ ;; (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 @@ -417,17 +417,17 @@ supplied, if ARG is greater or smaller than zero, respectively." (- (nth 3 edges) 1)))) (cond ((> effective-arg 0) - top-left) + top-left) ((< effective-arg 0) - bottom-right) + bottom-right) ((= 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 @@ -459,24 +459,17 @@ movement is relative to." 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'." - (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) - 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. @@ -486,17 +479,17 @@ DIR, ARG, and WINDOW are handled as by `windmove-other-window-loc'. If no window is at direction DIR, an error is signaled." (let ((other-window (windmove-find-other-window dir arg window))) (cond ((null other-window) - (error "No window %s from selected window" dir)) + (user-error "No window %s from selected window" dir)) ((and (window-minibuffer-p other-window) (not (minibuffer-window-active-p other-window))) - (error "Minibuffer is inactive")) + (user-error "Minibuffer is inactive")) (t (select-window other-window))))) ;;; end-user functions -;; these are all simple interactive wrappers to `windmove-do- -;; window-select', meant to be bound to keys. +;; these are all simple interactive wrappers to +;; `windmove-do-window-select', meant to be bound to keys. ;;;###autoload (defun windmove-left (&optional arg) @@ -553,7 +546,7 @@ If no window is at the desired location, an error is signaled." (defun windmove-default-keybindings (&optional modifier) "Set up keybindings for `windmove'. Keybindings are of the form MODIFIER-{left,right,up,down}. -Default MODIFIER is 'shift." +Default MODIFIER is `shift'." (interactive) (unless modifier (setq modifier 'shift)) (global-set-key (vector (list modifier 'left)) 'windmove-left)