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