diff options
| author | Chong Yidong | 2011-11-09 15:56:50 +0800 |
|---|---|---|
| committer | Chong Yidong | 2011-11-09 15:56:50 +0800 |
| commit | f6f6d7e7b144d4fc5955b91de2c802a19f3bf843 (patch) | |
| tree | d4a13903011b39cbbff50306a78e485b2a1ec352 | |
| parent | fe3c56695721ae0735a4556f74c63cd9104204ae (diff) | |
| download | emacs-f6f6d7e7b144d4fc5955b91de2c802a19f3bf843.tar.gz emacs-f6f6d7e7b144d4fc5955b91de2c802a19f3bf843.zip | |
* doc/lispref/windows.texi (Splitting Windows): Simplify example.
| -rw-r--r-- | doc/lispref/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/lispref/windows.texi | 386 |
2 files changed, 94 insertions, 296 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 7a1e34de159..2b1e210fc73 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2011-11-09 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * windows.texi (Splitting Windows): Simplify example. | ||
| 4 | |||
| 1 | 2011-11-08 Chong Yidong <cyd@gnu.org> | 5 | 2011-11-08 Chong Yidong <cyd@gnu.org> |
| 2 | 6 | ||
| 3 | * windows.texi (Window Sizes): Copyedits. Document | 7 | * windows.texi (Window Sizes): Copyedits. Document |
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 46ed4476036..17483d4c0ed 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -715,224 +715,66 @@ frame. @var{window} can be any window and defaults to the selected one. | |||
| 715 | @cindex splitting windows | 715 | @cindex splitting windows |
| 716 | @cindex window splitting | 716 | @cindex window splitting |
| 717 | 717 | ||
| 718 | The functions described below are the primitives needed for creating a | 718 | This section describes functions for creating a new window by |
| 719 | new window. They do not accept a buffer as an argument. Rather, they | 719 | @dfn{splitting} an existing one. |
| 720 | ``split'' an existing window into two halves, both displaying the buffer | ||
| 721 | previously visible in the window that was split. | ||
| 722 | 720 | ||
| 723 | @deffn Command split-window &optional window size side | 721 | @deffn Command split-window &optional window size side |
| 724 | This function creates a new window adjacent to @var{window}. It returns | 722 | This function creates a new live window next to the window |
| 725 | the new window which is always a live window. The argument @var{window} | 723 | @var{window}. If @var{window} is omitted or @code{nil}, it defaults |
| 726 | can denote any window and defaults to the selected one. This function | 724 | to the selected window. That window is ``split'', and reduced in |
| 727 | does not change the selected window. | 725 | size. The space is taken up by the new window, which is returned. |
| 728 | 726 | ||
| 729 | Optional second argument @var{size} a positive number means make | 727 | The optional second argument @var{size} determines the sizes of the |
| 730 | @var{window} @var{size} lines (or columns) tall. If @var{size} is | 728 | @var{window} and/or the new window. If it is omitted or @code{nil}, |
| 731 | negative, make the new window @minus{}@var{size} lines (or columns) | 729 | both windows are given equal sizes; if there is an odd line, it is |
| 732 | tall. If @var{size} is omitted or @code{nil}, then @var{window} is | 730 | allocated to the new window. If @var{size} is a positive number, |
| 733 | divided evenly into two parts. (If there is an odd line, it is | 731 | @var{window} is given @var{size} lines (or columns, depending on the |
| 734 | allocated to the new window.) | 732 | value of @var{side}). If @var{size} is a negative number, the new |
| 735 | 733 | window is given @minus{}@var{size} lines (or columns). | |
| 736 | Normally, the customizable variables @code{window-min-height} and | 734 | |
| 737 | @code{window-min-width} specify the smallest allowable size of a | 735 | If @var{size} is @code{nil}, this function obeys the variables |
| 738 | window. @xref{Change Window,,Deleting and Rearranging Windows, emacs, | 736 | @code{window-min-height} and @code{window-min-width}. @xref{Change |
| 739 | The GNU Emacs Manual}. If splitting would result in making a window | 737 | Window,,Deleting and Rearranging Windows, emacs, The GNU Emacs |
| 740 | smaller than this, this function usually signals an error. However, | 738 | Manual}. Thus, it signals an error if splitting would result in |
| 741 | if @var{size} is non-@code{nil} and valid, a new window of the | 739 | making a window smaller than those variables specify. However, a |
| 742 | requested size is created, provided it has enough space for a text | 740 | non-@code{nil} value for @var{size} causes those variables to be |
| 743 | area one line tall and/or two columns wide. | 741 | ignored; in that case, the smallest allowable window is considered to |
| 744 | 742 | be one that has space for a text area one line tall and/or two columns | |
| 745 | Optional third argument @var{side} @code{nil} (or @code{below}) | 743 | wide. |
| 746 | specifies that the new window shall be located below @var{window}. The | 744 | |
| 747 | value @code{above} means the new window will be located above | 745 | The optional third argument @var{side} determines the position of the |
| 748 | @var{window}. In both cases @var{size} specifies the new number of | 746 | new window relative to @var{window}. If it is @code{nil} or |
| 749 | lines for @var{window} (or the new window if @var{size} is negative) | 747 | @code{below}, the new window is placed below @var{window}. If it is |
| 750 | including space reserved for the mode and/or header line. | 748 | @code{above}, the new window is placed above @var{window}. In both |
| 751 | 749 | these cases, @var{size} specifies a total window height, in lines. | |
| 752 | If @var{side} is @code{t} or @code{right} the new window will be | 750 | |
| 753 | positioned on the right side of @var{window}. The value @code{left} | 751 | If @var{side} is @code{t} or @code{right}, the new window is placed on |
| 754 | means the new window will be located on the left side of @var{window}. | 752 | the right of @var{window}. If @var{side} is @code{left}, the new |
| 755 | In both cases @var{size} specifies the new number of columns for | 753 | window is placed on the left of @var{window}. In both these cases, |
| 756 | @var{window} (or the new window provided @var{size} is negative) | 754 | @var{size} specifies a total window width, in columns. |
| 757 | including space reserved for margins, fringes and the scroll bar or a | 755 | |
| 758 | divider column. | 756 | If @var{window} is a live window, the new window inherits various |
| 759 | 757 | properties from it, including margins and scroll bars. If | |
| 760 | Any other non-@code{nil} value for @var{side} is currently handled like | 758 | @var{window} is an internal window, the new window inherits the |
| 761 | @code{t} (or @code{right}). Since this might change in the future, | 759 | properties of the window selected within @var{window}'s frame. |
| 762 | application programs should refrain from using other values. | 760 | |
| 763 | 761 | If the variable @code{ignore-window-parameters} is non-@code{nil} | |
| 764 | If @var{window} is live, properties of the new window like margins and | 762 | (@pxref{Window Parameters}), this function ignores window parameters. |
| 765 | scroll bars are inherited from @var{window}. If @var{window} is an | 763 | Otherwise, it consults the @code{split-window} parameter of |
| 766 | internal window, these properties, as well as the buffer shown in the | 764 | @var{window}; if this is @code{t}, it splits the window disregarding |
| 767 | new window, are inherited from the window selected on @var{window}'s | 765 | any other window parameters. If the @code{split-window} parameter |
| 768 | frame. | 766 | specifies a function, that function is called with the arguments |
| 769 | 767 | @var{window}, @var{size}, and @var{side} to split @var{window}, in | |
| 770 | If @code{ignore-window-parameters} is non-@code{nil}, this function | 768 | lieu of the usual action of @code{split-window}. |
| 771 | ignores window parameters (@pxref{Window Parameters}). Otherwise, if | ||
| 772 | the @code{split-window} parameter of @var{window} is @code{t}, it splits | ||
| 773 | the window disregarding any other window parameters. If the | ||
| 774 | @code{split-window} parameter specifies a function, that function is | ||
| 775 | called with the arguments @var{window}, @var{size}, and @var{side} to | ||
| 776 | split @var{window}. If that function is @code{ignore}, nothing is done. | ||
| 777 | @end deffn | 769 | @end deffn |
| 778 | 770 | ||
| 779 | The following example starts with one window on a screen that is 50 | 771 | As an example, we show a combination of @code{split-window} calls |
| 780 | lines high by 80 columns wide; then it splits the window. | 772 | that yields the window configuration discussed in @ref{Windows and |
| 781 | 773 | Frames}. This example demonstrates splitting live windows as well as | |
| 782 | @smallexample | 774 | splitting internal windows. We begin with a frame containing a single |
| 783 | @group | 775 | window (a live root window), which we denote by @var{W4}. Calling |
| 784 | (setq W1 (selected-window)) | 776 | @code{(split-window W3)} yields this window configuration: |
| 785 | @result{} #<window 8 on windows.texi> | ||
| 786 | (setq W2 (split-window W1 15)) | ||
| 787 | @result{} #<window 28 on windows.texi> | ||
| 788 | @end group | ||
| 789 | @group | ||
| 790 | (window-top-line W1) | ||
| 791 | @result{} 0 | ||
| 792 | (window-total-size W1) | ||
| 793 | @result{} 15 | ||
| 794 | (window-top-line W2) | ||
| 795 | @result{} 15 | ||
| 796 | @end group | ||
| 797 | @end smallexample | ||
| 798 | |||
| 799 | The screen looks like this: | ||
| 800 | |||
| 801 | @smallexample | ||
| 802 | @group | ||
| 803 | __________ | ||
| 804 | | | line 0 | ||
| 805 | | W1 | | ||
| 806 | |__________| | ||
| 807 | | | line 15 | ||
| 808 | | W2 | | ||
| 809 | |__________| | ||
| 810 | line 50 | ||
| 811 | column 0 column 80 | ||
| 812 | @end group | ||
| 813 | @end smallexample | ||
| 814 | |||
| 815 | Next, split the top window into two side-by-side windows: | ||
| 816 | |||
| 817 | @smallexample | ||
| 818 | @group | ||
| 819 | (setq W3 (split-window W1 35 t)) | ||
| 820 | @result{} #<window 32 on windows.texi> | ||
| 821 | @end group | ||
| 822 | @group | ||
| 823 | (window-left-column W1) | ||
| 824 | @result{} 0 | ||
| 825 | (window-total-size W1 t) | ||
| 826 | @result{} 35 | ||
| 827 | (window-left-column W3) | ||
| 828 | @result{} 35 | ||
| 829 | @end group | ||
| 830 | @end smallexample | ||
| 831 | |||
| 832 | @need 3000 | ||
| 833 | Now the screen looks like this: | ||
| 834 | |||
| 835 | @smallexample | ||
| 836 | @group | ||
| 837 | column 35 | ||
| 838 | __________ | ||
| 839 | | | | line 0 | ||
| 840 | | W1 | W3 | | ||
| 841 | |____|_____| | ||
| 842 | | | line 15 | ||
| 843 | | W2 | | ||
| 844 | |__________| | ||
| 845 | line 50 | ||
| 846 | column 0 column 80 | ||
| 847 | @end group | ||
| 848 | @end smallexample | ||
| 849 | |||
| 850 | Normally, Emacs indicates the border between two side-by-side windows | ||
| 851 | with a scroll bar (@pxref{Scroll Bars}), or with @samp{|} characters. The | ||
| 852 | display table can specify alternative border characters; see @ref{Display | ||
| 853 | Tables}. | ||
| 854 | |||
| 855 | Below we describe how @code{split-window} can be used to create the | ||
| 856 | window configuration from our earlier example (@pxref{Windows and | ||
| 857 | Frames}) and how internal windows are created for this purpose. We | ||
| 858 | start with a frame containing one live window @code{W2} (in the | ||
| 859 | following scenarios window names are assigned in an arbitrary manner in | ||
| 860 | order to match the names of the example). Evaluating the form | ||
| 861 | @code{(split-window W2 8 t)} creates a new internal window @code{W1} | ||
| 862 | with two children---@code{W2} (the window we've split) and a new leaf | ||
| 863 | window @code{W6}: | ||
| 864 | @smallexample | ||
| 865 | @group | ||
| 866 | ______________________________________ | ||
| 867 | | ______ ____________________________ | | ||
| 868 | || || || | ||
| 869 | || || || | ||
| 870 | || || || | ||
| 871 | || || || | ||
| 872 | || || || | ||
| 873 | || || || | ||
| 874 | || || || | ||
| 875 | || || || | ||
| 876 | || || || | ||
| 877 | || || || | ||
| 878 | ||__W2__||_____________W6_____________ | | ||
| 879 | |__________________W1__________________| | ||
| 880 | |||
| 881 | @end group | ||
| 882 | @end smallexample | ||
| 883 | |||
| 884 | Evaluating now @code{(split-window W6 -3)} creates another internal | ||
| 885 | window @code{W3} with two children---@code{W6} and a new live window | ||
| 886 | @code{W5}. This leaves us with a vertically combined window @code{W3} | ||
| 887 | embedded in the horizontally combined window @code{W1}: | ||
| 888 | @smallexample | ||
| 889 | @group | ||
| 890 | ______________________________________ | ||
| 891 | | ______ ____________________________ | | ||
| 892 | || || __________________________ || | ||
| 893 | || ||| ||| | ||
| 894 | || ||| ||| | ||
| 895 | || ||| ||| | ||
| 896 | || ||| ||| | ||
| 897 | || ||| ||| | ||
| 898 | || |||____________W6____________||| | ||
| 899 | || || __________________________ || | ||
| 900 | || ||| ||| | ||
| 901 | || |||____________W5____________||| | ||
| 902 | ||__W2__||_____________W3_____________ | | ||
| 903 | |__________________W1__________________| | ||
| 904 | |||
| 905 | @end group | ||
| 906 | @end smallexample | ||
| 907 | 777 | ||
| 908 | Finally, evaluating @code{(split-window W6 nil t)} should get us the | ||
| 909 | desired configuration as depicted below. | ||
| 910 | @smallexample | ||
| 911 | @group | ||
| 912 | ______________________________________ | ||
| 913 | | ______ ____________________________ | | ||
| 914 | || || __________________________ || | ||
| 915 | || ||| ___________ ___________ ||| | ||
| 916 | || |||| || |||| | ||
| 917 | || |||| || |||| | ||
| 918 | || ||||_____W6____||_____W7____|||| | ||
| 919 | || |||____________W4____________||| | ||
| 920 | || || __________________________ || | ||
| 921 | || ||| ||| | ||
| 922 | || |||____________W5____________||| | ||
| 923 | ||__W2__||_____________W3_____________ | | ||
| 924 | |__________________W1__________________| | ||
| 925 | |||
| 926 | @end group | ||
| 927 | @end smallexample | ||
| 928 | |||
| 929 | The scenario sketched above is the standard way to obtain the desired | ||
| 930 | configuration. In Emacs 23 it was also the only way to do that since | ||
| 931 | Emacs 23 didn't allow splitting internal windows. | ||
| 932 | |||
| 933 | With Emacs 24 you can also proceed as follows: Split an initial window | ||
| 934 | @code{W6} by evaluating @code{(split-window W6 -3)} to produce the | ||
| 935 | following vertical combination: | ||
| 936 | @smallexample | 778 | @smallexample |
| 937 | @group | 779 | @group |
| 938 | ______________________________________ | 780 | ______________________________________ |
| @@ -940,112 +782,64 @@ following vertical combination: | |||
| 940 | || || | 782 | || || |
| 941 | || || | 783 | || || |
| 942 | || || | 784 | || || |
| 785 | ||_________________W4_________________|| | ||
| 786 | | ____________________________________ | | ||
| 943 | || || | 787 | || || |
| 944 | || || | 788 | || || |
| 945 | || || | 789 | || || |
| 946 | || || | ||
| 947 | ||_________________W6_________________|| | ||
| 948 | | ____________________________________ | | ||
| 949 | || || | ||
| 950 | ||_________________W5_________________|| | 790 | ||_________________W5_________________|| |
| 951 | |__________________W3__________________| | 791 | |__________________W3__________________| |
| 952 | 792 | ||
| 953 | @end group | 793 | @end group |
| 954 | @end smallexample | 794 | @end smallexample |
| 955 | 795 | ||
| 956 | Evaluating now @code{(split-window (window-parent W6) -8 'left)} or, | 796 | @noindent |
| 957 | equivalently, @code{(split-window W3 -8 'left)} should now produce the | 797 | The @code{split-window} call has created a new live window, denoted by |
| 958 | penultimate configuration from the previous scenario from where we can | 798 | @var{W5}. It has also created a new internal window, denoted by |
| 959 | continue as described before. | 799 | @var{W3}, which becomes the root window and the parent of both |
| 960 | 800 | @var{W4} and @var{W5}. | |
| 961 | Another strategy starts with splitting an initial window @code{W6} by | ||
| 962 | evaluating @code{(split-window W6 nil nil t)} with the following result: | ||
| 963 | @smallexample | ||
| 964 | @group | ||
| 965 | ______________________________________ | ||
| 966 | | _________________ _________________ | | ||
| 967 | || || || | ||
| 968 | || || || | ||
| 969 | || || || | ||
| 970 | || || || | ||
| 971 | || || || | ||
| 972 | || || || | ||
| 973 | || || || | ||
| 974 | || || || | ||
| 975 | || || || | ||
| 976 | || || || | ||
| 977 | ||________W6_______||________W7_______|| | ||
| 978 | |__________________W4__________________| | ||
| 979 | |||
| 980 | @end group | ||
| 981 | @end smallexample | ||
| 982 | |||
| 983 | Evaluating now @code{(split-window W4 -3)} or @code{(split-window | ||
| 984 | (window-parent W6) -3)} should get us a configuration as shown next. | ||
| 985 | @smallexample | ||
| 986 | @group | ||
| 987 | ______________________________________ | ||
| 988 | | ____________________________________ | | ||
| 989 | || ________________ ________________ || | ||
| 990 | ||| || ||| | ||
| 991 | ||| || ||| | ||
| 992 | ||| || ||| | ||
| 993 | ||| || ||| | ||
| 994 | ||| || ||| | ||
| 995 | |||_______W6_______||________W7______||| | ||
| 996 | ||_________________W4_________________|| | ||
| 997 | | ____________________________________ | | ||
| 998 | || || | ||
| 999 | ||_________________W5_________________|| | ||
| 1000 | |__________________W3__________________| | ||
| 1001 | |||
| 1002 | @end group | ||
| 1003 | @end smallexample | ||
| 1004 | 801 | ||
| 1005 | The desired configuration can be now obtained by evaluating | 802 | Next, we call @code{(split-window W3 nil 'left)}, passing the |
| 1006 | @code{(split-window W3 -8 'left)} or, equivalently, @code{(split-window | 803 | internal window @var{W3} as the argument. The result: |
| 1007 | (window-parent W5) -8 'left)}. | ||
| 1008 | 804 | ||
| 1009 | For a final approach let's start with the configuration of two live | ||
| 1010 | windows @code{W6} and @code{W7} shown above. If we now evaluate | ||
| 1011 | @code{(split-window W4 -8 'left)} or @code{(split-window (window-parent | ||
| 1012 | W6) -8 'left)} we get the following configuration. | ||
| 1013 | @smallexample | 805 | @smallexample |
| 1014 | @group | 806 | @group |
| 1015 | ______________________________________ | 807 | ______________________________________ |
| 1016 | | ______ ____________________________ | | 808 | | ______ ____________________________ | |
| 1017 | || || ____________ ____________ || | 809 | || || __________________________ || |
| 1018 | || ||| || ||| | 810 | || ||| ||| |
| 1019 | || ||| || ||| | 811 | || ||| ||| |
| 1020 | || ||| || ||| | 812 | || ||| ||| |
| 1021 | || ||| || ||| | 813 | || |||____________W4____________||| |
| 1022 | || ||| || ||| | 814 | || || __________________________ || |
| 1023 | || ||| || ||| | 815 | || ||| ||| |
| 1024 | || ||| || ||| | 816 | || ||| ||| |
| 1025 | || |||______W6____||______W7____||| | 817 | || |||____________W5____________||| |
| 1026 | ||__W2__||_____________W4_____________|| | 818 | ||__W2__||_____________W3_____________ | |
| 1027 | |__________________W1__________________| | 819 | |__________________W1__________________| |
| 1028 | |||
| 1029 | @end group | 820 | @end group |
| 1030 | @end smallexample | 821 | @end smallexample |
| 1031 | 822 | ||
| 1032 | Evaluating now @code{(split-window W4 -3)} or, for example, | 823 | @noindent |
| 1033 | @code{(split-window (window-parent W6) -3)} should produce the desired | 824 | A new live window, @var{W2}, is created to the left of @var{W3} (which |
| 1034 | configuration. | 825 | encompasses the vertical window combination of @var{W4} and @var{W5}). |
| 826 | A new internal window @var{W1} is also created, and becomes the new | ||
| 827 | root window. | ||
| 1035 | 828 | ||
| 1036 | The two options described next can be used to tune the operation of | 829 | The following two options can be used to modify the operation of |
| 1037 | @code{split-window}. | 830 | @code{split-window}. |
| 1038 | 831 | ||
| 1039 | @defopt window-splits | 832 | @defopt window-splits |
| 1040 | If this variable is @code{nil}, the function @code{split-window} can | 833 | If this variable is @code{nil}, @code{split-window} can only split a |
| 1041 | split a window if and only if that window's screen estate is | 834 | window (denoted by @var{window}) if @var{window}'s screen area is |
| 1042 | sufficiently large to accommodate both--itself and the new window. | 835 | large enough to accommodate both itself and the new window. This is |
| 1043 | 836 | the default. | |
| 1044 | If this variable is non-@code{nil}, @code{split-window} tries to resize | 837 | |
| 1045 | all windows that are part of the same combination as the old window to | 838 | If this variable is non-@code{nil}, @code{split-window} tries to |
| 1046 | accommodate the new window. Hence, the new window can be also created if | 839 | resize all windows that are part of the same combination as |
| 1047 | the old window is of fixed size or too small to split (@pxref{Window | 840 | @var{window}, in order to accommodate the new window. In particular, |
| 1048 | Sizes}). | 841 | this may allow @code{split-window} to succeed even if @var{window} is |
| 842 | a fixed-size window or too small to ordinarily split. | ||
| 1049 | 843 | ||
| 1050 | In any case, the value of this variable is assigned to the splits status | 844 | In any case, the value of this variable is assigned to the splits status |
| 1051 | of the new window and, provided old and new window form a new | 845 | of the new window and, provided old and new window form a new |