Mercurial > emacs
annotate lispref/windows.texi @ 23577:36cccf1ba0a9
(Fchar_after): Fix type clashes.
author | Andreas Schwab <schwab@suse.de> |
---|---|
date | Fri, 30 Oct 1998 10:13:41 +0000 |
parents | dfac7398266b |
children | 467b88fab665 |
rev | line source |
---|---|
6564 | 1 @c -*-texinfo-*- |
2 @c This is part of the GNU Emacs Lisp Reference Manual. | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc. |
6564 | 4 @c See the file elisp.texi for copying conditions. |
5 @setfilename ../info/windows | |
6 @node Windows, Frames, Buffers, Top | |
7 @chapter Windows | |
8 | |
9 This chapter describes most of the functions and variables related to | |
10 Emacs windows. See @ref{Display}, for information on how text is | |
11 displayed in windows. | |
12 | |
13 @menu | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
14 * Basic Windows:: Basic information on using windows. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
15 * Splitting Windows:: Splitting one window into two windows. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
16 * Deleting Windows:: Deleting a window gives its space to other windows. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
17 * Selecting Windows:: The selected window is the one that you edit in. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
18 * Cyclic Window Ordering:: Moving around the existing windows. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
19 * Buffers and Windows:: Each window displays the contents of a buffer. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
20 * Displaying Buffers:: Higher-lever functions for displaying a buffer |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
21 and choosing a window for it. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
22 * Choosing Window:: How to choose a window for displaying a buffer. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
23 * Window Point:: Each window has its own location of point. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
24 * Window Start:: The display-start position controls which text |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
25 is on-screen in the window. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
26 * Vertical Scrolling:: Moving text up and down in the window. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
27 * Horizontal Scrolling:: Moving text sideways on the window. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
28 * Size of Window:: Accessing the size of a window. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
29 * Resizing Windows:: Changing the size of a window. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
30 * Coordinates and Windows:: Converting coordinates to windows. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
31 * Window Configurations:: Saving and restoring the state of the screen. |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
32 * Window Hooks:: Hooks for scrolling, window size changes, |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
33 redisplay going past a certain point, |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
34 or window configuration changes. |
6564 | 35 @end menu |
36 | |
37 @node Basic Windows | |
38 @section Basic Concepts of Emacs Windows | |
39 @cindex window | |
40 @cindex selected window | |
41 | |
12098 | 42 A @dfn{window} in Emacs is the physical area of the screen in which a |
43 buffer is displayed. The term is also used to refer to a Lisp object that | |
6564 | 44 represents that screen area in Emacs Lisp. It should be |
45 clear from the context which is meant. | |
46 | |
12098 | 47 Emacs groups windows into frames. A frame represents an area of |
48 screen available for Emacs to use. Each frame always contains at least | |
49 one window, but you can subdivide it vertically or horizontally into | |
50 multiple nonoverlapping Emacs windows. | |
6564 | 51 |
12098 | 52 In each frame, at any time, one and only one window is designated as |
53 @dfn{selected within the frame}. The frame's cursor appears in that | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
54 window. At any time, one frame is the selected frame; and the window |
12098 | 55 selected within that frame is @dfn{the selected window}. The selected |
56 window's buffer is usually the current buffer (except when | |
57 @code{set-buffer} has been used). @xref{Current Buffer}. | |
58 | |
59 For practical purposes, a window exists only while it is displayed in | |
60 a frame. Once removed from the frame, the window is effectively deleted | |
61 and should not be used, @emph{even though there may still be references | |
62 to it} from other Lisp objects. Restoring a saved window configuration | |
63 is the only way for a window no longer on the screen to come back to | |
64 life. (@xref{Deleting Windows}.) | |
6564 | 65 |
66 Each window has the following attributes: | |
67 | |
68 @itemize @bullet | |
69 @item | |
70 containing frame | |
71 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
72 @item |
6564 | 73 window height |
74 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
75 @item |
6564 | 76 window width |
77 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
78 @item |
6564 | 79 window edges with respect to the screen or frame |
80 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
81 @item |
6564 | 82 the buffer it displays |
83 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
84 @item |
6564 | 85 position within the buffer at the upper left of the window |
86 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
87 @item |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
88 amount of horizontal scrolling, in columns |
6564 | 89 |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
90 @item |
6564 | 91 point |
92 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
93 @item |
6564 | 94 the mark |
95 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
96 @item |
6564 | 97 how recently the window was selected |
98 @end itemize | |
99 | |
100 @cindex multiple windows | |
101 Users create multiple windows so they can look at several buffers at | |
102 once. Lisp libraries use multiple windows for a variety of reasons, but | |
12098 | 103 most often to display related information. In Rmail, for example, you |
104 can move through a summary buffer in one window while the other window | |
105 shows messages one at a time as they are reached. | |
6564 | 106 |
107 The meaning of ``window'' in Emacs is similar to what it means in the | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
108 context of general-purpose window systems such as X, but not identical. |
12098 | 109 The X Window System places X windows on the screen; Emacs uses one or |
110 more X windows as frames, and subdivides them into | |
111 Emacs windows. When you use Emacs on a character-only terminal, Emacs | |
112 treats the whole terminal screen as one frame. | |
6564 | 113 |
114 @cindex terminal screen | |
115 @cindex screen of terminal | |
116 @cindex tiled windows | |
117 Most window systems support arbitrarily located overlapping windows. | |
118 In contrast, Emacs windows are @dfn{tiled}; they never overlap, and | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
119 together they fill the whole screen or frame. Because of the way in |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
120 which Emacs creates new windows and resizes them, not all conceivable |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
121 tilings of windows on an Emacs frame are actually possible. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
122 @xref{Splitting Windows}, and @ref{Size of Window}. |
6564 | 123 |
124 @xref{Display}, for information on how the contents of the | |
125 window's buffer are displayed in the window. | |
126 | |
127 @defun windowp object | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
128 This function returns @code{t} if @var{object} is a window. |
6564 | 129 @end defun |
130 | |
131 @node Splitting Windows | |
132 @section Splitting Windows | |
133 @cindex splitting windows | |
134 @cindex window splitting | |
135 | |
136 The functions described here are the primitives used to split a window | |
137 into two windows. Two higher level functions sometimes split a window, | |
138 but not always: @code{pop-to-buffer} and @code{display-buffer} | |
139 (@pxref{Displaying Buffers}). | |
140 | |
141 The functions described here do not accept a buffer as an argument. | |
142 The two ``halves'' of the split window initially display the same buffer | |
143 previously visible in the window that was split. | |
144 | |
145 @deffn Command split-window &optional window size horizontal | |
146 This function splits @var{window} into two windows. The original | |
147 window @var{window} remains the selected window, but occupies only | |
148 part of its former screen area. The rest is occupied by a newly created | |
149 window which is returned as the value of this function. | |
150 | |
151 If @var{horizontal} is non-@code{nil}, then @var{window} splits into | |
152 two side by side windows. The original window @var{window} keeps the | |
153 leftmost @var{size} columns, and gives the rest of the columns to the | |
154 new window. Otherwise, it splits into windows one above the other, and | |
155 @var{window} keeps the upper @var{size} lines and gives the rest of the | |
156 lines to the new window. The original window is therefore the | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
157 left-hand or upper of the two, and the new window is the right-hand or |
6564 | 158 lower. |
159 | |
160 If @var{window} is omitted or @code{nil}, then the selected window is | |
161 split. If @var{size} is omitted or @code{nil}, then @var{window} is | |
162 divided evenly into two parts. (If there is an odd line, it is | |
163 allocated to the new window.) When @code{split-window} is called | |
164 interactively, all its arguments are @code{nil}. | |
165 | |
166 The following example starts with one window on a screen that is 50 | |
167 lines high by 80 columns wide; then the window is split. | |
168 | |
169 @smallexample | |
170 @group | |
171 (setq w (selected-window)) | |
172 @result{} #<window 8 on windows.texi> | |
173 (window-edges) ; @r{Edges in order:} | |
174 @result{} (0 0 80 50) ; @r{left--top--right--bottom} | |
175 @end group | |
176 | |
177 @group | |
178 ;; @r{Returns window created} | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
179 (setq w2 (split-window w 15)) |
6564 | 180 @result{} #<window 28 on windows.texi> |
181 @end group | |
182 @group | |
183 (window-edges w2) | |
184 @result{} (0 15 80 50) ; @r{Bottom window;} | |
185 ; @r{top is line 15} | |
186 @end group | |
187 @group | |
188 (window-edges w) | |
189 @result{} (0 0 80 15) ; @r{Top window} | |
190 @end group | |
191 @end smallexample | |
192 | |
193 The screen looks like this: | |
194 | |
195 @smallexample | |
196 @group | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
197 __________ |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
198 | | line 0 |
6564 | 199 | w | |
200 |__________| | |
201 | | line 15 | |
202 | w2 | | |
203 |__________| | |
204 line 50 | |
205 column 0 column 80 | |
206 @end group | |
207 @end smallexample | |
208 | |
209 Next, the top window is split horizontally: | |
210 | |
211 @smallexample | |
212 @group | |
213 (setq w3 (split-window w 35 t)) | |
214 @result{} #<window 32 on windows.texi> | |
215 @end group | |
216 @group | |
217 (window-edges w3) | |
218 @result{} (35 0 80 15) ; @r{Left edge at column 35} | |
219 @end group | |
220 @group | |
221 (window-edges w) | |
222 @result{} (0 0 35 15) ; @r{Right edge at column 35} | |
223 @end group | |
224 @group | |
225 (window-edges w2) | |
226 @result{} (0 15 80 50) ; @r{Bottom window unchanged} | |
227 @end group | |
228 @end smallexample | |
229 | |
12282
586e3ea81792
updates for version 19.29 made by melissa; also needed to check out files
Melissa Weisshaus <melissa@gnu.org>
parents:
12125
diff
changeset
|
230 @need 3000 |
6564 | 231 Now, the screen looks like this: |
232 | |
233 @smallexample | |
234 @group | |
235 column 35 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
236 __________ |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
237 | | | line 0 |
6564 | 238 | w | w3 | |
239 |___|______| | |
240 | | line 15 | |
241 | w2 | | |
242 |__________| | |
243 line 50 | |
244 column 0 column 80 | |
245 @end group | |
246 @end smallexample | |
8926 | 247 |
248 Normally, Emacs indicates the border between two side-by-side windows | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
249 with a scroll bar (@pxref{Window Frame Parameters,Scroll Bars}) or @samp{|} |
8926 | 250 characters. The display table can specify alternative border |
251 characters; see @ref{Display Tables}. | |
6564 | 252 @end deffn |
253 | |
254 @deffn Command split-window-vertically size | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
255 This function splits the selected window into two windows, one above the |
22267
dfac7398266b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22252
diff
changeset
|
256 other, leaving the upper of the two windows selected, with @var{size} |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
257 lines. (If @var{size} is negative, then the lower of the two windows |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
258 gets @minus{} @var{size} lines and the upper window gets the rest, but |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
259 the upper window is still the one selected.) |
6564 | 260 |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
261 This function is simply an interface to @code{split-window}. |
6564 | 262 Here is the complete function definition for it: |
263 | |
264 @smallexample | |
265 @group | |
266 (defun split-window-vertically (&optional arg) | |
16736
981e116b4ac6
Minor cleanups for overfull hboxes.
Richard M. Stallman <rms@gnu.org>
parents:
15668
diff
changeset
|
267 "Split current window into two windows, @dots{}" |
6564 | 268 (interactive "P") |
269 (split-window nil (and arg (prefix-numeric-value arg)))) | |
270 @end group | |
271 @end smallexample | |
272 @end deffn | |
273 | |
274 @deffn Command split-window-horizontally size | |
275 This function splits the selected window into two windows | |
276 side-by-side, leaving the selected window with @var{size} columns. | |
277 | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
278 This function is simply an interface to @code{split-window}. Here is |
6564 | 279 the complete definition for @code{split-window-horizontally} (except for |
280 part of the documentation string): | |
281 | |
282 @smallexample | |
283 @group | |
284 (defun split-window-horizontally (&optional arg) | |
285 "Split selected window into two windows, side by side..." | |
286 (interactive "P") | |
287 (split-window nil (and arg (prefix-numeric-value arg)) t)) | |
288 @end group | |
289 @end smallexample | |
290 @end deffn | |
291 | |
292 @defun one-window-p &optional no-mini all-frames | |
293 This function returns non-@code{nil} if there is only one window. The | |
294 argument @var{no-mini}, if non-@code{nil}, means don't count the | |
295 minibuffer even if it is active; otherwise, the minibuffer window is | |
12125
995be67f3fd1
updates for version 19.29.
Melissa Weisshaus <melissa@gnu.org>
parents:
12099
diff
changeset
|
296 included, if active, in the total number of windows, which is compared |
6564 | 297 against one. |
298 | |
299 The argument @var{all-frames} specifies which frames to consider. Here | |
300 are the possible values and their meanings: | |
301 | |
302 @table @asis | |
303 @item @code{nil} | |
304 Count the windows in the selected frame, plus the minibuffer used | |
305 by that frame even if it lies in some other frame. | |
306 | |
307 @item @code{t} | |
308 Count all windows in all existing frames. | |
309 | |
310 @item @code{visible} | |
311 Count all windows in all visible frames. | |
312 | |
12098 | 313 @item 0 |
314 Count all windows in all visible or iconified frames. | |
315 | |
6564 | 316 @item anything else |
317 Count precisely the windows in the selected frame, and no others. | |
318 @end table | |
319 @end defun | |
320 | |
321 @node Deleting Windows | |
322 @section Deleting Windows | |
323 @cindex deleting windows | |
324 | |
325 A window remains visible on its frame unless you @dfn{delete} it by | |
326 calling certain functions that delete windows. A deleted window cannot | |
327 appear on the screen, but continues to exist as a Lisp object until | |
328 there are no references to it. There is no way to cancel the deletion | |
329 of a window aside from restoring a saved window configuration | |
330 (@pxref{Window Configurations}). Restoring a window configuration also | |
331 deletes any windows that aren't part of that configuration. | |
332 | |
333 When you delete a window, the space it took up is given to one | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
334 adjacent sibling. |
6564 | 335 |
336 @c Emacs 19 feature | |
337 @defun window-live-p window | |
338 This function returns @code{nil} if @var{window} is deleted, and | |
339 @code{t} otherwise. | |
340 | |
7735
7db892210924
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7082
diff
changeset
|
341 @strong{Warning:} Erroneous information or fatal errors may result from |
6564 | 342 using a deleted window as if it were live. |
343 @end defun | |
344 | |
345 @deffn Command delete-window &optional window | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
346 This function removes @var{window} from display, and returns @code{nil}. |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
347 If @var{window} is omitted, then the selected window is deleted. An |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
348 error is signaled if there is only one window when @code{delete-window} |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
349 is called. |
6564 | 350 @end deffn |
351 | |
352 @deffn Command delete-other-windows &optional window | |
353 This function makes @var{window} the only window on its frame, by | |
354 deleting the other windows in that frame. If @var{window} is omitted or | |
355 @code{nil}, then the selected window is used by default. | |
356 | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
357 The return value is @code{nil}. |
6564 | 358 @end deffn |
359 | |
360 @deffn Command delete-windows-on buffer &optional frame | |
361 This function deletes all windows showing @var{buffer}. If there are | |
362 no windows showing @var{buffer}, it does nothing. | |
363 | |
364 @code{delete-windows-on} operates frame by frame. If a frame has | |
365 several windows showing different buffers, then those showing | |
366 @var{buffer} are removed, and the others expand to fill the space. If | |
367 all windows in some frame are showing @var{buffer} (including the case | |
368 where there is only one window), then the frame reverts to having a | |
369 single window showing another buffer chosen with @code{other-buffer}. | |
370 @xref{The Buffer List}. | |
371 | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
372 The argument @var{frame} controls which frames to operate on. This |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
373 function does not use it in quite the same way as the other functions |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
374 which scan all windows; specifically, the values @code{t} and @code{nil} |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
375 have the opposite of their meanings in other functions. Here are the |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
376 full details: |
6564 | 377 |
378 @itemize @bullet | |
379 @item | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
380 If it is @code{nil}, operate on all frames. |
6564 | 381 @item |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
382 If it is @code{t}, operate on the selected frame. |
6564 | 383 @item |
384 If it is @code{visible}, operate on all visible frames. | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
385 @item |
12098 | 386 If it is 0, operate on all visible or iconified frames. |
6564 | 387 @item |
388 If it is a frame, operate on that frame. | |
389 @end itemize | |
390 | |
391 This function always returns @code{nil}. | |
392 @end deffn | |
393 | |
394 @node Selecting Windows | |
395 @section Selecting Windows | |
396 @cindex selecting windows | |
397 | |
398 When a window is selected, the buffer in the window becomes the current | |
399 buffer, and the cursor will appear in it. | |
400 | |
401 @defun selected-window | |
402 This function returns the selected window. This is the window in | |
403 which the cursor appears and to which many commands apply. | |
404 @end defun | |
405 | |
406 @defun select-window window | |
407 This function makes @var{window} the selected window. The cursor then | |
408 appears in @var{window} (on redisplay). The buffer being displayed in | |
409 @var{window} is immediately designated the current buffer. | |
410 | |
411 The return value is @var{window}. | |
412 | |
413 @example | |
414 @group | |
415 (setq w (next-window)) | |
416 (select-window w) | |
417 @result{} #<window 65 on windows.texi> | |
418 @end group | |
419 @end example | |
420 @end defun | |
421 | |
12098 | 422 @defmac save-selected-window forms@dots{} |
423 This macro records the selected window, executes @var{forms} | |
424 in sequence, then restores the earlier selected window. | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
425 |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
426 This macro does not save or restore anything about the sizes, arrangement |
12098 | 427 or contents of windows; therefore, if the @var{forms} change them, |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
428 the change persists. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
429 |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
430 Each frame, at any time, has a window selected within the frame. This |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
431 macro saves only @emph{the} selected window; it does not save anything |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
432 about other frames. If the @var{forms} select some other frame and |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
433 alter the window selected within it, the change persists. |
12098 | 434 @end defmac |
435 | |
6564 | 436 @cindex finding windows |
437 The following functions choose one of the windows on the screen, | |
438 offering various criteria for the choice. | |
439 | |
440 @defun get-lru-window &optional frame | |
441 This function returns the window least recently ``used'' (that is, | |
442 selected). The selected window is always the most recently used window. | |
443 | |
444 The selected window can be the least recently used window if it is the | |
445 only window. A newly created window becomes the least recently used | |
446 window until it is selected. A minibuffer window is never a candidate. | |
447 | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
448 The argument @var{frame} controls which windows are considered. |
6564 | 449 |
450 @itemize @bullet | |
451 @item | |
452 If it is @code{nil}, consider windows on the selected frame. | |
453 @item | |
454 If it is @code{t}, consider windows on all frames. | |
455 @item | |
456 If it is @code{visible}, consider windows on all visible frames. | |
457 @item | |
12098 | 458 If it is 0, consider windows on all visible or iconified frames. |
459 @item | |
6564 | 460 If it is a frame, consider windows on that frame. |
461 @end itemize | |
462 @end defun | |
463 | |
464 @defun get-largest-window &optional frame | |
465 This function returns the window with the largest area (height times | |
466 width). If there are no side-by-side windows, then this is the window | |
467 with the most lines. A minibuffer window is never a candidate. | |
468 | |
469 If there are two windows of the same size, then the function returns | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
470 the window that is first in the cyclic ordering of windows (see |
6564 | 471 following section), starting from the selected window. |
472 | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
473 The argument @var{frame} controls which set of windows to |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
474 consider. See @code{get-lru-window}, above. |
6564 | 475 @end defun |
476 | |
477 @node Cyclic Window Ordering | |
478 @comment node-name, next, previous, up | |
479 @section Cyclic Ordering of Windows | |
480 @cindex cyclic ordering of windows | |
481 @cindex ordering of windows, cyclic | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
482 @cindex window ordering, cyclic |
6564 | 483 |
484 When you use the command @kbd{C-x o} (@code{other-window}) to select | |
485 the next window, it moves through all the windows on the screen in a | |
486 specific cyclic order. For any given configuration of windows, this | |
487 order never varies. It is called the @dfn{cyclic ordering of windows}. | |
488 | |
489 This ordering generally goes from top to bottom, and from left to | |
490 right. But it may go down first or go right first, depending on the | |
491 order in which the windows were split. | |
492 | |
493 If the first split was vertical (into windows one above each other), | |
494 and then the subwindows were split horizontally, then the ordering is | |
495 left to right in the top of the frame, and then left to right in the | |
496 next lower part of the frame, and so on. If the first split was | |
497 horizontal, the ordering is top to bottom in the left part, and so on. | |
498 In general, within each set of siblings at any level in the window tree, | |
499 the order is left to right, or top to bottom. | |
500 | |
501 @defun next-window &optional window minibuf all-frames | |
502 @cindex minibuffer window | |
503 This function returns the window following @var{window} in the cyclic | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
504 ordering of windows. This is the window that @kbd{C-x o} would select |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
505 if typed when @var{window} is selected. If @var{window} is the only |
6564 | 506 window visible, then this function returns @var{window}. If omitted, |
507 @var{window} defaults to the selected window. | |
508 | |
509 The value of the argument @var{minibuf} determines whether the | |
510 minibuffer is included in the window order. Normally, when | |
511 @var{minibuf} is @code{nil}, the minibuffer is included if it is | |
512 currently active; this is the behavior of @kbd{C-x o}. (The minibuffer | |
513 window is active while the minibuffer is in use. @xref{Minibuffers}.) | |
514 | |
515 If @var{minibuf} is @code{t}, then the cyclic ordering includes the | |
516 minibuffer window even if it is not active. | |
517 | |
518 If @var{minibuf} is neither @code{t} nor @code{nil}, then the minibuffer | |
519 window is not included even if it is active. | |
520 | |
521 The argument @var{all-frames} specifies which frames to consider. Here | |
522 are the possible values and their meanings: | |
523 | |
524 @table @asis | |
525 @item @code{nil} | |
526 Consider all the windows in @var{window}'s frame, plus the minibuffer | |
527 used by that frame even if it lies in some other frame. | |
528 | |
529 @item @code{t} | |
530 Consider all windows in all existing frames. | |
531 | |
532 @item @code{visible} | |
533 Consider all windows in all visible frames. (To get useful results, you | |
534 must ensure @var{window} is in a visible frame.) | |
535 | |
12099 | 536 @item 0 |
12098 | 537 Consider all windows in all visible or iconified frames. |
538 | |
6564 | 539 @item anything else |
540 Consider precisely the windows in @var{window}'s frame, and no others. | |
541 @end table | |
542 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
543 This example assumes there are two windows, both displaying the |
6564 | 544 buffer @samp{windows.texi}: |
545 | |
546 @example | |
547 @group | |
548 (selected-window) | |
549 @result{} #<window 56 on windows.texi> | |
550 @end group | |
551 @group | |
552 (next-window (selected-window)) | |
553 @result{} #<window 52 on windows.texi> | |
554 @end group | |
555 @group | |
556 (next-window (next-window (selected-window))) | |
557 @result{} #<window 56 on windows.texi> | |
558 @end group | |
559 @end example | |
560 @end defun | |
561 | |
562 @defun previous-window &optional window minibuf all-frames | |
563 This function returns the window preceding @var{window} in the cyclic | |
564 ordering of windows. The other arguments specify which windows to | |
565 include in the cycle, as in @code{next-window}. | |
566 @end defun | |
567 | |
568 @deffn Command other-window count | |
569 This function selects the @var{count}th following window in the cyclic | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
570 order. If count is negative, then it moves back @minus{}@var{count} |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
571 windows in the cycle, rather than forward. It returns @code{nil}. |
6564 | 572 |
573 In an interactive call, @var{count} is the numeric prefix argument. | |
574 @end deffn | |
575 | |
576 @c Emacs 19 feature | |
577 @defun walk-windows proc &optional minibuf all-frames | |
578 This function cycles through all windows, calling @code{proc} | |
579 once for each window with the window as its sole argument. | |
580 | |
581 The optional arguments @var{minibuf} and @var{all-frames} specify the | |
582 set of windows to include in the scan. See @code{next-window}, above, | |
583 for details. | |
584 @end defun | |
585 | |
586 @node Buffers and Windows | |
587 @section Buffers and Windows | |
588 @cindex examining windows | |
589 @cindex windows, controlling precisely | |
590 @cindex buffers, controlled in windows | |
591 | |
592 This section describes low-level functions to examine windows or to | |
593 display buffers in windows in a precisely controlled fashion. | |
594 @iftex | |
595 See the following section for | |
596 @end iftex | |
597 @ifinfo | |
598 @xref{Displaying Buffers}, for | |
599 @end ifinfo | |
600 related functions that find a window to use and specify a buffer for it. | |
601 The functions described there are easier to use than these, but they | |
602 employ heuristics in choosing or creating a window; use these functions | |
603 when you need complete control. | |
604 | |
605 @defun set-window-buffer window buffer-or-name | |
606 This function makes @var{window} display @var{buffer-or-name} as its | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
607 contents. It returns @code{nil}. This is the fundamental primitive |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
608 for changing which buffer is displayed in a window, and all ways |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
609 of doing that call this function. |
6564 | 610 |
611 @example | |
612 @group | |
613 (set-window-buffer (selected-window) "foo") | |
614 @result{} nil | |
615 @end group | |
616 @end example | |
617 @end defun | |
618 | |
619 @defun window-buffer &optional window | |
620 This function returns the buffer that @var{window} is displaying. If | |
621 @var{window} is omitted, this function returns the buffer for the | |
622 selected window. | |
623 | |
624 @example | |
625 @group | |
626 (window-buffer) | |
627 @result{} #<buffer windows.texi> | |
628 @end group | |
629 @end example | |
630 @end defun | |
631 | |
632 @defun get-buffer-window buffer-or-name &optional all-frames | |
633 This function returns a window currently displaying | |
634 @var{buffer-or-name}, or @code{nil} if there is none. If there are | |
635 several such windows, then the function returns the first one in the | |
636 cyclic ordering of windows, starting from the selected window. | |
637 @xref{Cyclic Window Ordering}. | |
638 | |
639 The argument @var{all-frames} controls which windows to consider. | |
640 | |
641 @itemize @bullet | |
642 @item | |
643 If it is @code{nil}, consider windows on the selected frame. | |
644 @item | |
645 If it is @code{t}, consider windows on all frames. | |
646 @item | |
647 If it is @code{visible}, consider windows on all visible frames. | |
648 @item | |
12098 | 649 If it is 0, consider windows on all visible or iconified frames. |
650 @item | |
6564 | 651 If it is a frame, consider windows on that frame. |
652 @end itemize | |
653 @end defun | |
654 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
655 @defun get-buffer-window-list buffer-or-name &optional minibuf all-frames |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
656 This function returns a list of all the windows currently displaying |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
657 @var{buffer-or-name}. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
658 |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
659 The two optional arguments work like the optional arguments of |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
660 @code{next-window} (@pxref{Cyclic Window Ordering}); they are @emph{not} |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
661 like the single optional argument of @code{get-buffer-window}. Perhaps |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
662 we should change @code{get-buffer-window} in the future to make it |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
663 compatible with the other functions. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
664 |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
665 The argument @var{all-frames} controls which windows to consider. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
666 |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
667 @itemize @bullet |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
668 @item |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
669 If it is @code{nil}, consider windows on the selected frame. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
670 @item |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
671 If it is @code{t}, consider windows on all frames. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
672 @item |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
673 If it is @code{visible}, consider windows on all visible frames. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
674 @item |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
675 If it is 0, consider windows on all visible or iconified frames. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
676 @item |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
677 If it is a frame, consider windows on that frame. |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
678 @end itemize |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
679 @end defun |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
680 |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
681 @defvar buffer-display-time |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
682 @tindex buffer-display-time |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
683 This variable records the time at which a buffer was last made visible |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
684 in a window. It is always local in each buffer; each time |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
685 @code{set-window-buffer} is called, it sets this variable to |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
686 @code{(current-time)} in the specified buffer (@pxref{Time of Day}). |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
687 When a buffer is first created, @code{buffer-display-time} starts out |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
688 with the value @code{nil}. |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
689 @end defvar |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
690 |
6564 | 691 @node Displaying Buffers |
692 @section Displaying Buffers in Windows | |
693 @cindex switching to a buffer | |
694 @cindex displaying a buffer | |
695 | |
696 In this section we describe convenient functions that choose a window | |
697 automatically and use it to display a specified buffer. These functions | |
698 can also split an existing window in certain circumstances. We also | |
699 describe variables that parameterize the heuristics used for choosing a | |
700 window. | |
701 @iftex | |
702 See the preceding section for | |
703 @end iftex | |
704 @ifinfo | |
705 @xref{Buffers and Windows}, for | |
706 @end ifinfo | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
707 low-level functions that give you more precise control. All of these |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
708 functions work by calling @code{set-window-buffer}. |
6564 | 709 |
710 Do not use the functions in this section in order to make a buffer | |
711 current so that a Lisp program can access or modify it; they are too | |
712 drastic for that purpose, since they change the display of buffers in | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
713 windows, which would be gratuitous and surprise the user. Instead, use |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
714 @code{set-buffer} and @code{save-current-buffer} (@pxref{Current |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
715 Buffer}), which designate buffers as current for programmed access |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
716 without affecting the display of buffers in windows. |
6564 | 717 |
718 @deffn Command switch-to-buffer buffer-or-name &optional norecord | |
719 This function makes @var{buffer-or-name} the current buffer, and also | |
720 displays the buffer in the selected window. This means that a human can | |
721 see the buffer and subsequent keyboard commands will apply to it. | |
722 Contrast this with @code{set-buffer}, which makes @var{buffer-or-name} | |
723 the current buffer but does not display it in the selected window. | |
724 @xref{Current Buffer}. | |
725 | |
12067 | 726 If @var{buffer-or-name} does not identify an existing buffer, then a new |
727 buffer by that name is created. The major mode for the new buffer is | |
728 set according to the variable @code{default-major-mode}. @xref{Auto | |
729 Major Mode}. | |
6564 | 730 |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
731 Normally the specified buffer is put at the front of the buffer list |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
732 (both the selected frame's buffer list and the frame-independent buffer |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
733 list). This affects the operation of @code{other-buffer}. However, if |
6564 | 734 @var{norecord} is non-@code{nil}, this is not done. @xref{The Buffer |
735 List}. | |
736 | |
737 The @code{switch-to-buffer} function is often used interactively, as | |
738 the binding of @kbd{C-x b}. It is also used frequently in programs. It | |
739 always returns @code{nil}. | |
740 @end deffn | |
741 | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
742 @deffn Command switch-to-buffer-other-window buffer-or-name &optional norecord |
6564 | 743 This function makes @var{buffer-or-name} the current buffer and |
744 displays it in a window not currently selected. It then selects that | |
745 window. The handling of the buffer is the same as in | |
746 @code{switch-to-buffer}. | |
747 | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
748 The currently selected window is absolutely never used to do the job. |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
749 If it is the only window, then it is split to make a distinct window for |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
750 this purpose. If the selected window is already displaying the buffer, |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
751 then it continues to do so, but another window is nonetheless found to |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
752 display it in as well. |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
753 |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
754 This function updates the buffer list just like @code{switch-to-buffer} |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
755 unless @var{norecord} is non-@code{nil}. |
6564 | 756 @end deffn |
757 | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
758 @defun pop-to-buffer buffer-or-name &optional other-window norecord |
6564 | 759 This function makes @var{buffer-or-name} the current buffer and |
760 switches to it in some window, preferably not the window previously | |
761 selected. The ``popped-to'' window becomes the selected window within | |
762 its frame. | |
763 | |
764 If the variable @code{pop-up-frames} is non-@code{nil}, | |
765 @code{pop-to-buffer} looks for a window in any visible frame already | |
766 displaying the buffer; if there is one, it returns that window and makes | |
767 it be selected within its frame. If there is none, it creates a new | |
768 frame and displays the buffer in it. | |
769 | |
770 If @code{pop-up-frames} is @code{nil}, then @code{pop-to-buffer} | |
771 operates entirely within the selected frame. (If the selected frame has | |
772 just a minibuffer, @code{pop-to-buffer} operates within the most | |
773 recently selected frame that was not just a minibuffer.) | |
774 | |
775 If the variable @code{pop-up-windows} is non-@code{nil}, windows may | |
776 be split to create a new window that is different from the original | |
777 window. For details, see @ref{Choosing Window}. | |
778 | |
779 If @var{other-window} is non-@code{nil}, @code{pop-to-buffer} finds or | |
780 creates another window even if @var{buffer-or-name} is already visible | |
781 in the selected window. Thus @var{buffer-or-name} could end up | |
782 displayed in two windows. On the other hand, if @var{buffer-or-name} is | |
783 already displayed in the selected window and @var{other-window} is | |
784 @code{nil}, then the selected window is considered sufficient display | |
785 for @var{buffer-or-name}, so that nothing needs to be done. | |
786 | |
12098 | 787 All the variables that affect @code{display-buffer} affect |
788 @code{pop-to-buffer} as well. @xref{Choosing Window}. | |
789 | |
6564 | 790 If @var{buffer-or-name} is a string that does not name an existing |
12067 | 791 buffer, a buffer by that name is created. The major mode for the new |
792 buffer is set according to the variable @code{default-major-mode}. | |
793 @xref{Auto Major Mode}. | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
794 |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
795 This function updates the buffer list just like @code{switch-to-buffer} |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
796 unless @var{norecord} is non-@code{nil}. |
6564 | 797 @end defun |
798 | |
12098 | 799 @deffn Command replace-buffer-in-windows buffer |
800 This function replaces @var{buffer} with some other buffer in all | |
801 windows displaying it. The other buffer used is chosen with | |
802 @code{other-buffer}. In the usual applications of this function, you | |
803 don't care which other buffer is used; you just want to make sure that | |
804 @var{buffer} is no longer displayed. | |
805 | |
806 This function returns @code{nil}. | |
807 @end deffn | |
808 | |
6564 | 809 @node Choosing Window |
810 @section Choosing a Window for Display | |
811 | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
812 This section describes the basic facility that chooses a window to |
6564 | 813 display a buffer in---@code{display-buffer}. All the higher-level |
814 functions and commands use this subroutine. Here we describe how to use | |
815 @code{display-buffer} and how to customize it. | |
816 | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
817 @deffn Command display-buffer buffer-or-name &optional not-this-window frame |
6564 | 818 This command makes @var{buffer-or-name} appear in some window, like |
819 @code{pop-to-buffer}, but it does not select that window and does not | |
820 make the buffer current. The identity of the selected window is | |
821 unaltered by this function. | |
822 | |
823 If @var{not-this-window} is non-@code{nil}, it means to display the | |
824 specified buffer in a window other than the selected one, even if it is | |
825 already on display in the selected window. This can cause the buffer to | |
826 appear in two windows at once. Otherwise, if @var{buffer-or-name} is | |
827 already being displayed in any window, that is good enough, so this | |
828 function does nothing. | |
829 | |
830 @code{display-buffer} returns the window chosen to display | |
831 @var{buffer-or-name}. | |
832 | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
833 If the argument @var{frame} is non-@code{nil}, it specifies which frames |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
834 to check when deciding whether the buffer is already displayed. If the |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
835 buffer is already displayed in some window on one of these frames, |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
836 @code{display-buffer} simply returns that window. Here are the possible |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
837 values of @var{frame}: |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
838 |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
839 @itemize @bullet |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
840 @item |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
841 If it is @code{nil}, consider windows on the selected frame. |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
842 @item |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
843 If it is @code{t}, consider windows on all frames. |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
844 @item |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
845 If it is @code{visible}, consider windows on all visible frames. |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
846 @item |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
847 If it is 0, consider windows on all visible or iconified frames. |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
848 @item |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
849 If it is a frame, consider windows on that frame. |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
850 @end itemize |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
851 |
6564 | 852 Precisely how @code{display-buffer} finds or creates a window depends on |
853 the variables described below. | |
854 @end deffn | |
855 | |
856 @defopt pop-up-windows | |
857 This variable controls whether @code{display-buffer} makes new windows. | |
858 If it is non-@code{nil} and there is only one window, then that window | |
859 is split. If it is @code{nil}, then @code{display-buffer} does not | |
860 split the single window, but uses it whole. | |
861 @end defopt | |
862 | |
863 @defopt split-height-threshold | |
864 This variable determines when @code{display-buffer} may split a window, | |
865 if there are multiple windows. @code{display-buffer} always splits the | |
866 largest window if it has at least this many lines. If the largest | |
867 window is not this tall, it is split only if it is the sole window and | |
868 @code{pop-up-windows} is non-@code{nil}. | |
869 @end defopt | |
870 | |
871 @c Emacs 19 feature | |
872 @defopt pop-up-frames | |
873 This variable controls whether @code{display-buffer} makes new frames. | |
874 If it is non-@code{nil}, @code{display-buffer} looks for an existing | |
875 window already displaying the desired buffer, on any visible frame. If | |
876 it finds one, it returns that window. Otherwise it makes a new frame. | |
877 The variables @code{pop-up-windows} and @code{split-height-threshold} do | |
878 not matter if @code{pop-up-frames} is non-@code{nil}. | |
879 | |
880 If @code{pop-up-frames} is @code{nil}, then @code{display-buffer} either | |
881 splits a window or reuses one. | |
882 | |
883 @xref{Frames}, for more information. | |
884 @end defopt | |
885 | |
886 @c Emacs 19 feature | |
887 @defvar pop-up-frame-function | |
888 This variable specifies how to make a new frame if @code{pop-up-frames} | |
889 is non-@code{nil}. | |
890 | |
891 Its value should be a function of no arguments. When | |
892 @code{display-buffer} makes a new frame, it does so by calling that | |
893 function, which should return a frame. The default value of the | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
894 variable is a function that creates a frame using parameters from |
6564 | 895 @code{pop-up-frame-alist}. |
896 @end defvar | |
897 | |
898 @defvar pop-up-frame-alist | |
899 This variable holds an alist specifying frame parameters used when | |
900 @code{display-buffer} makes a new frame. @xref{Frame Parameters}, for | |
901 more information about frame parameters. | |
902 @end defvar | |
903 | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
904 @defopt special-display-buffer-names |
7082
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
905 A list of buffer names for buffers that should be displayed specially. |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
906 If the buffer's name is in this list, @code{display-buffer} handles the |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
907 buffer specially. |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
908 |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
909 By default, special display means to give the buffer a dedicated frame. |
12098 | 910 |
911 If an element is a list, instead of a string, then the @sc{car} of the | |
912 list is the buffer name, and the rest of the list says how to create the | |
913 frame. There are two possibilities for the rest of the list. It can be | |
914 an alist, specifying frame parameters, or it can contain a function and | |
915 arguments to give to it. (The function's first argument is always the | |
916 buffer to be displayed; the arguments from the list come after that.) | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
917 @end defopt |
7082
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
918 |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
919 @defopt special-display-regexps |
7082
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
920 A list of regular expressions that specify buffers that should be |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
921 displayed specially. If the buffer's name matches any of the regular |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
922 expressions in this list, @code{display-buffer} handles the buffer |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
923 specially. |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
924 |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
925 By default, special display means to give the buffer a dedicated frame. |
12098 | 926 |
927 If an element is a list, instead of a string, then the @sc{car} of the | |
928 list is the regular expression, and the rest of the list says how to | |
929 create the frame. See above, under @code{special-display-buffer-names}. | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
930 @end defopt |
7082
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
931 |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
932 @defvar special-display-function |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
933 This variable holds the function to call to display a buffer specially. |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
934 It receives the buffer as an argument, and should return the window in |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
935 which it is displayed. |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
936 |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
937 The default value of this variable is |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
938 @code{special-display-popup-frame}. |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
939 @end defvar |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
940 |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
941 @defun special-display-popup-frame buffer |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
942 This function makes @var{buffer} visible in a frame of its own. If |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
943 @var{buffer} is already displayed in a window in some frame, it makes |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
944 the frame visible and raises it, to use that window. Otherwise, it |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
945 creates a frame that will be dedicated to @var{buffer}. |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
946 |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
947 This function uses an existing window displaying @var{buffer} whether or |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
948 not it is in a frame of its own; but if you set up the above variables |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
949 in your init file, before @var{buffer} was created, then presumably the |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
950 window was previously made by this function. |
7082
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
951 @end defun |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
952 |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
953 @defopt special-display-frame-alist |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
954 This variable holds frame parameters for |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
955 @code{special-display-popup-frame} to use when it creates a frame. |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
956 @end defopt |
70b62e9d773b
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
6564
diff
changeset
|
957 |
12673
4d6b7909a0ec
Use defopt for same-window-buffer-names and same-window-regexps.
Richard M. Stallman <rms@gnu.org>
parents:
12596
diff
changeset
|
958 @defopt same-window-buffer-names |
12098 | 959 A list of buffer names for buffers that should be displayed in the |
960 selected window. If the buffer's name is in this list, | |
961 @code{display-buffer} handles the buffer by switching to it in the | |
962 selected window. | |
12673
4d6b7909a0ec
Use defopt for same-window-buffer-names and same-window-regexps.
Richard M. Stallman <rms@gnu.org>
parents:
12596
diff
changeset
|
963 @end defopt |
12098 | 964 |
12673
4d6b7909a0ec
Use defopt for same-window-buffer-names and same-window-regexps.
Richard M. Stallman <rms@gnu.org>
parents:
12596
diff
changeset
|
965 @defopt same-window-regexps |
12098 | 966 A list of regular expressions that specify buffers that should be |
967 displayed in the selected window. If the buffer's name matches any of | |
968 the regular expressions in this list, @code{display-buffer} handles the | |
969 buffer by switching to it in the selected window. | |
12673
4d6b7909a0ec
Use defopt for same-window-buffer-names and same-window-regexps.
Richard M. Stallman <rms@gnu.org>
parents:
12596
diff
changeset
|
970 @end defopt |
12098 | 971 |
6564 | 972 @c Emacs 19 feature |
973 @defvar display-buffer-function | |
974 This variable is the most flexible way to customize the behavior of | |
975 @code{display-buffer}. If it is non-@code{nil}, it should be a function | |
976 that @code{display-buffer} calls to do the work. The function should | |
977 accept two arguments, the same two arguments that @code{display-buffer} | |
978 received. It should choose or create a window, display the specified | |
979 buffer, and then return the window. | |
980 | |
981 This hook takes precedence over all the other options and hooks | |
982 described above. | |
983 @end defvar | |
984 | |
985 @c Emacs 19 feature | |
986 @cindex dedicated window | |
987 A window can be marked as ``dedicated'' to its buffer. Then | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
988 @code{display-buffer} will not try to use that window to display any |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
989 other buffer. |
6564 | 990 |
991 @defun window-dedicated-p window | |
992 This function returns @code{t} if @var{window} is marked as dedicated; | |
993 otherwise @code{nil}. | |
994 @end defun | |
995 | |
996 @defun set-window-dedicated-p window flag | |
997 This function marks @var{window} as dedicated if @var{flag} is | |
998 non-@code{nil}, and nondedicated otherwise. | |
999 @end defun | |
1000 | |
1001 @node Window Point | |
1002 @section Windows and Point | |
1003 @cindex window position | |
1004 @cindex window point | |
1005 @cindex position in window | |
1006 @cindex point in window | |
1007 | |
1008 Each window has its own value of point, independent of the value of | |
1009 point in other windows displaying the same buffer. This makes it useful | |
1010 to have multiple windows showing one buffer. | |
1011 | |
1012 @itemize @bullet | |
1013 @item | |
1014 The window point is established when a window is first created; it is | |
1015 initialized from the buffer's point, or from the window point of another | |
1016 window opened on the buffer if such a window exists. | |
1017 | |
1018 @item | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1019 Selecting a window sets the value of point in its buffer from the |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1020 window's value of point. Conversely, deselecting a window sets the |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1021 window's value of point from that of the buffer. Thus, when you switch |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1022 between windows that display a given buffer, the point value for the |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1023 selected window is in effect in the buffer, while the point values for |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1024 the other windows are stored in those windows. |
6564 | 1025 |
1026 @item | |
1027 As long as the selected window displays the current buffer, the window's | |
1028 point and the buffer's point always move together; they remain equal. | |
1029 | |
1030 @item | |
1031 @xref{Positions}, for more details on buffer positions. | |
1032 @end itemize | |
1033 | |
1034 As far as the user is concerned, point is where the cursor is, and | |
1035 when the user switches to another buffer, the cursor jumps to the | |
1036 position of point in that buffer. | |
1037 | |
1038 @defun window-point window | |
1039 This function returns the current position of point in @var{window}. | |
1040 For a nonselected window, this is the value point would have (in that | |
1041 window's buffer) if that window were selected. | |
1042 | |
1043 When @var{window} is the selected window and its buffer is also the | |
1044 current buffer, the value returned is the same as point in that buffer. | |
1045 | |
1046 Strictly speaking, it would be more correct to return the | |
1047 ``top-level'' value of point, outside of any @code{save-excursion} | |
1048 forms. But that value is hard to find. | |
1049 @end defun | |
1050 | |
1051 @defun set-window-point window position | |
1052 This function positions point in @var{window} at position | |
1053 @var{position} in @var{window}'s buffer. | |
1054 @end defun | |
1055 | |
1056 @node Window Start | |
1057 @section The Window Start Position | |
1058 | |
1059 Each window contains a marker used to keep track of a buffer position | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1060 that specifies where in the buffer display should start. This position |
6564 | 1061 is called the @dfn{display-start} position of the window (or just the |
1062 @dfn{start}). The character after this position is the one that appears | |
1063 at the upper left corner of the window. It is usually, but not | |
1064 inevitably, at the beginning of a text line. | |
1065 | |
1066 @defun window-start &optional window | |
1067 @cindex window top line | |
1068 This function returns the display-start position of window | |
1069 @var{window}. If @var{window} is @code{nil}, the selected window is | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1070 used. For example, |
6564 | 1071 |
1072 @example | |
1073 @group | |
1074 (window-start) | |
1075 @result{} 7058 | |
1076 @end group | |
1077 @end example | |
1078 | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1079 When you create a window, or display a different buffer in it, the |
6564 | 1080 display-start position is set to a display-start position recently used |
1081 for the same buffer, or 1 if the buffer doesn't have any. | |
1082 | |
12596
ffe0de415152
Explain how redisplay updates window-start.
Richard M. Stallman <rms@gnu.org>
parents:
12282
diff
changeset
|
1083 Redisplay updates the window-start position (if you have not specified |
ffe0de415152
Explain how redisplay updates window-start.
Richard M. Stallman <rms@gnu.org>
parents:
12282
diff
changeset
|
1084 it explicitly since the previous redisplay) so that point appears on the |
ffe0de415152
Explain how redisplay updates window-start.
Richard M. Stallman <rms@gnu.org>
parents:
12282
diff
changeset
|
1085 screen. Nothing except redisplay automatically changes the window-start |
ffe0de415152
Explain how redisplay updates window-start.
Richard M. Stallman <rms@gnu.org>
parents:
12282
diff
changeset
|
1086 position; if you move point, do not expect the window-start position to |
ffe0de415152
Explain how redisplay updates window-start.
Richard M. Stallman <rms@gnu.org>
parents:
12282
diff
changeset
|
1087 change in response until after the next redisplay. |
ffe0de415152
Explain how redisplay updates window-start.
Richard M. Stallman <rms@gnu.org>
parents:
12282
diff
changeset
|
1088 |
ffe0de415152
Explain how redisplay updates window-start.
Richard M. Stallman <rms@gnu.org>
parents:
12282
diff
changeset
|
1089 For a realistic example of using @code{window-start}, see the |
ffe0de415152
Explain how redisplay updates window-start.
Richard M. Stallman <rms@gnu.org>
parents:
12282
diff
changeset
|
1090 description of @code{count-lines} in @ref{Text Lines}. |
6564 | 1091 @end defun |
1092 | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1093 @defun window-end &optional window update |
6564 | 1094 This function returns the position of the end of the display in window |
1095 @var{window}. If @var{window} is @code{nil}, the selected window is | |
1096 used. | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1097 |
11510
e5d3814e783a
Update info on window-end.
Richard M. Stallman <rms@gnu.org>
parents:
8926
diff
changeset
|
1098 Simply changing the buffer text or moving point does not update the |
e5d3814e783a
Update info on window-end.
Richard M. Stallman <rms@gnu.org>
parents:
8926
diff
changeset
|
1099 value that @code{window-end} returns. The value is updated only when |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1100 Emacs redisplays and redisplay completes without being preempted. |
11510
e5d3814e783a
Update info on window-end.
Richard M. Stallman <rms@gnu.org>
parents:
8926
diff
changeset
|
1101 |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1102 If the last redisplay of @var{window} was preempted, and did not finish, |
8516
5d76d6decb35
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
8491
diff
changeset
|
1103 Emacs does not know the position of the end of display in that window. |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1104 In that case, this function returns @code{nil}. |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1105 |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1106 If @var{update} is non-@code{nil}, @code{window-end} always returns |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1107 an up-to-date value for where the window ends. If the saved value is |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1108 valid, @code{window-end} returns that; otherwise it computes the correct |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1109 value by scanning the buffer text. |
6564 | 1110 @end defun |
1111 | |
1112 @defun set-window-start window position &optional noforce | |
1113 This function sets the display-start position of @var{window} to | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1114 @var{position} in @var{window}'s buffer. It returns @var{position}. |
6564 | 1115 |
1116 The display routines insist that the position of point be visible when a | |
1117 buffer is displayed. Normally, they change the display-start position | |
1118 (that is, scroll the window) whenever necessary to make point visible. | |
1119 However, if you specify the start position with this function using | |
1120 @code{nil} for @var{noforce}, it means you want display to start at | |
1121 @var{position} even if that would put the location of point off the | |
1122 screen. If this does place point off screen, the display routines move | |
1123 point to the left margin on the middle line in the window. | |
1124 | |
1125 For example, if point @w{is 1} and you set the start of the window @w{to | |
1126 2}, then point would be ``above'' the top of the window. The display | |
1127 routines will automatically move point if it is still 1 when redisplay | |
1128 occurs. Here is an example: | |
1129 | |
1130 @example | |
1131 @group | |
1132 ;; @r{Here is what @samp{foo} looks like before executing} | |
1133 ;; @r{the @code{set-window-start} expression.} | |
1134 @end group | |
1135 | |
1136 @group | |
1137 ---------- Buffer: foo ---------- | |
1138 @point{}This is the contents of buffer foo. | |
1139 2 | |
1140 3 | |
1141 4 | |
1142 5 | |
1143 6 | |
1144 ---------- Buffer: foo ---------- | |
1145 @end group | |
1146 | |
1147 @group | |
1148 (set-window-start | |
1149 (selected-window) | |
1150 (1+ (window-start))) | |
1151 @result{} 2 | |
1152 @end group | |
1153 | |
1154 @group | |
1155 ;; @r{Here is what @samp{foo} looks like after executing} | |
1156 ;; @r{the @code{set-window-start} expression.} | |
1157 ---------- Buffer: foo ---------- | |
1158 his is the contents of buffer foo. | |
1159 2 | |
1160 3 | |
1161 @point{}4 | |
1162 5 | |
1163 6 | |
1164 ---------- Buffer: foo ---------- | |
1165 @end group | |
1166 @end example | |
1167 | |
1168 If @var{noforce} is non-@code{nil}, and @var{position} would place point | |
1169 off screen at the next redisplay, then redisplay computes a new window-start | |
1170 position that works well with point, and thus @var{position} is not used. | |
1171 @end defun | |
1172 | |
1173 @defun pos-visible-in-window-p &optional position window | |
1174 This function returns @code{t} if @var{position} is within the range | |
1175 of text currently visible on the screen in @var{window}. It returns | |
1176 @code{nil} if @var{position} is scrolled vertically out of view. The | |
1177 argument @var{position} defaults to the current position of point; | |
1178 @var{window}, to the selected window. Here is an example: | |
1179 | |
1180 @example | |
1181 @group | |
1182 (or (pos-visible-in-window-p | |
1183 (point) (selected-window)) | |
1184 (recenter 0)) | |
1185 @end group | |
1186 @end example | |
1187 | |
1188 The @code{pos-visible-in-window-p} function considers only vertical | |
1189 scrolling. If @var{position} is out of view only because @var{window} | |
1190 has been scrolled horizontally, @code{pos-visible-in-window-p} returns | |
1191 @code{t}. @xref{Horizontal Scrolling}. | |
1192 @end defun | |
1193 | |
1194 @node Vertical Scrolling | |
1195 @section Vertical Scrolling | |
1196 @cindex vertical scrolling | |
1197 @cindex scrolling vertically | |
1198 | |
1199 Vertical scrolling means moving the text up or down in a window. It | |
1200 works by changing the value of the window's display-start location. It | |
1201 may also change the value of @code{window-point} to keep it on the | |
1202 screen. | |
1203 | |
1204 In the commands @code{scroll-up} and @code{scroll-down}, the directions | |
1205 ``up'' and ``down'' refer to the motion of the text in the buffer at which | |
1206 you are looking through the window. Imagine that the text is | |
1207 written on a long roll of paper and that the scrolling commands move the | |
1208 paper up and down. Thus, if you are looking at text in the middle of a | |
1209 buffer and repeatedly call @code{scroll-down}, you will eventually see | |
1210 the beginning of the buffer. | |
1211 | |
1212 Some people have urged that the opposite convention be used: they | |
1213 imagine that the window moves over text that remains in place. Then | |
1214 ``down'' commands would take you to the end of the buffer. This view is | |
1215 more consistent with the actual relationship between windows and the | |
1216 text in the buffer, but it is less like what the user sees. The | |
1217 position of a window on the terminal does not move, and short scrolling | |
1218 commands clearly move the text up or down on the screen. We have chosen | |
1219 names that fit the user's point of view. | |
1220 | |
1221 The scrolling functions (aside from @code{scroll-other-window}) have | |
1222 unpredictable results if the current buffer is different from the buffer | |
1223 that is displayed in the selected window. @xref{Current Buffer}. | |
1224 | |
1225 @deffn Command scroll-up &optional count | |
1226 This function scrolls the text in the selected window upward | |
1227 @var{count} lines. If @var{count} is negative, scrolling is actually | |
1228 downward. | |
1229 | |
1230 If @var{count} is @code{nil} (or omitted), then the length of scroll | |
1231 is @code{next-screen-context-lines} lines less than the usable height of | |
1232 the window (not counting its mode line). | |
1233 | |
1234 @code{scroll-up} returns @code{nil}. | |
1235 @end deffn | |
1236 | |
1237 @deffn Command scroll-down &optional count | |
1238 This function scrolls the text in the selected window downward | |
1239 @var{count} lines. If @var{count} is negative, scrolling is actually | |
1240 upward. | |
1241 | |
1242 If @var{count} is omitted or @code{nil}, then the length of the scroll | |
1243 is @code{next-screen-context-lines} lines less than the usable height of | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1244 the window (not counting its mode line). |
6564 | 1245 |
1246 @code{scroll-down} returns @code{nil}. | |
1247 @end deffn | |
1248 | |
1249 @deffn Command scroll-other-window &optional count | |
1250 This function scrolls the text in another window upward @var{count} | |
1251 lines. Negative values of @var{count}, or @code{nil}, are handled | |
1252 as in @code{scroll-up}. | |
1253 | |
1254 You can specify a buffer to scroll with the variable | |
1255 @code{other-window-scroll-buffer}. When the selected window is the | |
1256 minibuffer, the next window is normally the one at the top left corner. | |
1257 You can specify a different window to scroll with the variable | |
1258 @code{minibuffer-scroll-window}. This variable has no effect when any | |
1259 other window is selected. @xref{Minibuffer Misc}. | |
1260 | |
1261 When the minibuffer is active, it is the next window if the selected | |
1262 window is the one at the bottom right corner. In this case, | |
1263 @code{scroll-other-window} attempts to scroll the minibuffer. If the | |
1264 minibuffer contains just one line, it has nowhere to scroll to, so the | |
1265 line reappears after the echo area momentarily displays the message | |
1266 ``Beginning of buffer''. | |
1267 @end deffn | |
1268 | |
1269 @c Emacs 19 feature | |
1270 @defvar other-window-scroll-buffer | |
1271 If this variable is non-@code{nil}, it tells @code{scroll-other-window} | |
1272 which buffer to scroll. | |
1273 @end defvar | |
1274 | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1275 @tindex scroll-margin |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1276 @defopt scroll-margin |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1277 This option specifies the size of the scroll margin---a minimum number |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1278 of lines between point and the top or bottom of a window. Whenever |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1279 point gets within this many lines of the top or bottom of the window, |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1280 the window scrolls automatically (if possible) to move point out of the |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1281 margin, closer to the center of the window. |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1282 @end defopt |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1283 |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1284 @tindex scroll-conservatively |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1285 @defopt scroll-conservatively |
6564 | 1286 This variable controls how scrolling is done automatically when point |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1287 moves off the screen (or into the scroll margin). If the value is zero, |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1288 then redisplay scrolls the text to center point vertically in the |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1289 window. If the value is a positive integer @var{n}, then redisplay |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1290 scrolls the window up to @var{n} lines in either direction, if that will |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1291 bring point back into view. Otherwise, it centers point. The default |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1292 value is zero. |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1293 @end defopt |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1294 |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1295 @defopt scroll-step |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1296 This variable is an older variant of @code{scroll-conservatively}. The |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1297 difference is that it if its value is @var{n}, that permits scrolling |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1298 only by precisely @var{n} lines, not a smaller number. This feature |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1299 does not work with @code{scroll-margin}. The default value is zero. |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1300 @end defopt |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1301 |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1302 @tindex scroll-preserve-screen-position |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1303 @defopt scroll-preserve-screen-position |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1304 If this option is non-@code{nil}, the scroll functions move point so |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1305 that the vertical position of the cursor is unchanged, when that is |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1306 possible. |
6564 | 1307 @end defopt |
1308 | |
1309 @defopt next-screen-context-lines | |
1310 The value of this variable is the number of lines of continuity to | |
1311 retain when scrolling by full screens. For example, @code{scroll-up} | |
1312 with an argument of @code{nil} scrolls so that this many lines at the | |
1313 bottom of the window appear instead at the top. The default value is | |
1314 @code{2}. | |
1315 @end defopt | |
1316 | |
1317 @deffn Command recenter &optional count | |
1318 @cindex centering point | |
1319 This function scrolls the selected window to put the text where point | |
1320 is located at a specified vertical position within the window. | |
1321 | |
1322 If @var{count} is a nonnegative number, it puts the line containing | |
1323 point @var{count} lines down from the top of the window. If @var{count} | |
1324 is a negative number, then it counts upward from the bottom of the | |
1325 window, so that @minus{}1 stands for the last usable line in the window. | |
1326 If @var{count} is a non-@code{nil} list, then it stands for the line in | |
1327 the middle of the window. | |
1328 | |
1329 If @var{count} is @code{nil}, @code{recenter} puts the line containing | |
1330 point in the middle of the window, then clears and redisplays the entire | |
1331 selected frame. | |
1332 | |
1333 When @code{recenter} is called interactively, @var{count} is the raw | |
1334 prefix argument. Thus, typing @kbd{C-u} as the prefix sets the | |
1335 @var{count} to a non-@code{nil} list, while typing @kbd{C-u 4} sets | |
1336 @var{count} to 4, which positions the current line four lines from the | |
1337 top. | |
1338 | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1339 With an argument of zero, @code{recenter} positions the current line at |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1340 the top of the window. This action is so handy that some people make a |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1341 separate key binding to do this. For example, |
6564 | 1342 |
1343 @example | |
1344 @group | |
1345 (defun line-to-top-of-window () | |
1346 "Scroll current line to top of window. | |
1347 Replaces three keystroke sequence C-u 0 C-l." | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1348 (interactive) |
6564 | 1349 (recenter 0)) |
1350 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1351 (global-set-key [kp-multiply] 'line-to-top-of-window) |
6564 | 1352 @end group |
1353 @end example | |
1354 @end deffn | |
1355 | |
1356 @node Horizontal Scrolling | |
1357 @section Horizontal Scrolling | |
1358 @cindex horizontal scrolling | |
1359 | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1360 Because we read English from left to right in the ``inner loop'', and |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1361 from top to bottom in the ``outer loop'', horizontal scrolling is not |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1362 like vertical scrolling. Vertical scrolling involves selection of a |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1363 contiguous portion of text to display, but horizontal scrolling causes |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1364 part of each line to go off screen. The amount of horizontal scrolling |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1365 is therefore specified as a number of columns rather than as a position |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1366 in the buffer. It has nothing to do with the display-start position |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1367 returned by @code{window-start}. |
6564 | 1368 |
1369 Usually, no horizontal scrolling is in effect; then the leftmost | |
1370 column is at the left edge of the window. In this state, scrolling to | |
1371 the right is meaningless, since there is no data to the left of the | |
1372 screen to be revealed by it; so this is not allowed. Scrolling to the | |
1373 left is allowed; it scrolls the first columns of text off the edge of | |
1374 the window and can reveal additional columns on the right that were | |
1375 truncated before. Once a window has a nonzero amount of leftward | |
1376 horizontal scrolling, you can scroll it back to the right, but only so | |
1377 far as to reduce the net horizontal scroll to zero. There is no limit | |
1378 to how far left you can scroll, but eventually all the text will | |
1379 disappear off the left edge. | |
1380 | |
1381 @deffn Command scroll-left count | |
1382 This function scrolls the selected window @var{count} columns to the | |
1383 left (or to the right if @var{count} is negative). The return value is | |
1384 the total amount of leftward horizontal scrolling in effect after the | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1385 change---just like the value returned by @code{window-hscroll} (below). |
6564 | 1386 @end deffn |
1387 | |
1388 @deffn Command scroll-right count | |
1389 This function scrolls the selected window @var{count} columns to the | |
1390 right (or to the left if @var{count} is negative). The return value is | |
1391 the total amount of leftward horizontal scrolling in effect after the | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1392 change---just like the value returned by @code{window-hscroll} (below). |
6564 | 1393 |
1394 Once you scroll a window as far right as it can go, back to its normal | |
1395 position where the total leftward scrolling is zero, attempts to scroll | |
1396 any farther right have no effect. | |
1397 @end deffn | |
1398 | |
1399 @defun window-hscroll &optional window | |
1400 This function returns the total leftward horizontal scrolling of | |
1401 @var{window}---the number of columns by which the text in @var{window} | |
1402 is scrolled left past the left margin. | |
1403 | |
1404 The value is never negative. It is zero when no horizontal scrolling | |
1405 has been done in @var{window} (which is usually the case). | |
1406 | |
1407 If @var{window} is @code{nil}, the selected window is used. | |
1408 | |
1409 @example | |
1410 @group | |
1411 (window-hscroll) | |
1412 @result{} 0 | |
1413 @end group | |
1414 @group | |
1415 (scroll-left 5) | |
1416 @result{} 5 | |
1417 @end group | |
1418 @group | |
1419 (window-hscroll) | |
1420 @result{} 5 | |
1421 @end group | |
1422 @end example | |
1423 @end defun | |
1424 | |
1425 @defun set-window-hscroll window columns | |
1426 This function sets the number of columns from the left margin that | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1427 @var{window} is scrolled from the value of @var{columns}. The argument |
6564 | 1428 @var{columns} should be zero or positive; if not, it is taken as zero. |
1429 | |
1430 The value returned is @var{columns}. | |
1431 | |
1432 @example | |
1433 @group | |
1434 (set-window-hscroll (selected-window) 10) | |
1435 @result{} 10 | |
1436 @end group | |
1437 @end example | |
1438 @end defun | |
1439 | |
1440 Here is how you can determine whether a given position @var{position} | |
1441 is off the screen due to horizontal scrolling: | |
1442 | |
1443 @example | |
1444 @group | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1445 (defun hscroll-on-screen (window position) |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1446 (save-excursion |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1447 (goto-char position) |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1448 (and |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1449 (>= (- (current-column) (window-hscroll window)) 0) |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1450 (< (- (current-column) (window-hscroll window)) |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1451 (window-width window))))) |
6564 | 1452 @end group |
1453 @end example | |
1454 | |
1455 @node Size of Window | |
1456 @section The Size of a Window | |
1457 @cindex window size | |
1458 @cindex size of window | |
1459 | |
1460 An Emacs window is rectangular, and its size information consists of | |
1461 the height (the number of lines) and the width (the number of character | |
1462 positions in each line). The mode line is included in the height. But | |
1463 the width does not count the scroll bar or the column of @samp{|} | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1464 characters that separates side-by-side windows. |
6564 | 1465 |
1466 The following three functions return size information about a window: | |
1467 | |
1468 @defun window-height &optional window | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1469 This function returns the number of lines in @var{window}, including its |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1470 mode line. If @var{window} fills its entire frame, this is typically |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1471 one less than the value of @code{frame-height} on that frame (since the |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1472 last line is always reserved for the minibuffer). |
6564 | 1473 |
1474 If @var{window} is @code{nil}, the function uses the selected window. | |
1475 | |
1476 @example | |
1477 @group | |
1478 (window-height) | |
1479 @result{} 23 | |
1480 @end group | |
1481 @group | |
1482 (split-window-vertically) | |
1483 @result{} #<window 4 on windows.texi> | |
1484 @end group | |
1485 @group | |
1486 (window-height) | |
1487 @result{} 11 | |
1488 @end group | |
1489 @end example | |
1490 @end defun | |
1491 | |
1492 @defun window-width &optional window | |
1493 This function returns the number of columns in @var{window}. If | |
1494 @var{window} fills its entire frame, this is the same as the value of | |
1495 @code{frame-width} on that frame. The width does not include the | |
1496 window's scroll bar or the column of @samp{|} characters that separates | |
1497 side-by-side windows. | |
1498 | |
1499 If @var{window} is @code{nil}, the function uses the selected window. | |
1500 | |
1501 @example | |
1502 @group | |
1503 (window-width) | |
1504 @result{} 80 | |
1505 @end group | |
1506 @end example | |
1507 @end defun | |
1508 | |
1509 @defun window-edges &optional window | |
1510 This function returns a list of the edge coordinates of @var{window}. | |
1511 If @var{window} is @code{nil}, the selected window is used. | |
1512 | |
1513 The order of the list is @code{(@var{left} @var{top} @var{right} | |
1514 @var{bottom})}, all elements relative to 0, 0 at the top left corner of | |
1515 the frame. The element @var{right} of the value is one more than the | |
1516 rightmost column used by @var{window}, and @var{bottom} is one more than | |
1517 the bottommost row used by @var{window} and its mode-line. | |
1518 | |
1519 When you have side-by-side windows, the right edge value for a window | |
1520 with a neighbor on the right includes the width of the separator between | |
1521 the window and that neighbor. This separator may be a column of | |
1522 @samp{|} characters or it may be a scroll bar. Since the width of the | |
1523 window does not include this separator, the width does not equal the | |
1524 difference between the right and left edges in this case. | |
1525 | |
1526 Here is the result obtained on a typical 24-line terminal with just one | |
1527 window: | |
1528 | |
1529 @example | |
1530 @group | |
1531 (window-edges (selected-window)) | |
1532 @result{} (0 0 80 23) | |
1533 @end group | |
1534 @end example | |
1535 | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1536 @noindent |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1537 The bottom edge is at line 23 because the last line is the echo area. |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1538 |
13275 | 1539 If @var{window} is at the upper left corner of its frame, then |
1540 @var{bottom} is the same as the value of @code{(window-height)}, | |
1541 @var{right} is almost the same as the value of | |
1542 @code{(window-width)}@footnote{They are not exactly equal because | |
1543 @var{right} includes the vertical separator line or scroll bar, while | |
1544 @code{(window-width)} does not.}, and @var{top} and @var{left} are zero. | |
1545 For example, the edges of the following window are @w{@samp{0 0 5 8}}. | |
1546 Assuming that the frame has more than 8 columns, the last column of the | |
1547 window (column 7) holds a border rather than text. The last row (row 4) | |
1548 holds the mode line, shown here with @samp{xxxxxxxxx}. | |
6564 | 1549 |
1550 @example | |
1551 @group | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1552 0 |
6564 | 1553 _______ |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1554 0 | | |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1555 | | |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1556 | | |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1557 | | |
6564 | 1558 xxxxxxxxx 4 |
1559 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1560 7 |
6564 | 1561 @end group |
1562 @end example | |
1563 | |
1564 When there are side-by-side windows, any window not at the right edge of | |
1565 its frame has a separator in its last column or columns. The separator | |
1566 counts as one or two columns in the width of the window. A window never | |
1567 includes a separator on its left, since that belongs to the window to | |
1568 the left. | |
1569 | |
1570 In the following example, let's suppose that the frame is 7 | |
1571 columns wide. Then the edges of the left window are @w{@samp{0 0 4 3}} | |
1572 and the edges of the right window are @w{@samp{4 0 7 3}}. | |
1573 | |
1574 @example | |
1575 @group | |
1576 ___ ___ | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1577 | | | |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1578 | | | |
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1579 xxxxxxxxx |
6564 | 1580 |
1581 0 34 7 | |
1582 @end group | |
1583 @end example | |
1584 @end defun | |
1585 | |
1586 @node Resizing Windows | |
1587 @section Changing the Size of a Window | |
1588 @cindex window resizing | |
1589 @cindex changing window size | |
1590 @cindex window size, changing | |
1591 | |
1592 The window size functions fall into two classes: high-level commands | |
1593 that change the size of windows and low-level functions that access | |
1594 window size. Emacs does not permit overlapping windows or gaps between | |
1595 windows, so resizing one window affects other windows. | |
1596 | |
1597 @deffn Command enlarge-window size &optional horizontal | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1598 This function makes the selected window @var{size} lines taller, |
6564 | 1599 stealing lines from neighboring windows. It takes the lines from one |
1600 window at a time until that window is used up, then takes from another. | |
1601 If a window from which lines are stolen shrinks below | |
1602 @code{window-min-height} lines, that window disappears. | |
1603 | |
1604 If @var{horizontal} is non-@code{nil}, this function makes | |
1605 @var{window} wider by @var{size} columns, stealing columns instead of | |
1606 lines. If a window from which columns are stolen shrinks below | |
1607 @code{window-min-width} columns, that window disappears. | |
1608 | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1609 If the requested size would exceed that of the window's frame, then the |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1610 function makes the window occupy the entire height (or width) of the |
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1611 frame. |
6564 | 1612 |
1613 If @var{size} is negative, this function shrinks the window by | |
1614 @minus{}@var{size} lines or columns. If that makes the window smaller | |
1615 than the minimum size (@code{window-min-height} and | |
1616 @code{window-min-width}), @code{enlarge-window} deletes the window. | |
1617 | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1618 @code{enlarge-window} returns @code{nil}. |
6564 | 1619 @end deffn |
1620 | |
1621 @deffn Command enlarge-window-horizontally columns | |
1622 This function makes the selected window @var{columns} wider. | |
1623 It could be defined as follows: | |
1624 | |
1625 @example | |
1626 @group | |
1627 (defun enlarge-window-horizontally (columns) | |
1628 (enlarge-window columns t)) | |
1629 @end group | |
1630 @end example | |
1631 @end deffn | |
1632 | |
1633 @deffn Command shrink-window size &optional horizontal | |
1634 This function is like @code{enlarge-window} but negates the argument | |
1635 @var{size}, making the selected window smaller by giving lines (or | |
1636 columns) to the other windows. If the window shrinks below | |
1637 @code{window-min-height} or @code{window-min-width}, then it disappears. | |
1638 | |
1639 If @var{size} is negative, the window is enlarged by @minus{}@var{size} | |
1640 lines or columns. | |
1641 @end deffn | |
1642 | |
1643 @deffn Command shrink-window-horizontally columns | |
1644 This function makes the selected window @var{columns} narrower. | |
1645 It could be defined as follows: | |
1646 | |
1647 @example | |
1648 @group | |
1649 (defun shrink-window-horizontally (columns) | |
1650 (shrink-window columns t)) | |
1651 @end group | |
1652 @end example | |
1653 @end deffn | |
1654 | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1655 @deffn Command shrink-window-if-larger-than-buffer window |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1656 This command shrinks @var{window} to be as small as possible while still |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1657 showing the full contents of its buffer---but not less than |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1658 @code{window-min-height} lines. |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1659 |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1660 However, the command does nothing if the window is already too small to |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1661 display the whole text of the buffer, or if part of the contents are |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1662 currently scrolled off screen, or if the window is not the full width of |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1663 its frame, or if the window is the only window in its frame. |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1664 @end deffn |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1665 |
6564 | 1666 @cindex minimum window size |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1667 The following two variables constrain the window-size-changing |
6564 | 1668 functions to a minimum height and width. |
1669 | |
1670 @defopt window-min-height | |
1671 The value of this variable determines how short a window may become | |
1672 before it is automatically deleted. Making a window smaller than | |
1673 @code{window-min-height} automatically deletes it, and no window may be | |
1674 created shorter than this. The absolute minimum height is two (allowing | |
1675 one line for the mode line, and one line for the buffer display). | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1676 Actions that change window sizes reset this variable to two if it is |
6564 | 1677 less than two. The default value is 4. |
1678 @end defopt | |
1679 | |
1680 @defopt window-min-width | |
1681 The value of this variable determines how narrow a window may become | |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1682 before it is automatically deleted. Making a window smaller than |
6564 | 1683 @code{window-min-width} automatically deletes it, and no window may be |
1684 created narrower than this. The absolute minimum width is one; any | |
1685 value below that is ignored. The default value is 10. | |
1686 @end defopt | |
1687 | |
1688 @node Coordinates and Windows | |
1689 @section Coordinates and Windows | |
1690 | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1691 This section describes how to relate screen coordinates to windows. |
6564 | 1692 |
1693 @defun window-at x y &optional frame | |
1694 This function returns the window containing the specified cursor | |
1695 position in the frame @var{frame}. The coordinates @var{x} and @var{y} | |
1696 are measured in characters and count from the top left corner of the | |
1697 frame. If they are out of range, @code{window-at} returns @code{nil}. | |
1698 | |
1699 If you omit @var{frame}, the selected frame is used. | |
1700 @end defun | |
1701 | |
1702 @defun coordinates-in-window-p coordinates window | |
1703 This function checks whether a particular frame position falls within | |
1704 the window @var{window}. | |
1705 | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1706 The argument @var{coordinates} is a cons cell of the form @code{(@var{x} |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1707 . @var{y})}. The coordinates @var{x} and @var{y} are measured in |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1708 characters, and count from the top left corner of the screen or frame. |
6564 | 1709 |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1710 The value returned by @code{coordinates-in-window-p} is non-@code{nil} |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1711 if the coordinates are inside @var{window}. The value also indicates |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1712 what part of the window the position is in, as follows: |
6564 | 1713 |
1714 @table @code | |
1715 @item (@var{relx} . @var{rely}) | |
1716 The coordinates are inside @var{window}. The numbers @var{relx} and | |
1717 @var{rely} are the equivalent window-relative coordinates for the | |
1718 specified position, counting from 0 at the top left corner of the | |
1719 window. | |
1720 | |
1721 @item mode-line | |
1722 The coordinates are in the mode line of @var{window}. | |
1723 | |
1724 @item vertical-split | |
1725 The coordinates are in the vertical line between @var{window} and its | |
15668
194145c1a2c0
Added Richard's diffs to this file, fixed a couple of small bugs
Daniel Hagerty <hag@gnu.org>
parents:
13275
diff
changeset
|
1726 neighbor to the right. This value occurs only if the window doesn't |
6564 | 1727 have a scroll bar; positions in a scroll bar are considered outside the |
1728 window. | |
1729 | |
1730 @item nil | |
1731 The coordinates are not in any part of @var{window}. | |
1732 @end table | |
1733 | |
1734 The function @code{coordinates-in-window-p} does not require a frame as | |
1735 argument because it always uses the frame that @var{window} is on. | |
1736 @end defun | |
1737 | |
1738 @node Window Configurations | |
1739 @section Window Configurations | |
1740 @cindex window configurations | |
1741 @cindex saving window information | |
1742 | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1743 A @dfn{window configuration} records the entire layout of one |
6564 | 1744 frame---all windows, their sizes, which buffers they contain, what part |
1745 of each buffer is displayed, and the values of point and the mark. You | |
1746 can bring back an entire previous layout by restoring a window | |
1747 configuration previously saved. | |
1748 | |
1749 If you want to record all frames instead of just one, use a frame | |
1750 configuration instead of a window configuration. @xref{Frame | |
1751 Configurations}. | |
1752 | |
1753 @defun current-window-configuration | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1754 This function returns a new object representing the selected frame's |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1755 current window configuration, including the number of windows, their |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1756 sizes and current buffers, which window is the selected window, and for |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1757 each window the displayed buffer, the display-start position, and the |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1758 positions of point and the mark. It also includes the values of |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1759 @code{window-min-height}, @code{window-min-width} and |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1760 @code{minibuffer-scroll-window}. An exception is made for point in the |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1761 current buffer, whose value is not saved. |
6564 | 1762 @end defun |
1763 | |
1764 @defun set-window-configuration configuration | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1765 This function restores the configuration of windows and buffers as |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1766 specified by @var{configuration}. The argument @var{configuration} must |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1767 be a value that was previously returned by |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1768 @code{current-window-configuration}. This configuration is restored in |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1769 the frame from which @var{configuration} was made, whether that frame is |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1770 selected or not. This always counts as a window size change and |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1771 triggers execution of the @code{window-size-change-functions} |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1772 (@pxref{Window Hooks}), because @code{set-window-configuration} doesn't |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1773 know how to tell whether the new configuration actually differs from the |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1774 old one. |
6564 | 1775 |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1776 If the frame which @var{configuration} was saved from is dead, all this |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1777 function does is restore the three variables @code{window-min-height}, |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1778 @code{window-min-width} and @code{minibuffer-scroll-window}. |
12098 | 1779 |
6564 | 1780 Here is a way of using this function to get the same effect |
1781 as @code{save-window-excursion}: | |
1782 | |
1783 @example | |
1784 @group | |
1785 (let ((config (current-window-configuration))) | |
1786 (unwind-protect | |
1787 (progn (split-window-vertically nil) | |
1788 @dots{}) | |
1789 (set-window-configuration config))) | |
1790 @end group | |
1791 @end example | |
1792 @end defun | |
1793 | |
1794 @defspec save-window-excursion forms@dots{} | |
1795 This special form records the window configuration, executes @var{forms} | |
1796 in sequence, then restores the earlier window configuration. The window | |
1797 configuration includes the value of point and the portion of the buffer | |
8491
320375e58ee3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
7735
diff
changeset
|
1798 that is visible. It also includes the choice of selected window. |
6564 | 1799 However, it does not include the value of point in the current buffer; |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1800 use @code{save-excursion} also, if you wish to preserve that. |
6564 | 1801 |
12098 | 1802 Don't use this construct when @code{save-selected-window} is all you need. |
1803 | |
1804 Exit from @code{save-window-excursion} always triggers execution of the | |
1805 @code{window-size-change-functions}. (It doesn't know how to tell | |
1806 whether the restored configuration actually differs from the one in | |
1807 effect at the end of the @var{forms}.) | |
1808 | |
6564 | 1809 The return value is the value of the final form in @var{forms}. |
1810 For example: | |
1811 | |
1812 @example | |
1813 @group | |
1814 (split-window) | |
1815 @result{} #<window 25 on control.texi> | |
1816 @end group | |
1817 @group | |
1818 (setq w (selected-window)) | |
1819 @result{} #<window 19 on control.texi> | |
1820 @end group | |
1821 @group | |
1822 (save-window-excursion | |
1823 (delete-other-windows w) | |
1824 (switch-to-buffer "foo") | |
1825 'do-something) | |
1826 @result{} do-something | |
1827 ;; @r{The screen is now split again.} | |
1828 @end group | |
1829 @end example | |
1830 @end defspec | |
1831 | |
1832 @defun window-configuration-p object | |
1833 This function returns @code{t} if @var{object} is a window configuration. | |
1834 @end defun | |
1835 | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1836 @defun compare-window-configurations config1 config2 |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1837 This function compares two window configurations as regards the |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1838 structure of windows, but ignores the values of point and mark and the |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1839 saved scrolling positions---it can return @code{t} even if those |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1840 aspects differ. |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1841 |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1842 The function @code{equal} can also compare two window configurations; it |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1843 regards configurations as unequal if they differ in any respect, even a |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1844 saved point or mark. |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1845 @end defun |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1846 |
6564 | 1847 Primitives to look inside of window configurations would make sense, |
1848 but none are implemented. It is not clear they are useful enough to be | |
1849 worth implementing. | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1850 |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1851 @node Window Hooks |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1852 @section Hooks for Window Scrolling and Changes |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1853 |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1854 This section describes how a Lisp program can take action whenever a |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1855 window displays a different part of its buffer or a different buffer. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1856 There are three actions that can change this: scrolling the window, |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1857 switching buffers in the window, and changing the size of the window. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1858 The first two actions run @code{window-scroll-functions}; the last runs |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1859 @code{window-size-change-functions}. The paradigmatic use of these |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1860 hooks is in the implementation of Lazy Lock mode; see @ref{Support |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
1861 Modes, Lazy Lock, Font Lock Support Modes, emacs, The GNU Emacs Manual}. |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1862 |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1863 @defvar window-scroll-functions |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1864 This variable holds a list of functions that Emacs should call before |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1865 redisplaying a window with scrolling. It is not a normal hook, because |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1866 each function is called with two arguments: the window, and its new |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1867 display-start position. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1868 |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1869 Displaying a different buffer in the window also runs these functions. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1870 |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1871 These functions must be careful in using @code{window-end} |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1872 (@pxref{Window Start}); if you need an up-to-date value, you must use |
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1873 the @var{update} argument to ensure you get it. |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1874 @end defvar |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1875 |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1876 @defvar window-size-change-functions |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1877 This variable holds a list of functions to be called if the size of any |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1878 window changes for any reason. The functions are called just once per |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1879 redisplay, and just once for each frame on which size changes have |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1880 occurred. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1881 |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1882 Each function receives the frame as its sole argument. There is no |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1883 direct way to find out which windows on that frame have changed size, or |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1884 precisely how. However, if a size-change function records, at each |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1885 call, the existing windows and their sizes, it can also compare the |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1886 present sizes and the previous sizes. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1887 |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1888 Creating or deleting windows counts as a size change, and therefore |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1889 causes these functions to be called. Changing the frame size also |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1890 counts, because it changes the sizes of the existing windows. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1891 |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1892 It is not a good idea to use @code{save-window-excursion} (@pxref{Window |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1893 Configurations}) in these functions, because that always counts as a |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1894 size change, and it would cause these functions to be called over and |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1895 over. In most cases, @code{save-selected-window} (@pxref{Selecting |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1896 Windows}) is what you need here. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1897 @end defvar |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1898 |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1899 @defvar redisplay-end-trigger-functions |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1900 @tindex redisplay-end-trigger-functions |
22252
40089afa2b1d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22138
diff
changeset
|
1901 This abnormal hook is run whenever redisplay in a window uses text that |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1902 extends past a specified end trigger position. You set the end trigger |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1903 position with the function @code{set-window-redisplay-end-trigger}. The |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1904 functions are called with two arguments: the window, and the end trigger |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1905 position. Storing @code{nil} for the end trigger position turns off the |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1906 feature, and the trigger value is automatically reset to @code{nil} just |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1907 after the hook is run. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1908 @end defvar |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1909 |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1910 @defun set-window-redisplay-end-trigger window position |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1911 @tindex set-window-redisplay-end-trigger |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1912 This function sets @var{window}'s end trigger position at |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1913 @var{position}. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1914 @end defun |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1915 |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1916 @defun window-redisplay-end-trigger window |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1917 @tindex window-redisplay-end-trigger |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1918 This function returns @var{window}'s current end trigger position. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1919 @end defun |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1920 |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
1921 @defvar window-configuration-change-hook |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1922 @tindex window-configuration-change-hook |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1923 A normal hook that is run every time you change the window configuration |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1924 of an existing frame. This includes splitting or deleting windows, |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1925 changing the sizes of windows, or displaying a different buffer in a |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1926 window. The frame whose window configuration has changed is the |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1927 selected frame when this hook runs. |
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
16736
diff
changeset
|
1928 @end defvar |