aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2012-11-03 11:47:03 +0100
committerMartin Rudalics2012-11-03 11:47:03 +0100
commit43bcfda6d863c6172eeba2d6aa22d22453849423 (patch)
tree8482396f0a59b18e3b1db40c36e91e35a7078d38
parent67b50ba47bcf46bd8a699fa0c1f2af1cce3f2338 (diff)
downloademacs-43bcfda6d863c6172eeba2d6aa22d22453849423.tar.gz
emacs-43bcfda6d863c6172eeba2d6aa22d22453849423.zip
Doc changes related to displaying buffers and quitting windows.
* window.el (switch-to-visible-buffer) (switch-to-buffer-preserve-window-point): Fix doc-strings. * windows.texi (Switching Buffers): Document option switch-to-buffer-preserve-window-point. (Display Action Functions): Document window-height and window-width alist entries. (Display Action Functions): Document display-buffer-below-selected and display-buffer-in-previous-window. (Quitting Windows): Document quit-restore-window. Rewrite section. (Window Configurations): In window-state-get mention that argument window must be valid. (Window Parameters): Document quit-restore window parameter (Bug#12158).
-rw-r--r--doc/lispref/ChangeLog16
-rw-r--r--doc/lispref/windows.texi227
-rw-r--r--etc/NEWS13
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/window.el13
5 files changed, 215 insertions, 59 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index da3cc91a675..fa996191ac4 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,19 @@
12012-11-03 Martin Rudalics <rudalics@gmx.at>
2
3 * windows.texi (Switching Buffers): Document option
4 switch-to-buffer-preserve-window-point.
5 (Display Action Functions): Document window-height and
6 window-width alist entries.
7 (Display Action Functions): Document
8 display-buffer-below-selected and
9 display-buffer-in-previous-window.
10 (Quitting Windows): Document quit-restore-window. Rewrite
11 section.
12 (Window Configurations): In window-state-get mention that
13 argument window must be valid.
14 (Window Parameters): Document quit-restore window parameter
15 (Bug#12158).
16
12012-10-31 Glenn Morris <rgm@gnu.org> 172012-10-31 Glenn Morris <rgm@gnu.org>
2 18
3 * control.texi (Catch and Throw): Add xref to cl.texi. 19 * control.texi (Catch and Throw): Add xref to cl.texi.
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index d0e149eb165..2fbb59cd1dd 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -1550,6 +1550,26 @@ normally tries to display the buffer in some other window, by invoking
1550instead. 1550instead.
1551@end deffn 1551@end deffn
1552 1552
1553By default, @code{switch-to-buffer} sets @code{window-point} of the
1554window used to the buffer's position of @code{point}. This behavior can
1555be tuned using the following option.
1556
1557@defopt switch-to-buffer-preserve-window-point
1558If this variable is @code{nil}, @code{switch-to-buffer} displays the
1559buffer specified by @var{buffer-or-name} at the position of that
1560buffer's @code{point}. If this variable is @code{already-displayed}, it
1561tries to display the buffer at its previous position in the selected
1562window, provided the buffer is currently displayed in some other window
1563on any visible or iconified frame. If this variable is @code{t},
1564@code{switch-to-buffer} unconditionally tries to display the buffer at
1565its previous position in the selected window.
1566
1567This variable is ignored if the buffer is already displayed in the
1568selected window or never appeared in it before, or if
1569@code{switch-to-buffer} calls @code{pop-to-buffer} to display the
1570buffer.
1571@end defopt
1572
1553The next two functions are similar to @code{switch-to-buffer}, except 1573The next two functions are similar to @code{switch-to-buffer}, except
1554for the described features. 1574for the described features.
1555 1575
@@ -1775,9 +1795,51 @@ It actually performs the split by calling the function specified in
1775@code{split-window-preferred-function} (@pxref{Choosing Window 1795@code{split-window-preferred-function} (@pxref{Choosing Window
1776Options}). 1796Options}).
1777 1797
1778It can fail if no window splitting can be performed for some reason 1798The size of the new window can be adjusted by supplying
1779(e.g. if there is just one frame and it has an @code{unsplittable} 1799@code{window-height} and @code{window-width} entries in @var{alist}. To
1780frame parameter; @pxref{Buffer Parameters}). 1800adjust the window's height, use an entry whose @sc{car} is
1801@code{window-height} and whose @sc{cdr} is one of:
1802
1803@itemize @bullet
1804@item
1805@code{nil} means to leave the height of the new window alone.
1806
1807@item
1808A number specifies the desired height of the new window. An integer
1809number specifies the number of lines of the window. A floating point
1810number gives the fraction of the window's height with respect to the
1811height of the frame's root window.
1812
1813@item
1814If the @sc{cdr} specifies a function, that function is called with one
1815argument - the new window. The function is supposed to adjust the
1816height of the window; its return value is ignored. Suitable functions
1817are @code{shrink-window-if-larger-than-buffer} and
1818@code{fit-window-to-buffer}, see @ref{Resizing Windows}.
1819@end itemize
1820
1821To adjust the window's width, use an entry whose @sc{car} is
1822@code{window-width} and whose @sc{cdr} is one of:
1823
1824@itemize @bullet
1825@item
1826@code{nil} means to leave the width of the new window alone.
1827
1828@item
1829A number specifies the desired width of the new window. An integer
1830number specifies the number of columns of the window. A floating point
1831number gives the fraction of the window's width with respect to the
1832width of the frame's root window.
1833
1834@item
1835If the @sc{cdr} specifies a function, that function is called with one
1836argument - the new window. The function is supposed to adjust the width
1837of the window; its return value is ignored.
1838@end itemize
1839
1840This function can fail if no window splitting can be performed for some
1841reason (e.g. if there is just one frame and it has an
1842@code{unsplittable} frame parameter; @pxref{Buffer Parameters}).
1781@end defun 1843@end defun
1782 1844
1783@defun display-buffer-use-some-window buffer alist 1845@defun display-buffer-use-some-window buffer alist
@@ -1786,6 +1848,26 @@ window and displaying the buffer in that window. It can fail if all
1786windows are dedicated to another buffer (@pxref{Dedicated Windows}). 1848windows are dedicated to another buffer (@pxref{Dedicated Windows}).
1787@end defun 1849@end defun
1788 1850
1851@defun display-buffer-below-selected buffer alist
1852This function tries to display @var{buffer} in a window below the
1853selected window. This means to either split the selected window or
1854reuse the window below the selected one.
1855@end defun
1856
1857@defun display-buffer-in-previous-window buffer alist
1858This function tries to display @var{buffer} in a window previously
1859showing it. If @var{alist} has a non-@code{nil}
1860@code{inhibit-same-window} entry, the selected window is not eligible
1861for reuse. If @var{alist} contains a @code{reusable-frames} entry, its
1862value determines which frames to search for a suitable window as with
1863@code{display-buffer-reuse-window}.
1864
1865If @var{alist} has a @code{previous-window} entry, the window
1866specified by that entry will override any other window found by the
1867methods above, even if that window never showed @var{buffer} before.
1868@end defun
1869
1870
1789@node Choosing Window Options 1871@node Choosing Window Options
1790@section Additional Options for Displaying Buffers 1872@section Additional Options for Displaying Buffers
1791 1873
@@ -2086,45 +2168,77 @@ function @code{switch-to-prev-buffer} (@pxref{Window History}).
2086Finally, you might want to either bury (@pxref{The Buffer List}) or kill 2168Finally, you might want to either bury (@pxref{The Buffer List}) or kill
2087(@pxref{Killing Buffers}) the window's buffer. 2169(@pxref{Killing Buffers}) the window's buffer.
2088 2170
2089 The following function uses information on how the window for 2171 The following command uses information on how the window for
2090displaying the buffer was obtained in the first place, thus attempting to 2172displaying the buffer was obtained in the first place, thus attempting
2091automate the above decisions for you. 2173to automate the above decisions for you.
2092 2174
2093@deffn Command quit-window &optional kill window 2175@deffn Command quit-window &optional kill window
2094This command quits @var{window} and buries its buffer. The argument 2176This command quits @var{window} and buries its buffer. The argument
2095@var{window} must be a live window and defaults to the selected one. 2177@var{window} must be a live window and defaults to the selected one.
2096With prefix argument @var{kill} non-@code{nil}, it kills the buffer 2178With prefix argument @var{kill} non-@code{nil}, it kills the buffer
2097instead of burying it. 2179instead of burying it. It calls the function @code{quit-restore-window}
2098 2180described next to deal with the window and its buffer.
2099Quitting @var{window} means to proceed as follows: If @var{window} was
2100created specially for displaying its current buffer, delete @var{window}
2101provided its frame contains at least one other live window. If
2102@var{window} is the only window on its frame and there are other frames
2103on the frame's terminal, the value of @var{kill} determines how to
2104proceed with the window. If @var{kill} is @code{nil}, the fate of the
2105frame is determined by calling @code{frame-auto-hide-function} (see
2106below) with that frame as sole argument. If @var{kill} is
2107non-@code{nil}, the frame is deleted unconditionally.
2108
2109If @var{window} was reused for displaying its buffer, this command tries
2110to display the buffer previously shown in it. It also tries to restore
2111the window start (@pxref{Window Start and End}) and point (@pxref{Window
2112Point}) positions of the previously shown buffer. If, in addition, the
2113current buffer was temporarily resized, this command will also try to
2114restore the original height of @var{window}.
2115
2116The three cases described so far require that the buffer shown in
2117@var{window} is still the buffer displayed by the last buffer display
2118function for this window. If another buffer has been shown in the
2119meantime, or the buffer previously shown no longer exists, this command
2120calls @code{switch-to-prev-buffer} (@pxref{Window History}) to show some
2121other buffer instead.
2122@end deffn 2181@end deffn
2123 2182
2124The function @code{quit-window} bases its decisions on information 2183@defun quit-restore-window &optional window bury-or-kill
2125stored in @var{window}'s @code{quit-restore} window parameter 2184This function tries to restore the state of @var{window} that existed
2126(@pxref{Window Parameters}), and resets that parameter to @code{nil} 2185before its buffer was displayed in it. The optional argument
2127after it's done. 2186@var{window} must be a live window and defaults to the selected one.
2187
2188If @var{window} was created specially for displaying its buffer, this
2189function deletes @var{window} provided its frame contains at least one
2190other live window. If @var{window} is the only window on its frame and
2191there are other frames on the frame's terminal, the value of the
2192optional argument @var{bury-or-kill} determines how to proceed with the
2193window. If @var{bury-or-kill} equals @code{kill}, the frame is deleted
2194unconditionally. Otherwise, the fate of the frame is determined by
2195calling @code{frame-auto-hide-function} (see below) with that frame as
2196sole argument.
2197
2198Otherwise, this function tries to redisplay the buffer previously shown
2199in @var{window}. It also tries to restore the window start
2200(@pxref{Window Start and End}) and point (@pxref{Window Point})
2201positions of the previously shown buffer. If, in addition,
2202@var{window}'s buffer was temporarily resized, this function will also
2203try to restore the original height of @var{window}.
2204
2205The cases described so far require that the buffer shown in @var{window}
2206is still the buffer displayed by the last buffer display function for
2207this window. If another buffer has been shown in the meantime, or the
2208buffer previously shown no longer exists, this function calls
2209@code{switch-to-prev-buffer} (@pxref{Window History}) to show some other
2210buffer instead.
2211
2212The optional argument @var{bury-or-kill} specifes how to deal with
2213@var{window}'s buffer. The following values are handled:
2214
2215@table @code
2216@item nil
2217This means to not deal with the buffer in any particular way. As a
2218consequence, if @var{window} is not deleted, invoking
2219@code{switch-to-prev-buffer} will usually show the buffer again.
2220
2221@item append
2222This means that if @var{window} is not deleted, its buffer is moved to
2223the end of @var{window}'s list of previous buffers, so it's less likely
2224that a future invocation of @code{switch-to-prev-buffer} will switch to
2225it. Also, it moves the buffer to the end of the frame's buffer list.
2226
2227@item bury
2228This means that if @var{window} is not deleted, its buffer is removed
2229from @var{window}'s list of previous buffers. Also, it moves the buffer
2230to the end of the frame's buffer list. This value provides the most
2231reliable remedy to not have @code{switch-to-prev-buffer} switch to this
2232buffer again without killing the buffer.
2233
2234@item kill
2235This means to kill @var{window}'s buffer.
2236@end table
2237
2238@code{quit-restore-window} bases its decisions on information stored in
2239@var{window}'s @code{quit-restore} window parameter (@pxref{Window
2240Parameters}), and resets that parameter to @code{nil} after it's done.
2241@end defun
2128 2242
2129The following option specifies how to deal with a frame containing just 2243The following option specifies how to deal with a frame containing just
2130one window that should be either quit, or whose buffer should be buried. 2244one window that should be either quit, or whose buffer should be buried.
@@ -2135,10 +2249,9 @@ frames. This function is called with one argument---a frame.
2135 2249
2136The function specified here is called by @code{bury-buffer} (@pxref{The 2250The function specified here is called by @code{bury-buffer} (@pxref{The
2137Buffer List}) when the selected window is dedicated and shows the buffer 2251Buffer List}) when the selected window is dedicated and shows the buffer
2138that should be buried. It is also called by @code{quit-window} (see 2252to bury. It is also called by @code{quit-restore-window} (see above)
2139above) when the frame of the window that should be quit has been 2253when the frame of the window to quit has been specially created for
2140specially created for displaying that window's buffer and the buffer 2254displaying that window's buffer and the buffer is not killed.
2141should be buried.
2142 2255
2143The default is to call @code{iconify-frame} (@pxref{Visibility of 2256The default is to call @code{iconify-frame} (@pxref{Visibility of
2144Frames}). Alternatively, you may specify either @code{delete-frame} 2257Frames}). Alternatively, you may specify either @code{delete-frame}
@@ -2146,9 +2259,9 @@ Frames}). Alternatively, you may specify either @code{delete-frame}
2146@code{ignore} to leave the frame unchanged, or any other function that 2259@code{ignore} to leave the frame unchanged, or any other function that
2147can take a frame as its sole argument. 2260can take a frame as its sole argument.
2148 2261
2149Note that the function specified by this option is called if and only if 2262Note that the function specified by this option is called only if the
2150there is at least one other frame on the terminal of the frame it's 2263specified frame contains just one live window and there is at least one
2151supposed to handle, and that frame contains only one live window. 2264other frame on the same terminal.
2152@end defopt 2265@end defopt
2153 2266
2154 2267
@@ -3123,8 +3236,8 @@ frame into the root window of that very frame only).
3123 3236
3124@defun window-state-get &optional window writable 3237@defun window-state-get &optional window writable
3125This function returns the state of @var{window} as a Lisp object. The 3238This function returns the state of @var{window} as a Lisp object. The
3126argument @var{window} can be any window and defaults to the root window 3239argument @var{window} must be a valid window and defaults to the root
3127of the selected frame. 3240window of the selected frame.
3128 3241
3129If the optional argument @var{writable} is non-@code{nil}, this means to 3242If the optional argument @var{writable} is non-@code{nil}, this means to
3130not use markers for sampling positions like @code{window-point} or 3243not use markers for sampling positions like @code{window-point} or
@@ -3267,10 +3380,28 @@ from. It is installed by @code{window-state-get} (@pxref{Window
3267Configurations}). 3380Configurations}).
3268 3381
3269@item @code{quit-restore} 3382@item @code{quit-restore}
3270This parameter specifies what to do with a window when the buffer it 3383This parameter is installed by the buffer display functions
3271shows is not needed any more. It is installed by the buffer display 3384(@pxref{Choosing Window}) and consulted by @code{quit-restore-window}
3272functions (@pxref{Choosing Window}), and consulted by the function 3385(@pxref{Quitting Windows}). It contains four elements:
3273@code{quit-window} (@pxref{Quitting Windows}). 3386
3387The first element is one of the symbols @code{window} - meaning that the
3388window has been specially created by @code{display-buffer}, @code{frame}
3389- a separate frame has been created, @code{same} - the window has
3390displayed the same buffer before, or @code{other} - the window showed
3391another buffer before.
3392
3393The second element is either one of the symbols @code{window} or
3394@code{frame}, or a list whose elements are the buffer shown in the
3395window before, that buffer's window start and window point positions,
3396and the window's height at that time.
3397
3398The third element is the window selected at the time the parameter was
3399created. The function @code{quit-restore-window} tries to reselect that
3400window when it deletes the window passed to it as argument.
3401
3402The fourth element is the buffer whose display caused the creation of
3403this parameter. @code{quit-restore-window} deletes the specified window
3404only if it still shows that buffer.
3274@end table 3405@end table
3275 3406
3276There are additional parameters @code{window-atom} and @code{window-side}; 3407There are additional parameters @code{window-atom} and @code{window-side};
diff --git a/etc/NEWS b/etc/NEWS
index 31a4909f8d9..9ece829217f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -818,7 +818,7 @@ to work out which code is doing something.
818recursive invocations. 818recursive invocations.
819 819
820** Window changes 820** Window changes
821 821+++
822*** The functions get-lru-window, get-mru-window and get-largest-window 822*** The functions get-lru-window, get-mru-window and get-largest-window
823now accept a third argument to avoid choosing the selected window. 823now accept a third argument to avoid choosing the selected window.
824 824
@@ -831,9 +831,12 @@ reused.
831 831
832*** New function `fit-frame-to-buffer' and new options 832*** New function `fit-frame-to-buffer' and new options
833`fit-frame-to-buffer' and `fit-frame-to-buffer-bottom-margin'. 833`fit-frame-to-buffer' and `fit-frame-to-buffer-bottom-margin'.
834 834+++
835*** New option switch-to-buffer-preserve-window-point to restore a
836window's point when switching buffers.
837+++
835*** New display action functions `display-buffer-below-selected', 838*** New display action functions `display-buffer-below-selected',
836`display-buffer-at-bottom' and `display-buffer-in-previous-window'. 839and `display-buffer-in-previous-window'.
837 840
838*** New display action alist entry `inhibit-switch-frame', if non-nil, 841*** New display action alist entry `inhibit-switch-frame', if non-nil,
839tells display action functions to avoid changing which frame is 842tells display action functions to avoid changing which frame is
@@ -841,10 +844,10 @@ selected.
841 844
842*** New display action alist entry `pop-up-frame-parameters', if 845*** New display action alist entry `pop-up-frame-parameters', if
843non-nil, specifies frame parameters to give any newly-created frame. 846non-nil, specifies frame parameters to give any newly-created frame.
844 847+++
845*** New display action alist entry `previous-window', if non-nil, 848*** New display action alist entry `previous-window', if non-nil,
846specifies window to reuse in `display-buffer-in-previous-window'. 849specifies window to reuse in `display-buffer-in-previous-window'.
847 850+++
848*** New display action alist entries `window-height' and `window-width' 851*** New display action alist entries `window-height' and `window-width'
849to specify size of new window created by `display-buffer'. 852to specify size of new window created by `display-buffer'.
850 853
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ab73a61d9e6..1b560651abb 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12012-11-03 Martin Rudalics <rudalics@gmx.at>
2
3 * window.el (switch-to-visible-buffer)
4 (switch-to-buffer-preserve-window-point): Fix doc-strings.
5
12012-11-01 Stephen Berman <stephen.berman@gmx.net> 62012-11-01 Stephen Berman <stephen.berman@gmx.net>
2 7
3 * play/gomoku.el (gomoku-display-statistics): Update mode line 8 * play/gomoku.el (gomoku-display-statistics): Update mode line
diff --git a/lisp/window.el b/lisp/window.el
index 10f75d44d69..be6ddf8ab9e 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -3091,10 +3091,11 @@ before was current this also makes BUFFER the current buffer."
3091 "If non-nil, allow switching to an already visible buffer. 3091 "If non-nil, allow switching to an already visible buffer.
3092If this variable is non-nil, `switch-to-prev-buffer' and 3092If this variable is non-nil, `switch-to-prev-buffer' and
3093`switch-to-next-buffer' may switch to an already visible buffer 3093`switch-to-next-buffer' may switch to an already visible buffer
3094provided the buffer was shown in the argument window before. If 3094provided the buffer was shown before in the window specified as
3095this variable is nil, `switch-to-prev-buffer' and 3095argument to those functions. If this variable is nil,
3096`switch-to-next-buffer' always try to avoid switching to a buffer 3096`switch-to-prev-buffer' and `switch-to-next-buffer' always try to
3097that is already visible in another window on the same frame." 3097avoid switching to a buffer that is already visible in another
3098window on the same frame."
3098 :type 'boolean 3099 :type 'boolean
3099 :version "24.1" 3100 :version "24.1"
3100 :group 'windows) 3101 :group 'windows)
@@ -5855,8 +5856,8 @@ window on any visible or iconified frame. If this is t, it
5855unconditionally tries to display the buffer at its previous 5856unconditionally tries to display the buffer at its previous
5856position in the selected window. 5857position in the selected window.
5857 5858
5858This variable is ignored if the the buffer is already displayed 5859This variable is ignored if the buffer is already displayed in
5859in the selected window or never appeared in it before, or if 5860the selected window or never appeared in it before, or if
5860`switch-to-buffer' calls `pop-to-buffer' to display the buffer." 5861`switch-to-buffer' calls `pop-to-buffer' to display the buffer."
5861 :type '(choice 5862 :type '(choice
5862 (const :tag "Never" nil) 5863 (const :tag "Never" nil)