]> code.delx.au - gnu-emacs/blobdiff - lisp/windmove.el
Added checks that distinguish between cygwin and windows in some
[gnu-emacs] / lisp / windmove.el
index 7d5d629d2cb5591e991cd2a800526f982d111a74..fc5e864391c40d7f9f8ebccdfd0bcf18bd3ba004 100644 (file)
@@ -1,10 +1,10 @@
-;; windmove.el -- directional window-selection routines.
+;;; windmove.el --- directional window-selection routines
 ;;
 ;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
 ;;
 ;; Author: Hovav Shacham (hovav@cs.stanford.edu)
 ;; Created: 17 October 1998
-;; Keywords: window, movement
+;; Keywords: window, movement, convenience
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -51,7 +51,7 @@
 ;;     selected window; in this case, this policy selects A.
 ;; (2) Always move to the window to the right of the bottom edge of
 ;;     the selected window; in this case, this policy selects B.
-;; (3) Move to the window to the right of point in the slected
+;; (3) Move to the window to the right of point in the selected
 ;;     window.  This may select either A or B, depending on the
 ;;     position of point; in the illustrated example, it would select
 ;;     B.
 ;;
 ;; Put the following line in your `.emacs' file:
 ;;
-;;     (windmove-default-keybindings)    ; default keybindings
+;;     (windmove-default-keybindings)         ; shifted arrow keys
+;;
+;; or
+;;
+;;     (windmove-default-keybindings 'hyper)  ; etc.
+;;
+;; to use another modifier key.
 ;;
 ;;
 ;; If you wish to enable wrap-around, also add a line like:
 ;; causes the occasional creation of a "lost column" between windows,
 ;; so that two adjacent windows do not actually touch, you may want to
 ;; increase the value of `windmove-window-distance-delta' to 2 or 3:
-;;     
+;;
 ;;     (setq windmove-window-distance-delta 2)
 ;;
 
 ;; to suggest wrap-around behavior.  Thanks also to Gerd Moellmann
 ;; (gerd@gnu.org) for his comments and suggestions.
 
-;; --------------------------------------------------------------------
-
 ;;; Code:
 
 
 (defgroup windmove nil
   "Directional selection of windows in a frame."
   :prefix "windmove-"
+  :version "21.1"
   :group 'windows
   :group 'convenience)
 
@@ -263,7 +268,7 @@ placement bugs in old versions of Emacs."
 ;; In the first phase, we make sure that the new location is sane.
 ;; "Sane" means that we can only fall of the edge of the frame in the
 ;; direction we're moving in, and that we don't miss the minibuffer if
-;; we're moving down and not already in the minibuffer.  The function 
+;; we're moving down and not already in the minibuffer.  The function
 ;; `windmove-constrain-loc-for-movement' takes care of all this.
 ;;
 ;; Then, we handle the wraparound, if it's enabled.  The function
@@ -311,7 +316,7 @@ MIN-N."
 (defun windmove-frame-edges (window)
   "Return (X-MIN Y-MIN X-MAX Y-MAX) for the frame containing WINDOW.
 If WINDOW is nil, return the edges for the selected frame.
-(X-MIN, Y-MIN) is the zero-based coordinate of the top-left corner
+\(X-MIN, Y-MIN) is the zero-based coordinate of the top-left corner
 of the frame; (X-MAX, Y-MAX) is the zero-based coordinate of the
 bottom-right corner of the frame.
 For example, if a frame has 76 rows and 181 columns, the return value
@@ -521,7 +526,7 @@ DIR, ARG, and WINDOW are handled as by `windmove-other-window-loc'."
 ;; Selects the window that's hopefully at the location returned by
 ;; `windmove-other-window-loc', or screams if there's no window there.
 (defun windmove-do-window-select (dir &optional arg window)
-  "Moves to the window at direction DIR.
+  "Move to the window at direction DIR.
 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)))
@@ -544,7 +549,7 @@ If no window is at direction DIR, an error is signaled."
 With no prefix argument, or with prefix argument equal to zero,
 \"left\" is relative to the position of point in the window; otherwise
 it is relative to the top edge (for positive ARG) or the bottom edge
-(for negative ARG) of the current window.
+\(for negative ARG) of the current window.
 If no window is at the desired location, an error is signaled."
   (interactive "P")
   (windmove-do-window-select 'left arg))
@@ -577,7 +582,7 @@ If no window is at the desired location, an error is signaled."
 With no prefix argument, or with prefix argument equal to zero,
 \"down\" is relative to the position of point in the window; otherwise
 it is relative to the left edge (for positive ARG) or the right edge
-(for negative ARG) of the current window.
+\(for negative ARG) of the current window.
 If no window is at the desired location, an error is signaled."
   (interactive "P")
   (windmove-do-window-select 'down arg))
@@ -590,13 +595,16 @@ If no window is at the desired location, an error is signaled."
 ;; probably want to use different bindings in that case.
 
 ;;;###autoload
-(defun windmove-default-keybindings ()
-  "Set up default keybindings for `windmove'."
+(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."
   (interactive)
-  (global-set-key [(shift left)]  'windmove-left)
-  (global-set-key [(shift up)]    'windmove-up)
-  (global-set-key [(shift right)] 'windmove-right)
-  (global-set-key [(shift down)]  'windmove-down))
+  (unless modifier (setq modifier 'shift))
+  (global-set-key (vector (list modifier 'left))  'windmove-left)
+  (global-set-key (vector (list modifier 'right)) 'windmove-right)
+  (global-set-key (vector (list modifier 'up))    'windmove-up)
+  (global-set-key (vector (list modifier 'down))  'windmove-down))
 
 
 (provide 'windmove)