diff options
| -rw-r--r-- | doc/lispref/ChangeLog | 8 | ||||
| -rw-r--r-- | doc/lispref/windows.texi | 187 |
2 files changed, 111 insertions, 84 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index cbe016ac96d..ca3a01d2808 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-11-09 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * windows.texi (Window Sizes): Document window-pixel-edges, | ||
| 4 | window-inside-pixel-edges. window-absolute-pixel-edges, and | ||
| 5 | window-inside-absolute-pixel-edges. | ||
| 6 | (Resizing Windows): shrink-window-if-larger-than-buffer works on | ||
| 7 | non-full-width windows. | ||
| 8 | |||
| 1 | 2011-11-09 Martin Rudalics <rudalics@gmx.at> | 9 | 2011-11-09 Martin Rudalics <rudalics@gmx.at> |
| 2 | 10 | ||
| 3 | * windows.texi (Resizing Windows): Rewrite documentation of | 11 | * windows.texi (Resizing Windows): Rewrite documentation of |
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 52ac5a53900..cf5cfedf5af 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -375,13 +375,13 @@ Bars}). At the top of the window is an optional header line | |||
| 375 | line (@pxref{Mode Line Format}). | 375 | line (@pxref{Mode Line Format}). |
| 376 | 376 | ||
| 377 | Emacs provides several functions for finding the height and width of | 377 | Emacs provides several functions for finding the height and width of |
| 378 | a window. Most of these functions report the values as integer | 378 | a window. Except where noted, these heights and widths are reported |
| 379 | multiples of the default character height and width. On a graphical | 379 | as integer numbers of lines and columns respectively. On a graphical |
| 380 | display, the actual screen size of this default height and width are | 380 | display, each ``line'' and ``column'' actually corresponds to the |
| 381 | those specified by the frame's default font. Hence, if the buffer | 381 | height and width of a ``default'' character specified by the frame's |
| 382 | contains text that is displayed in a different size, the reported | 382 | default font. Thus, if a window is displaying text with a different |
| 383 | height and width of the window may differ from the actual number of | 383 | font or size, the reported height and width for that window may differ |
| 384 | text lines or columns displayed in it. | 384 | from the actual number of text lines or columns displayed within it. |
| 385 | 385 | ||
| 386 | @cindex window height | 386 | @cindex window height |
| 387 | @cindex height of a window | 387 | @cindex height of a window |
| @@ -534,6 +534,45 @@ can be resized in the desired direction. To determine that, use the | |||
| 534 | function @code{window-resizable}. @xref{Resizing Windows}. | 534 | function @code{window-resizable}. @xref{Resizing Windows}. |
| 535 | @end defun | 535 | @end defun |
| 536 | 536 | ||
| 537 | The following functions can be used to find a window's size and | ||
| 538 | position in pixels. Though mostly useful on graphical displays, they | ||
| 539 | can also be called on text-only terminals, where the screen area of | ||
| 540 | each text character is taken to be ``one pixel''. | ||
| 541 | |||
| 542 | @defun window-pixel-edges &optional window | ||
| 543 | This function return a list of pixel coordinates for the edges of | ||
| 544 | @var{window}. If @var{window} is omitted or @code{nil}, it defaults | ||
| 545 | to the selected window. | ||
| 546 | |||
| 547 | The return value has the form @code{(@var{left} @var{top} @var{right} | ||
| 548 | @var{bottom})}. The list elements are, respectively, the X coordinate | ||
| 549 | of the left window edge, the Y coordinate of the top edge, one more | ||
| 550 | than the X coordinate of the right edge, and one more than the Y | ||
| 551 | coordinate of the bottom edge. The origin coordinate @samp{(0,0)} is | ||
| 552 | taken to be the top left corner of the frame's window area. | ||
| 553 | |||
| 554 | These edge values include the space used by the window's scroll bar, | ||
| 555 | margins, fringes, header line, and mode line, if any. | ||
| 556 | @end defun | ||
| 557 | |||
| 558 | @defun window-inside-pixel-edges &optional window | ||
| 559 | This function is like @code{window-pixel-edges}, except that it | ||
| 560 | returns the edge coordinates for the window's text area, rather than | ||
| 561 | the edge coordinates for the window itself. @var{window} must specify | ||
| 562 | a live window. | ||
| 563 | @end defun | ||
| 564 | |||
| 565 | @defun window-absolute-pixel-edges &optional window | ||
| 566 | This function is like @code{window-pixel-edges}, except that it | ||
| 567 | returns the edge coordinates relative to the top left corner of the | ||
| 568 | display screen. | ||
| 569 | @end defun | ||
| 570 | |||
| 571 | @defun window-inside-absolute-pixel-edges &optional window | ||
| 572 | This function is like @code{window-inside-pixel-edges}, except that it | ||
| 573 | returns the edge coordinates relative to the top left corner of the | ||
| 574 | display screen. @var{window} must specify a live window. | ||
| 575 | @end defun | ||
| 537 | 576 | ||
| 538 | @node Resizing Windows | 577 | @node Resizing Windows |
| 539 | @section Resizing Windows | 578 | @section Resizing Windows |
| @@ -604,104 +643,85 @@ moving only the bottom or right edge of a window, use the function | |||
| 604 | @c shrink-window, and shrink-window-horizontally are documented in the | 643 | @c shrink-window, and shrink-window-horizontally are documented in the |
| 605 | @c Emacs manual. They are not preferred for calling from Lisp. | 644 | @c Emacs manual. They are not preferred for calling from Lisp. |
| 606 | 645 | ||
| 607 | The following function is useful for moving the line dividing two | ||
| 608 | windows. | ||
| 609 | |||
| 610 | @defun adjust-window-trailing-edge window delta &optional horizontal | 646 | @defun adjust-window-trailing-edge window delta &optional horizontal |
| 611 | This function moves @var{window}'s bottom edge by @var{delta} lines. | 647 | This function moves @var{window}'s bottom edge by @var{delta} lines. |
| 612 | Optional argument @var{horizontal} non-@code{nil} means to move | 648 | If optional argument @var{horizontal} is non-@code{nil}, it instead |
| 613 | @var{window}'s right edge by @var{delta} columns. The argument | 649 | moves the right edge by @var{delta} columns. If @var{window} is |
| 614 | @var{window} defaults to the selected window. | 650 | @code{nil}, it defaults to the selected window. |
| 615 | 651 | ||
| 616 | If @var{delta} is greater zero, this moves the edge downwards or to the | 652 | A positive @var{delta} moves the edge downwards or to the right; a |
| 617 | right. If @var{delta} is less than zero, this moves the edge upwards or | 653 | negative @var{delta} moves it upwards or to the left. If the edge |
| 618 | to the left. If the edge can't be moved by @var{delta} lines or columns, | 654 | cannot be moved as far as specified by @var{delta}, this function |
| 619 | it is moved as far as possible in the desired direction but no error is | 655 | moves it as far as possible but does not signal a error. |
| 620 | signaled. | ||
| 621 | 656 | ||
| 622 | This function tries to resize windows adjacent to the edge that is | 657 | This function tries to resize windows adjacent to the edge that is |
| 623 | moved. Only if this is insufficient, it will also resize windows not | 658 | moved. If this is not possible for some reason (e.g. if that adjacent |
| 624 | adjacent to that edge. As a consequence, if you move an edge in one | 659 | window is fixed-size), it may resize other windows. |
| 625 | direction and back in the other direction by the same amount, the | ||
| 626 | resulting window configuration will not be necessarily identical to the | ||
| 627 | one before the first move. So if your intend to just resize | ||
| 628 | @var{window}, you should not use this function but call | ||
| 629 | @code{window-resize} (see above) instead. | ||
| 630 | @end defun | 660 | @end defun |
| 631 | 661 | ||
| 662 | The following commands resize windows in more specific ways. When | ||
| 663 | called interactively, they act on the selected window. | ||
| 664 | |||
| 632 | @deffn Command fit-window-to-buffer &optional window max-height min-height override | 665 | @deffn Command fit-window-to-buffer &optional window max-height min-height override |
| 633 | This command makes @var{window} the right height to display its | 666 | This command adjusts the height of @var{window} to fit the text in it. |
| 634 | contents exactly. The default for @var{window} is the selected window. | 667 | It returns non-@code{nil} if it was able to resize @var{window}, and |
| 635 | 668 | @code{nil} otherwise. If @var{window} is omitted or @code{nil}, it | |
| 636 | The optional argument @var{max-height} specifies the maximum total | 669 | defaults to the selected window. Otherwise, it should be a live |
| 637 | height the window is allowed to be; @code{nil} means use the maximum | 670 | window. |
| 638 | permissible height of a window on @var{window}'s frame. The optional | 671 | |
| 639 | argument @var{min-height} specifies the minimum total height for the | 672 | The optional argument @var{max-height}, if non-@code{nil}, specifies |
| 640 | window; @code{nil} means use @code{window-min-height}. All these height | 673 | the maximum total height that this function can give @var{window}. |
| 641 | values include the mode line and/or header line. | 674 | The optional argument @var{min-height}, if no-@code{nil}, specifies |
| 642 | 675 | the minimum total height that it can give, which overrides the | |
| 643 | If the optional argument @var{override} is non-@code{nil}, this means to | 676 | variable @code{window-min-height}. |
| 644 | ignore any restrictions imposed by @code{window-min-height} and | 677 | |
| 645 | @code{window-min-width} on the size of @var{window}. | 678 | If the optional argument @var{override} is non-@code{nil}, this |
| 646 | 679 | function ignores any size restrictions imposed by | |
| 647 | This function returns non-@code{nil} if it orderly resized @var{window}, | 680 | @code{window-min-height} and @code{window-min-width}. |
| 648 | and @code{nil} otherwise. | ||
| 649 | @end deffn | 681 | @end deffn |
| 650 | 682 | ||
| 651 | @deffn Command shrink-window-if-larger-than-buffer &optional window | 683 | @deffn Command shrink-window-if-larger-than-buffer &optional window |
| 652 | This command shrinks @var{window} vertically to be as small as possible | 684 | This command attempts to reduce @var{window}'s height as much as |
| 653 | while still showing the full contents of its buffer---but not less than | 685 | possible while still showing its full buffer, but no less than |
| 654 | @code{window-min-height} lines. The argument @var{window} must denote | 686 | @code{window-min-height} lines. The return value is non-@code{nil} if |
| 655 | a live window and defaults to the selected one. | 687 | the window was resized, and @code{nil} otherwise. If @var{window} is |
| 656 | 688 | omitted or @code{nil}, it defaults to the selected window. Otherwise, | |
| 657 | However, this command does nothing if the window is already too small to | 689 | it should be a live window. |
| 658 | display the whole text of the buffer, or if part of the contents are | 690 | |
| 659 | currently scrolled off screen, or if the window is not the full width of | 691 | This command does nothing if the window is already too short to |
| 660 | its frame, or if the window is the only window in its frame. | 692 | display all of its buffer, or if any of the buffer is scrolled |
| 661 | 693 | off-screen, or if the window is the only live window in its frame. | |
| 662 | This command returns non-@code{nil} if it actually shrank the window | ||
| 663 | and @code{nil} otherwise. | ||
| 664 | @end deffn | 694 | @end deffn |
| 665 | 695 | ||
| 666 | @cindex balancing window sizes | 696 | @cindex balancing window sizes |
| 667 | Emacs provides two functions to balance windows, that is, to even out | ||
| 668 | the sizes of all windows on the same frame. The minibuffer window and | ||
| 669 | fixed-size windows are not resized by these functions. | ||
| 670 | |||
| 671 | @deffn Command balance-windows &optional window-or-frame | 697 | @deffn Command balance-windows &optional window-or-frame |
| 672 | This function balances windows in a way that gives more space to | 698 | This function balances windows in a way that gives more space to |
| 673 | full-width and/or full-height windows. If @var{window-or-frame} | 699 | full-width and/or full-height windows. If @var{window-or-frame} |
| 674 | specifies a frame, it balances all windows on that frame. If | 700 | specifies a frame, it balances all windows on that frame. If |
| 675 | @var{window-or-frame} specifies a window, it balances that window and | 701 | @var{window-or-frame} specifies a window, it balances only that window |
| 676 | its siblings (@pxref{Windows and Frames}) only. | 702 | and its siblings (@pxref{Windows and Frames}). |
| 677 | @end deffn | 703 | @end deffn |
| 678 | 704 | ||
| 679 | @deffn Command balance-windows-area | 705 | @deffn Command balance-windows-area |
| 680 | This function attempts to give all windows on the selected frame | 706 | This function attempts to give all windows on the selected frame |
| 681 | approximately the same share of the screen area. This means that | 707 | approximately the same share of the screen area. Full-width or |
| 682 | full-width or full-height windows are not given more space than other | 708 | full-height windows are not given more space than other windows. |
| 683 | windows. | ||
| 684 | @end deffn | 709 | @end deffn |
| 685 | 710 | ||
| 686 | @cindex maximizing windows | 711 | @cindex maximizing windows |
| 687 | The following function can be used to give a window the maximum possible | ||
| 688 | size without deleting other ones. | ||
| 689 | |||
| 690 | @deffn Command maximize-window &optional window | 712 | @deffn Command maximize-window &optional window |
| 691 | This function maximizes @var{window}. More precisely, this makes | 713 | This function attempts to make @var{window} as large as possible, in |
| 692 | @var{window} as large as possible without resizing its frame or deleting | 714 | both dimensions, without resizing its frame or deleting other windows. |
| 693 | other windows. @var{window} can be any window and defaults to the | 715 | If @var{window} is omitted or @code{nil}, it defaults to the selected |
| 694 | selected one. | 716 | window. |
| 695 | @end deffn | 717 | @end deffn |
| 696 | 718 | ||
| 697 | @cindex minimizing windows | 719 | @cindex minimizing windows |
| 698 | To make a window as small as possible without deleting it the | ||
| 699 | following function can be used. | ||
| 700 | |||
| 701 | @deffn Command minimize-window &optional window | 720 | @deffn Command minimize-window &optional window |
| 702 | This function minimizes @var{window}. More precisely, this makes | 721 | This function attempts to make @var{window} as small as possible, in |
| 703 | @var{window} as small as possible without deleting it or resizing its | 722 | both dimensions, without deleting it or resizing its frame. If |
| 704 | frame. @var{window} can be any window and defaults to the selected one. | 723 | @var{window} is omitted or @code{nil}, it defaults to the selected |
| 724 | window. | ||
| 705 | @end deffn | 725 | @end deffn |
| 706 | 726 | ||
| 707 | 727 | ||
| @@ -719,7 +739,7 @@ This function creates a new live window next to the window | |||
| 719 | to the selected window. That window is ``split'', and reduced in | 739 | to the selected window. That window is ``split'', and reduced in |
| 720 | size. The space is taken up by the new window, which is returned. | 740 | size. The space is taken up by the new window, which is returned. |
| 721 | 741 | ||
| 722 | The optional second argument @var{size} determines the sizes of the | 742 | The optional second argument @var{size} determines the sizes of |
| 723 | @var{window} and/or the new window. If it is omitted or @code{nil}, | 743 | @var{window} and/or the new window. If it is omitted or @code{nil}, |
| 724 | both windows are given equal sizes; if there is an odd line, it is | 744 | both windows are given equal sizes; if there is an odd line, it is |
| 725 | allocated to the new window. If @var{size} is a positive number, | 745 | allocated to the new window. If @var{size} is a positive number, |
| @@ -765,10 +785,10 @@ lieu of the usual action of @code{split-window}. | |||
| 765 | 785 | ||
| 766 | As an example, we show a combination of @code{split-window} calls | 786 | As an example, we show a combination of @code{split-window} calls |
| 767 | that yields the window configuration discussed in @ref{Windows and | 787 | that yields the window configuration discussed in @ref{Windows and |
| 768 | Frames}. This example demonstrates splitting live windows as well as | 788 | Frames}. This example demonstrates splitting a live window as well as |
| 769 | splitting internal windows. We begin with a frame containing a single | 789 | splitting an internal window. We begin with a frame containing a |
| 770 | window (a live root window), which we denote by @var{W4}. Calling | 790 | single window (a live root window), which we denote by @var{W4}. |
| 771 | @code{(split-window W3)} yields this window configuration: | 791 | Calling @code{(split-window W3)} yields this window configuration: |
| 772 | 792 | ||
| 773 | @smallexample | 793 | @smallexample |
| 774 | @group | 794 | @group |
| @@ -816,10 +836,9 @@ internal window @var{W3} as the argument. The result: | |||
| 816 | @end smallexample | 836 | @end smallexample |
| 817 | 837 | ||
| 818 | @noindent | 838 | @noindent |
| 819 | A new live window, @var{W2}, is created to the left of @var{W3} (which | 839 | A new live window @var{W2} is created, to the left of the internal |
| 820 | encompasses the vertical window combination of @var{W4} and @var{W5}). | 840 | window @var{W3}. A new internal window @var{W1} is created, becoming |
| 821 | A new internal window @var{W1} is also created, and becomes the new | 841 | the new root window. |
| 822 | root window. | ||
| 823 | 842 | ||
| 824 | The following two options can be used to modify the operation of | 843 | The following two options can be used to modify the operation of |
| 825 | @code{split-window}. | 844 | @code{split-window}. |