annotate lisp/windmove.el @ 64803:126d8b68ff09

(ada-prj-display-page): Use with-no-warnings.
author Richard M. Stallman <rms@gnu.org>
date Tue, 09 Aug 2005 02:55:43 +0000
parents 41bb365f41c4
children 6c1c6712bea9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 30892
diff changeset
1 ;;; windmove.el --- directional window-selection routines
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2 ;;
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
3 ;; Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004,
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
4 ;; 2005 Free Software Foundation, Inc.
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Author: Hovav Shacham (hovav@cs.stanford.edu)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; Created: 17 October 1998
30892
495502641770 (windmove) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents: 27545
diff changeset
8 ;; Keywords: window, movement, convenience
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; any later version.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 57092
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 57092
diff changeset
25 ;; Boston, MA 02110-1301, USA.
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;; --------------------------------------------------------------------
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;;; Commentary:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; This package defines a set of routines, windmove-{left,up,right,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; down}, for selection of windows in a frame geometrically. For
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; example, `windmove-right' selects the window immediately to the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;; right of the currently-selected one. This functionality is similar
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; to the window-selection controls of the BRIEF editor of yore.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; One subtle point is what happens when the window to the right has
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; been split vertically; for example, consider a call to
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; `windmove-right' in this setup:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;; -------------
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;; | | A |
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; | | |
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;; | |-----
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;; | * | | (* is point in the currently
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; | | B | selected window)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;; | | |
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;; -------------
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;; There are (at least) three reasonable things to do:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;; (1) Always move to the window to the right of the top edge of the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; selected window; in this case, this policy selects A.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;; (2) Always move to the window to the right of the bottom edge of
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; the selected window; in this case, this policy selects B.
30892
495502641770 (windmove) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents: 27545
diff changeset
55 ;; (3) Move to the window to the right of point in the selected
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;; window. This may select either A or B, depending on the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ;; position of point; in the illustrated example, it would select
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;; B.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ;; Similar issues arise for all the movement functions. Windmove
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ;; resolves this problem by allowing the user to specify behavior
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 ;; through a prefix argument. The cases are thus:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 ;; * if no argument is given to the movement functions, or the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 ;; argument given is zero, movement is relative to point;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ;; * if a positive argument is given, movement is relative to the top
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 ;; or left edge of the selected window, depending on whether the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 ;; movement is to be horizontal or vertical;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;; * if a negative argument is given, movement is relative to the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 ;; bottom or right edge of the selected window, depending on whether
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;; the movement is to be horizontal or vertical.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ;; Another feature enables wrap-around mode when the variable
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 ;; `windmove-wrap-around' is set to a non-nil value. In this mode,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 ;; movement that falls off the edge of the frame will wrap around to
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 ;; find the window on the opposite side of the frame. Windmove does
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ;; the Right Thing about the minibuffer; for example, consider:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 ;; -------------
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 ;; | * |
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 ;; |-----------|
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;; | A |
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ;; |-----------| (* is point in the currently
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 ;; | B | C | selected window)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 ;; | | |
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 ;; -------------
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 ;; With wraparound enabled, windmove-down will move to A, while
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 ;; windmove-up will move to the minibuffer if it is active, or to
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 ;; either B or C depending on the prefix argument.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 ;; A set of default keybindings is supplied: shift-{left,up,right,down}
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 ;; invoke the corresponding Windmove function. See the installation
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 ;; section if you wish to use these keybindings.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 ;; Installation:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 ;; Put the following line in your `.emacs' file:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 ;;
45166
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
102 ;; (windmove-default-keybindings) ; shifted arrow keys
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
103 ;;
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
104 ;; or
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
105 ;;
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
106 ;; (windmove-default-keybindings 'hyper) ; etc.
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
107 ;;
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
108 ;; to use another modifier key.
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 ;; If you wish to enable wrap-around, also add a line like:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 ;; (setq windmove-wrap-around t)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 ;; Note: If you have an Emacs that manifests a bug that sometimes
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 ;; causes the occasional creation of a "lost column" between windows,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 ;; so that two adjacent windows do not actually touch, you may want to
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 ;; increase the value of `windmove-window-distance-delta' to 2 or 3:
45166
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
120 ;;
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 ;; (setq windmove-window-distance-delta 2)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 ;; Acknowledgements:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 ;; Special thanks to Julian Assange (proff@iq.org), whose
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 ;; change-windows-intuitively.el predates Windmove, and provided the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 ;; inspiration for it. Kin Cho (kin@symmetrycomm.com) was the first
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 ;; to suggest wrap-around behavior. Thanks also to Gerd Moellmann
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 ;; (gerd@gnu.org) for his comments and suggestions.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 ;;; Code:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 ;; User configurable variables:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 ;; For customize ...
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (defgroup windmove nil
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 "Directional selection of windows in a frame."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 :prefix "windmove-"
30892
495502641770 (windmove) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents: 27545
diff changeset
141 :version "21.1"
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 :group 'windows
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 :group 'convenience)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 (defcustom windmove-wrap-around nil
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 "Whether movement off the edge of the frame wraps around.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 If this variable is set to t, moving left from the leftmost window in
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 a frame will find the rightmost one, and similarly for the other
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 directions. The minibuffer is skipped over in up/down movements if it
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 is inactive."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 :type 'boolean
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 :group 'windmove)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 ;; If your Emacs sometimes places an empty column between two adjacent
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 ;; windows, you may wish to set this delta to 2.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 (defcustom windmove-window-distance-delta 1
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 "How far away from the current window to look for an adjacent window.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 Measured in characters either horizontally or vertically; setting this
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 to a value larger than 1 may be useful in getting around window-
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 placement bugs in old versions of Emacs."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 :type 'number
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 :group 'windmove)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 ;; Implementation overview:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 ;; The conceptual framework behind this code is all fairly simple. We
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 ;; are on one window; we wish to move to another. The correct window
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 ;; to move to is determined by the position of point in the current
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 ;; window as well as the overall window setup.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 ;; Early on, I made the decision to base my implementation around the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 ;; built-in function `window-at'. This function takes a frame-based
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 ;; coordinate, and returns the window that contains it. Using this
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 ;; function, the job of the various top-level windmove functions can
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 ;; be decomposed: first, find the current frame-based location of
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 ;; point; second, manipulate it in some way to give a new location,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 ;; that hopefully falls in the window immediately at left (or right,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 ;; etc.); third, use `window-at' and `select-window' to select the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 ;; window at that new location.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 ;; This is probably not the only possible architecture, and it turns
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 ;; out to have some inherent cruftiness. (Well, okay, the third step
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 ;; is pretty clean....) We will consider each step in turn.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 ;; A quick digression about coordinate frames: most of the functions
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 ;; in the windmove package deal with screen coordinates in one way or
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 ;; another. These coordinates are always relative to some reference
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 ;; points. Window-based coordinates have their reference point in the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 ;; upper-left-hand corner of whatever window is being talked about;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 ;; frame-based coordinates have their reference point in the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 ;; upper-left-hand corner of the entire frame (of which the current
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 ;; window is a component).
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 ;; All coordinates are zero-based, which simply means that the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 ;; reference point (whatever it is) is assigned the value (x=0, y=0).
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 ;; X-coordinates grow down the screen, and Y-coordinates grow towards
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 ;; the right of the screen.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 ;; Okay, back to work. The first step is to gather information about
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 ;; the frame-based coordinates of point, or rather, the reference
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 ;; location. The reference location can be point, or the upper-left,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 ;; or the lower-right corner of the window; the particular one used is
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 ;; controlled by the prefix argument to `windmove-left' and all the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 ;; rest.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 ;; This work is done by `windmove-reference-loc'. It can figure out
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 ;; the locations of the corners by calling `window-edges', but to
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 ;; calculate the frame-based location of point, it calls the workhorse
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 ;; function `windmove-coordinates-of-position', which itself calls the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 ;; incredibly hairy builtin `compute-motion'. There is a good deal of
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 ;; black magic in getting all the arguments to this function just right.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 ;; The second step is more messy. Conceptually, it is fairly simple:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 ;; if we know the reference location, and the coordinates of the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 ;; current window, we can "throw" our reference point just over the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 ;; appropriate edge of the window, and see what other window is
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 ;; there. More explicitly, consider this example from the user
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 ;; documentation above.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 ;; -------------
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 ;; | | A |
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 ;; | | |
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 ;; | |-----
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 ;; | * | | (* is point in the currently
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 ;; | | B | selected window)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 ;; | | |
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 ;; -------------
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 ;; The asterisk marks the reference point; we wish to move right.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 ;; Since we are moving horizontally, the Y coordinate of the new
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 ;; location will be the same. The X coordinate can be such that it is
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 ;; just past the edge of the present window. Obviously, the new point
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 ;; will be inside window B. This in itself is fairly simple: using
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 ;; the result of `windmove-reference-loc' and `window-edges', all the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 ;; necessary math can be performed. (Having said that, there is a
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 ;; good deal of room for off-by-one errors, and Emacs 19.34, at least,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 ;; sometimes manifests a bug where two windows don't actually touch,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 ;; so a larger skip is required.) The actual math here is done by
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 ;; `windmove-other-window-loc'.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 ;; But we can't just pass the result of `windmove-other-window-loc' to
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 ;; `window-at' directly. Why not? Suppose a move would take us off
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 ;; the edge of the screen, say to the left. We want to give a
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 ;; descriptive error message to the user. Or, suppose that a move
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 ;; would place us in the minibuffer. What if the minibuffer is
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 ;; inactive?
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 ;; Actually, the whole subject of the minibuffer edge of the frame is
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 ;; rather messy. It turns out that with a sufficiently large delta,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 ;; we can fly off the bottom edge of the frame and miss the minibuffer
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 ;; altogther. This, I think, is never right: if there's a minibuffer
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 ;; and you're not in it, and you move down, the minibuffer should be
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 ;; in your way.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 ;; (By the way, I'm not totally sure that the code does the right
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 ;; thing in really weird cases, like a frame with no minibuffer.)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 ;; So, what we need is some ways to do constraining and such. The
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 ;; early versions of windmove took a fairly simplistic approach to all
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 ;; this. When I added the wrap-around option, those internals had to
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 ;; be rewritten. After a *lot* of futzing around, I came up with a
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 ;; two-step process that I think is general enough to cover the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 ;; relevant cases. (I'm not totally happy with having to pass the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 ;; window variable as deep as I do, but we can't have everything.)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 ;; In the first phase, we make sure that the new location is sane.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 ;; "Sane" means that we can only fall of the edge of the frame in the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 ;; direction we're moving in, and that we don't miss the minibuffer if
30892
495502641770 (windmove) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents: 27545
diff changeset
272 ;; we're moving down and not already in the minibuffer. The function
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 ;; `windmove-constrain-loc-for-movement' takes care of all this.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 ;; Then, we handle the wraparound, if it's enabled. The function
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 ;; `windmove-wrap-loc-for-movement' takes coordinate values (both X
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 ;; and Y) that fall off the edge of the frame, and replaces them with
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 ;; values on the other side of the frame. It also has special
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 ;; minibuffer-handling code again, because we want to wrap through the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 ;; minibuffer if it's not enabled.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 ;; So, that's it. Seems to work. All of this work is done by the fun
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 ;; function `windmove-find-other-window'.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 ;;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 ;; So, now we have a window to move to (or nil if something's gone
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 ;; wrong). The function `windmove-do-window-select' is the main
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 ;; driver function: it actually does the `select-window'. It is
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 ;; called by four little convenience wrappers, `windmove-left',
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 ;; `windmove-up', `windmove-right', and `windmove-down', which make
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 ;; for convenient keybinding.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 ;; Quick & dirty utility function to add two (x . y) coords.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (defun windmove-coord-add (coord1 coord2)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 "Add the two coordinates.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 Both COORD1 and COORD2 are coordinate cons pairs, (HPOS . VPOS). The
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 result is another coordinate cons pair."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 (cons (+ (car coord1) (car coord2))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (+ (cdr coord1) (cdr coord2))))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (defun windmove-constrain-to-range (n min-n max-n)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 "Ensure that N is between MIN-N and MAX-N inclusive by constraining.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 If N is less than MIN-N, return MIN-N; if greater than MAX-N, return
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 MAX-N."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (max min-n (min n max-n)))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (defun windmove-constrain-around-range (n min-n max-n)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 "Ensure that N is between MIN-N and MAX-N inclusive by wrapping.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 If N is less than MIN-N, return MAX-N; if greater than MAX-N, return
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 MIN-N."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (cond
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 ((< n min-n) max-n)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 ((> n max-n) min-n)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (t n)))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (defun windmove-frame-edges (window)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 "Return (X-MIN Y-MIN X-MAX Y-MAX) for the frame containing WINDOW.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 If WINDOW is nil, return the edges for the selected frame.
39588
62d7faafb853 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
320 \(X-MIN, Y-MIN) is the zero-based coordinate of the top-left corner
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 of the frame; (X-MAX, Y-MAX) is the zero-based coordinate of the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 bottom-right corner of the frame.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 For example, if a frame has 76 rows and 181 columns, the return value
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 from `windmove-frame-edges' will be the list (0 0 180 75)."
51424
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
325 (let* ((frame (if window
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
326 (window-frame window)
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
327 (selected-frame)))
57092
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
328 (top-left (window-edges (frame-first-window frame)))
51424
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
329 (x-min (nth 0 top-left))
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
330 (y-min (nth 1 top-left))
57092
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
331 (x-max (1- (frame-width frame))) ; 1- for last row & col
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
332 (y-max (1- (frame-height frame))))
51424
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
333 (list x-min y-min x-max y-max)))
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 ;; it turns out that constraining is always a good thing, even when
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 ;; wrapping is going to happen. this is because:
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 ;; first, since we disallow exotic diagonal-around-a-corner type
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 ;; movements, so we can always fix the unimportant direction (the one
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 ;; we're not moving in).
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 ;; second, if we're moving down and we're not in the minibuffer, then
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 ;; constraining the y coordinate to max-y is okay, because if that
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 ;; falls in the minibuffer and the minibuffer isn't active, that y
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 ;; coordinate will still be off the bottom of the frame as the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 ;; wrapping function sees it and so will get wrapped around anyway.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (defun windmove-constrain-loc-for-movement (coord window dir)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 "Constrain COORD so that it is reasonable for the given movement.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 This involves two things: first, make sure that the \"off\" coordinate
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 -- the one not being moved on, e.g., y for horizontal movement -- is
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 within frame boundaries; second, if the movement is down and we're not
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 moving from the minibuffer, make sure that the y coordinate does not
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 exceed the frame max-y, so that we don't overshoot the minibuffer
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 accidentally. WINDOW is the window that movement is relative to; DIR
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 is the direction of the movement, one of `left', `up', `right',
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 or `down'.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 Returns the constrained coordinate."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (let ((frame-edges (windmove-frame-edges window))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (in-minibuffer (window-minibuffer-p window)))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 (let ((min-x (nth 0 frame-edges))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 (min-y (nth 1 frame-edges))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 (max-x (nth 2 frame-edges))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 (max-y (nth 3 frame-edges)))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 (let ((new-x
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (if (memq dir '(up down)) ; vertical movement
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (windmove-constrain-to-range (car coord) min-x max-x)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (car coord)))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (new-y
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (if (or (memq dir '(left right)) ; horizontal movement
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (and (eq dir 'down)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 (not in-minibuffer))) ; don't miss minibuffer
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 ;; (technically, we shouldn't constrain on min-y in the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 ;; second case, but this shouldn't do any harm on a
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 ;; down movement.)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 (windmove-constrain-to-range (cdr coord) min-y max-y)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 (cdr coord))))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 (cons new-x new-y)))))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 ;; having constrained in the limited sense of windmove-constrain-loc-
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 ;; for-movement, the wrapping code is actually much simpler than it
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 ;; otherwise would be. the only complication is that we need to check
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 ;; if the minibuffer is active, and, if not, pretend that it's not
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 ;; even part of the frame.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (defun windmove-wrap-loc-for-movement (coord window dir)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 "Takes the constrained COORD and wraps it around for the movement.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 This makes an out-of-range x or y coordinate and wraps it around the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 frame, giving a coordinate (hopefully) in the window on the other edge
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 of the frame. WINDOW is the window that movement is relative to (nil
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 means the currently selected window); DIR is the direction of the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 movement, one of `left', `up', `right',or `down'.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 Returns the wrapped coordinate."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (let* ((frame-edges (windmove-frame-edges window))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (frame-minibuffer (minibuffer-window (if window
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (window-frame window)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (selected-frame))))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (minibuffer-active (minibuffer-window-active-p
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 frame-minibuffer)))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (let ((min-x (nth 0 frame-edges))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (min-y (nth 1 frame-edges))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (max-x (nth 2 frame-edges))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (max-y (if (not minibuffer-active)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (- (nth 3 frame-edges)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (window-height frame-minibuffer))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (nth 3 frame-edges))))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (cons
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (windmove-constrain-around-range (car coord) min-x max-x)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (windmove-constrain-around-range (cdr coord) min-y max-y)))))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 ;; `windmove-coordinates-of-position' is stolen and modified from the
57092
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
410 ;; Emacs 20 Lisp Reference Manual, section 27.2.5. It seems to work
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 ;; okay, although I am bothered by the fact that tab-offset (the cdr
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 ;; of the next-to- last argument) is set to 0. On the other hand, I
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 ;; can't find a single usage of `compute-motion' anywhere that doesn't
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 ;; set this component to zero, and I'm too lazy to grovel through the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 ;; C source to figure out what's happening in the background. there
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 ;; also seems to be a good deal of fun in calculating the correct
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 ;; width of lines for telling `compute-motion' about; in particular,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 ;; it seems we need to subtract 1 (for the continuation column) from
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 ;; the number that `window-width' gives, or continuation lines aren't
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 ;; counted correctly. I haven't seen anyone doing this before,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 ;; though.
57092
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
422 ;;
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
423 ;; Now updated for Emacs 21, based on the Emacs 21 Lisp Reference
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
424 ;; Manual, section 30.2.5. It is no longer necessary to subtract
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
425 ;; 1 for the usable width of the window.
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
426 ;; TODO: also handle minibuffer case, w/ `minibuffer-prompt-width'.
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
427 (defun windmove-coordinates-of-position (pos)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
428 "Return the coordinates of position POS in the current window.
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 Return the window-based coodinates in a cons pair: (HPOS . VPOS),
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 where HPOS and VPOS are the zero-based x and y components of the
57092
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
431 screen location of POS.
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 As an example, if point is in the top left corner of a window, then
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 the return value from `windmove-coordinates-of-position' is (0 . 0)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 regardless of the where point is in the buffer and where the window
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 is placed in the frame."
57092
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
436 (let ((big-hairy-result (compute-motion
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
437 (window-start)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
438 '(0 . 0)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
439 pos
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
440 nil ; (window-width window-height)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
441 nil ; window-width
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
442 (cons (window-hscroll)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
443 0) ; why zero?
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
444 (selected-window))))
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
445 (cons (nth 1 big-hairy-result) ; hpos, not vpos as documented
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
446 (nth 2 big-hairy-result)))) ; vpos, not hpos as documented
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
447
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
448 (defun windmove-coordinates-of-window-position (pos &optional window)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
449 "Return the coordinates of position POS in WINDOW.
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
450 Return the window-based coodinates in a cons pair: (HPOS . VPOS),
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
451 where HPOS and VPOS are the zero-based x and y components of the
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
452 screen location of POS. If WINDOW is nil, return the coordinates in
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
453 the currently selected window."
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
454 (if (null window)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
455 (windmove-coordinates-of-position pos)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
456 (save-selected-window
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
457 (select-window window)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
458 (windmove-coordinates-of-position pos))))
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 ;; This calculates the reference location in the current window: the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 ;; frame-based (x . y) of either point, the top-left, or the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 ;; bottom-right of the window, depending on ARG.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 (defun windmove-reference-loc (&optional arg window)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 "Return the reference location for directional window selection.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 Return a coordinate (HPOS . VPOS) that is frame-based. If ARG is nil
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 or not supplied, the reference point is the buffer's point in the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 currently-selected window, or WINDOW if supplied; otherwise, it is the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 top-left or bottom-right corner of the selected window, or WINDOW if
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 supplied, if ARG is greater or smaller than zero, respectively."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (let ((effective-arg (if (null arg) 0 (prefix-numeric-value arg)))
51424
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
471 (edges (window-inside-edges window)))
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (let ((top-left (cons (nth 0 edges)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 (nth 1 edges)))
51424
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
474 ;; Subtracting 1 converts the edge to the last column or line
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
475 ;; within the window.
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (bottom-right (cons (- (nth 2 edges) 1)
51424
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
477 (- (nth 3 edges) 1))))
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (cond
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 ((> effective-arg 0)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 top-left)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 ((< effective-arg 0)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 bottom-right)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 ((= effective-arg 0)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (windmove-coord-add
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 top-left
57092
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
486 (windmove-coordinates-of-window-position
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
487 (window-point window)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
488 window)))))))
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 ;; This uses the reference location in the current window (calculated
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 ;; by `windmove-reference-loc' above) to find a reference location
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 ;; that will hopefully be in the window we want to move to.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 (defun windmove-other-window-loc (dir &optional arg window)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 "Return a location in the window to be moved to.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 Return value is a frame-based (HPOS . VPOS) value that should be moved
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 to. DIR is one of `left', `up', `right', or `down'; an optional ARG
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 is handled as by `windmove-reference-loc'; WINDOW is the window that
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 movement is relative to."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 (let ((edges (window-edges window)) ; edges: (x0, y0, x1, y1)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (refpoint (windmove-reference-loc arg window))) ; (x . y)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (cond
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 ((eq dir 'left)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (cons (- (nth 0 edges)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 windmove-window-distance-delta)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (cdr refpoint))) ; (x0-d, y)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 ((eq dir 'up)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (cons (car refpoint)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (- (nth 1 edges)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 windmove-window-distance-delta))) ; (x, y0-d)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 ((eq dir 'right)
57092
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
511 (cons (+ (1- (nth 2 edges)) ; -1 to get actual max x
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 windmove-window-distance-delta)
57092
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
513 (cdr refpoint))) ; (x1+d-1, y)
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
514 ((eq dir 'down) ; -1 to get actual max y
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 (cons (car refpoint)
57092
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
516 (+ (1- (nth 3 edges))
5f904f95d7fd (windmove-frame-edges): Report coordinates of
Eli Zaretskii <eliz@gnu.org>
parents: 56587
diff changeset
517 windmove-window-distance-delta))) ; (x, y1+d-1)
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (t (error "Invalid direction of movement: %s" dir)))))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (defun windmove-find-other-window (dir &optional arg window)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 "Return the window object in direction DIR.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 DIR, ARG, and WINDOW are handled as by `windmove-other-window-loc'."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 (let* ((actual-current-window (or window (selected-window)))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 (raw-other-window-loc
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (windmove-other-window-loc dir arg actual-current-window))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 (constrained-other-window-loc
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (windmove-constrain-loc-for-movement raw-other-window-loc
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 actual-current-window
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 dir))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (other-window-loc
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 (if windmove-wrap-around
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (windmove-wrap-loc-for-movement constrained-other-window-loc
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 actual-current-window
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 dir)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 constrained-other-window-loc)))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 (window-at (car other-window-loc)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 (cdr other-window-loc))))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 ;; Selects the window that's hopefully at the location returned by
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 ;; `windmove-other-window-loc', or screams if there's no window there.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (defun windmove-do-window-select (dir &optional arg window)
30892
495502641770 (windmove) <defgroup>: Add :version.
Dave Love <fx@gnu.org>
parents: 27545
diff changeset
543 "Move to the window at direction DIR.
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 DIR, ARG, and WINDOW are handled as by `windmove-other-window-loc'.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 If no window is at direction DIR, an error is signaled."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (let ((other-window (windmove-find-other-window dir arg window)))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (cond ((null other-window)
51424
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
548 (error "No window %s from selected window" dir))
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 ((and (window-minibuffer-p other-window)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (not (minibuffer-window-active-p other-window)))
51424
26d468be5b3c (windmove-reference-loc, windmove-frame-edges): Use window-inside-edges.
Richard M. Stallman <rms@gnu.org>
parents: 45166
diff changeset
551 (error "Minibuffer is inactive"))
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (t
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (select-window other-window)))))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 ;;; end-user functions
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 ;; these are all simple interactive wrappers to `windmove-do-
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 ;; window-select', meant to be bound to keys.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 ;;;###autoload
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 (defun windmove-left (&optional arg)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 "Select the window to the left of the current one.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 With no prefix argument, or with prefix argument equal to zero,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 \"left\" is relative to the position of point in the window; otherwise
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 it is relative to the top edge (for positive ARG) or the bottom edge
39588
62d7faafb853 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
566 \(for negative ARG) of the current window.
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 If no window is at the desired location, an error is signaled."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 (interactive "P")
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 (windmove-do-window-select 'left arg))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 ;;;###autoload
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 (defun windmove-up (&optional arg)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 "Select the window above the current one.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 With no prefix argument, or with prefix argument equal to zero, \"up\"
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 is relative to the position of point in the window; otherwise it is
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 relative to the left edge (for positive ARG) or the right edge (for
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 negative ARG) of the current window.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 If no window is at the desired location, an error is signaled."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (interactive "P")
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 (windmove-do-window-select 'up arg))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 ;;;###autoload
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 (defun windmove-right (&optional arg)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 "Select the window to the right of the current one.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 With no prefix argument, or with prefix argument equal to zero,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 \"right\" is relative to the position of point in the window;
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 otherwise it is relative to the top edge (for positive ARG) or the
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 bottom edge (for negative ARG) of the current window.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589 If no window is at the desired location, an error is signaled."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 (interactive "P")
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591 (windmove-do-window-select 'right arg))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 ;;;###autoload
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 (defun windmove-down (&optional arg)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 "Select the window below the current one.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 With no prefix argument, or with prefix argument equal to zero,
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 \"down\" is relative to the position of point in the window; otherwise
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 it is relative to the left edge (for positive ARG) or the right edge
39588
62d7faafb853 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
599 \(for negative ARG) of the current window.
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 If no window is at the desired location, an error is signaled."
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 (interactive "P")
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 (windmove-do-window-select 'down arg))
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 ;;; set up keybindings
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606 ;; Idea for this function is from iswitchb.el, by Stephen Eglen
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 ;; (stephen@cns.ed.ac.uk).
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608 ;; I don't think these bindings will work on non-X terminals; you
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
609 ;; probably want to use different bindings in that case.
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611 ;;;###autoload
45166
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
612 (defun windmove-default-keybindings (&optional modifier)
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
613 "Set up keybindings for `windmove'.
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
614 Keybindings are of the form MODIFIER-{left,right,up,down}.
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
615 Default MODIFIER is 'shift."
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616 (interactive)
45166
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
617 (unless modifier (setq modifier 'shift))
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
618 (global-set-key (vector (list modifier 'left)) 'windmove-left)
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
619 (global-set-key (vector (list modifier 'right)) 'windmove-right)
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
620 (global-set-key (vector (list modifier 'up)) 'windmove-up)
8de5fa67b6cb (windmove-default-keybindings): Add optional parameter to allow using a
Juanma Barranquero <lekktu@gmail.com>
parents: 39588
diff changeset
621 (global-set-key (vector (list modifier 'down)) 'windmove-down))
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624 (provide 'windmove)
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51424
diff changeset
626 ;;; arch-tag: 56267432-bf1a-4296-a9a0-85c6bd9f2375
27545
ea6b156518f2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 ;;; windmove.el ends here