aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-11-09 15:56:50 +0800
committerChong Yidong2011-11-09 15:56:50 +0800
commitf6f6d7e7b144d4fc5955b91de2c802a19f3bf843 (patch)
treed4a13903011b39cbbff50306a78e485b2a1ec352
parentfe3c56695721ae0735a4556f74c63cd9104204ae (diff)
downloademacs-f6f6d7e7b144d4fc5955b91de2c802a19f3bf843.tar.gz
emacs-f6f6d7e7b144d4fc5955b91de2c802a19f3bf843.zip
* doc/lispref/windows.texi (Splitting Windows): Simplify example.
-rw-r--r--doc/lispref/ChangeLog4
-rw-r--r--doc/lispref/windows.texi386
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 @@
12011-11-09 Chong Yidong <cyd@gnu.org>
2
3 * windows.texi (Splitting Windows): Simplify example.
4
12011-11-08 Chong Yidong <cyd@gnu.org> 52011-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
718The functions described below are the primitives needed for creating a 718This section describes functions for creating a new window by
719new 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
721previously 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
724This function creates a new window adjacent to @var{window}. It returns 722This function creates a new live window next to the window
725the 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
726can denote any window and defaults to the selected one. This function 724to the selected window. That window is ``split'', and reduced in
727does not change the selected window. 725size. The space is taken up by the new window, which is returned.
728 726
729Optional second argument @var{size} a positive number means make 727The 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},
731negative, make the new window @minus{}@var{size} lines (or columns) 729both windows are given equal sizes; if there is an odd line, it is
732tall. If @var{size} is omitted or @code{nil}, then @var{window} is 730allocated to the new window. If @var{size} is a positive number,
733divided 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
734allocated to the new window.) 732value of @var{side}). If @var{size} is a negative number, the new
735 733window is given @minus{}@var{size} lines (or columns).
736Normally, the customizable variables @code{window-min-height} and 734
737@code{window-min-width} specify the smallest allowable size of a 735If @var{size} is @code{nil}, this function obeys the variables
738window. @xref{Change Window,,Deleting and Rearranging Windows, emacs, 736@code{window-min-height} and @code{window-min-width}. @xref{Change
739The GNU Emacs Manual}. If splitting would result in making a window 737Window,,Deleting and Rearranging Windows, emacs, The GNU Emacs
740smaller than this, this function usually signals an error. However, 738Manual}. Thus, it signals an error if splitting would result in
741if @var{size} is non-@code{nil} and valid, a new window of the 739making a window smaller than those variables specify. However, a
742requested size is created, provided it has enough space for a text 740non-@code{nil} value for @var{size} causes those variables to be
743area one line tall and/or two columns wide. 741ignored; in that case, the smallest allowable window is considered to
744 742be one that has space for a text area one line tall and/or two columns
745Optional third argument @var{side} @code{nil} (or @code{below}) 743wide.
746specifies that the new window shall be located below @var{window}. The 744
747value @code{above} means the new window will be located above 745The optional third argument @var{side} determines the position of the
748@var{window}. In both cases @var{size} specifies the new number of 746new window relative to @var{window}. If it is @code{nil} or
749lines 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
750including space reserved for the mode and/or header line. 748@code{above}, the new window is placed above @var{window}. In both
751 749these cases, @var{size} specifies a total window height, in lines.
752If @var{side} is @code{t} or @code{right} the new window will be 750
753positioned on the right side of @var{window}. The value @code{left} 751If @var{side} is @code{t} or @code{right}, the new window is placed on
754means the new window will be located on the left side of @var{window}. 752the right of @var{window}. If @var{side} is @code{left}, the new
755In both cases @var{size} specifies the new number of columns for 753window 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.
757including space reserved for margins, fringes and the scroll bar or a 755
758divider column. 756If @var{window} is a live window, the new window inherits various
759 757properties from it, including margins and scroll bars. If
760Any 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, 759properties of the window selected within @var{window}'s frame.
762application programs should refrain from using other values. 760
763 761If the variable @code{ignore-window-parameters} is non-@code{nil}
764If @var{window} is live, properties of the new window like margins and 762(@pxref{Window Parameters}), this function ignores window parameters.
765scroll bars are inherited from @var{window}. If @var{window} is an 763Otherwise, it consults the @code{split-window} parameter of
766internal window, these properties, as well as the buffer shown in the 764@var{window}; if this is @code{t}, it splits the window disregarding
767new window, are inherited from the window selected on @var{window}'s 765any other window parameters. If the @code{split-window} parameter
768frame. 766specifies a function, that function is called with the arguments
769 767@var{window}, @var{size}, and @var{side} to split @var{window}, in
770If @code{ignore-window-parameters} is non-@code{nil}, this function 768lieu of the usual action of @code{split-window}.
771ignores window parameters (@pxref{Window Parameters}). Otherwise, if
772the @code{split-window} parameter of @var{window} is @code{t}, it splits
773the window disregarding any other window parameters. If the
774@code{split-window} parameter specifies a function, that function is
775called with the arguments @var{window}, @var{size}, and @var{side} to
776split @var{window}. If that function is @code{ignore}, nothing is done.
777@end deffn 769@end deffn
778 770
779The 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
780lines high by 80 columns wide; then it splits the window. 772that yields the window configuration discussed in @ref{Windows and
781 773Frames}. This example demonstrates splitting live windows as well as
782@smallexample 774splitting internal windows. We begin with a frame containing a single
783@group 775window (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
799The 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
815Next, 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
833Now 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
850Normally, Emacs indicates the border between two side-by-side windows
851with a scroll bar (@pxref{Scroll Bars}), or with @samp{|} characters. The
852display table can specify alternative border characters; see @ref{Display
853Tables}.
854
855Below we describe how @code{split-window} can be used to create the
856window configuration from our earlier example (@pxref{Windows and
857Frames}) and how internal windows are created for this purpose. We
858start with a frame containing one live window @code{W2} (in the
859following scenarios window names are assigned in an arbitrary manner in
860order to match the names of the example). Evaluating the form
861@code{(split-window W2 8 t)} creates a new internal window @code{W1}
862with two children---@code{W2} (the window we've split) and a new leaf
863window @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
884Evaluating now @code{(split-window W6 -3)} creates another internal
885window @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}
887embedded 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
908Finally, evaluating @code{(split-window W6 nil t)} should get us the
909desired 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
929The scenario sketched above is the standard way to obtain the desired
930configuration. In Emacs 23 it was also the only way to do that since
931Emacs 23 didn't allow splitting internal windows.
932
933With 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
935following 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
956Evaluating now @code{(split-window (window-parent W6) -8 'left)} or, 796@noindent
957equivalently, @code{(split-window W3 -8 'left)} should now produce the 797The @code{split-window} call has created a new live window, denoted by
958penultimate configuration from the previous scenario from where we can 798@var{W5}. It has also created a new internal window, denoted by
959continue 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
962evaluating @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
983Evaluating 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
1005The 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 803internal 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
1010windows @code{W6} and @code{W7} shown above. If we now evaluate
1011@code{(split-window W4 -8 'left)} or @code{(split-window (window-parent
1012W6) -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
1032Evaluating now @code{(split-window W4 -3)} or, for example, 823@noindent
1033@code{(split-window (window-parent W6) -3)} should produce the desired 824A new live window, @var{W2}, is created to the left of @var{W3} (which
1034configuration. 825encompasses the vertical window combination of @var{W4} and @var{W5}).
826A new internal window @var{W1} is also created, and becomes the new
827root 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
1040If this variable is @code{nil}, the function @code{split-window} can 833If this variable is @code{nil}, @code{split-window} can only split a
1041split a window if and only if that window's screen estate is 834window (denoted by @var{window}) if @var{window}'s screen area is
1042sufficiently large to accommodate both--itself and the new window. 835large enough to accommodate both itself and the new window. This is
1043 836the default.
1044If this variable is non-@code{nil}, @code{split-window} tries to resize 837
1045all windows that are part of the same combination as the old window to 838If this variable is non-@code{nil}, @code{split-window} tries to
1046accommodate the new window. Hence, the new window can be also created if 839resize all windows that are part of the same combination as
1047the 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,
1048Sizes}). 841this may allow @code{split-window} to succeed even if @var{window} is
842a fixed-size window or too small to ordinarily split.
1049 843
1050In any case, the value of this variable is assigned to the splits status 844In any case, the value of this variable is assigned to the splits status
1051of the new window and, provided old and new window form a new 845of the new window and, provided old and new window form a new