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