diff options
| author | Eric Abrahamsen | 2017-03-24 12:10:06 -0700 |
|---|---|---|
| committer | Eric Abrahamsen | 2017-03-25 09:56:28 -0700 |
| commit | 0a911b68eae3e295139609b1ad94b70a4d421f9b (patch) | |
| tree | 278b3524b1ee5d0e548648eb1db2223ad025deae | |
| parent | 501d07981ed1840ae72fe7dd599ab0b9f85b4a7f (diff) | |
| download | emacs-0a911b68eae3e295139609b1ad94b70a4d421f9b.tar.gz emacs-0a911b68eae3e295139609b1ad94b70a4d421f9b.zip | |
Expand manual section on quitting windows
* doc/lispref/windows.texi (Quitting Windows): Provide more
information about the elements of the quit-restore window parameter,
and how they affect the behavior of quit-restore-window.
| -rw-r--r-- | doc/lispref/windows.texi | 108 |
1 files changed, 65 insertions, 43 deletions
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index a4f8400170e..6aa9591e09f 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -2803,12 +2803,13 @@ put it in the selected window. | |||
| 2803 | @section Window History | 2803 | @section Window History |
| 2804 | @cindex window history | 2804 | @cindex window history |
| 2805 | 2805 | ||
| 2806 | Each window remembers in a list the buffers it has previously displayed, | 2806 | Each window remembers in a list the buffers it has previously |
| 2807 | and the order in which these buffers were removed from it. This history | 2807 | displayed, and the order in which these buffers were removed from it. |
| 2808 | is used, for example, by @code{replace-buffer-in-windows} | 2808 | This history is used, for example, by @code{replace-buffer-in-windows} |
| 2809 | (@pxref{Buffers and Windows}). The list is automatically maintained by | 2809 | (@pxref{Buffers and Windows}), and when quitting windows |
| 2810 | Emacs, but you can use the following functions to explicitly inspect or | 2810 | (@pxref{Quitting Windows}). The list is automatically maintained by |
| 2811 | alter it: | 2811 | Emacs, but you can use the following functions to explicitly inspect |
| 2812 | or alter it: | ||
| 2812 | 2813 | ||
| 2813 | @defun window-prev-buffers &optional window | 2814 | @defun window-prev-buffers &optional window |
| 2814 | This function returns a list specifying the previous contents of | 2815 | This function returns a list specifying the previous contents of |
| @@ -2994,33 +2995,35 @@ described next to deal with the window and its buffer. | |||
| 2994 | @end deffn | 2995 | @end deffn |
| 2995 | 2996 | ||
| 2996 | @defun quit-restore-window &optional window bury-or-kill | 2997 | @defun quit-restore-window &optional window bury-or-kill |
| 2997 | This function tries to restore the state of @var{window} that existed | 2998 | This function handles @var{window} and its buffer after quitting. The |
| 2998 | before its buffer was displayed in it. The optional argument | 2999 | optional argument @var{window} must be a live window and defaults to |
| 2999 | @var{window} must be a live window and defaults to the selected one. | 3000 | the selected one. The function's behavior is determined by the four |
| 3001 | elements of the @code{quit-restore} window parameter (@pxref{Window | ||
| 3002 | Parameters}), which is set to nil afterwards. | ||
| 3003 | |||
| 3004 | The window is deleted entirely if: 1) the first element of the | ||
| 3005 | @code{quit-restore} parameter is one of 'window or 'frame, 2) the | ||
| 3006 | window has no history of previously-displayed buffers, and 3) the | ||
| 3007 | displayed buffer matches the one in the fourth element of the | ||
| 3008 | @code{quit-restore} parameter. If @var{window} is the | ||
| 3009 | only window on its frame and there are other frames on the frame's | ||
| 3010 | terminal, the value of the optional argument @var{bury-or-kill} | ||
| 3011 | determines how to proceed with the window. If @var{bury-or-kill} | ||
| 3012 | equals @code{kill}, the frame is deleted unconditionally. Otherwise, | ||
| 3013 | the fate of the frame is determined by calling | ||
| 3014 | @code{frame-auto-hide-function} (see below) with that frame as sole | ||
| 3015 | argument. | ||
| 3000 | 3016 | ||
| 3001 | If @var{window} was created specially for displaying its buffer, this | 3017 | If the third element of the @code{quit-restore} parameter is a list of |
| 3002 | function deletes @var{window} provided its frame contains at least one | 3018 | buffer, window start (@pxref{Window Start and End}), and point |
| 3003 | other live window. If @var{window} is the only window on its frame and | 3019 | (@pxref{Window Point}), and that buffer is still live, the buffer will |
| 3004 | there are other frames on the frame's terminal, the value of the | 3020 | be displayed, and start and point set accordingly. If, in addition, |
| 3005 | optional argument @var{bury-or-kill} determines how to proceed with the | ||
| 3006 | window. If @var{bury-or-kill} equals @code{kill}, the frame is deleted | ||
| 3007 | unconditionally. Otherwise, the fate of the frame is determined by | ||
| 3008 | calling @code{frame-auto-hide-function} (see below) with that frame as | ||
| 3009 | sole argument. | ||
| 3010 | |||
| 3011 | Otherwise, this function tries to redisplay the buffer previously shown | ||
| 3012 | in @var{window}. It also tries to restore the window start | ||
| 3013 | (@pxref{Window Start and End}) and point (@pxref{Window Point}) | ||
| 3014 | positions of the previously shown buffer. If, in addition, | ||
| 3015 | @var{window}'s buffer was temporarily resized, this function will also | 3021 | @var{window}'s buffer was temporarily resized, this function will also |
| 3016 | try to restore the original height of @var{window}. | 3022 | try to restore the original height of @var{window}. |
| 3017 | 3023 | ||
| 3018 | The cases described so far require that the buffer shown in @var{window} | 3024 | Otherwise, if @var{window} was previously used for displaying other |
| 3019 | is still the buffer displayed by the last buffer display function for | 3025 | buffers (@pxref{Window History}), the most recent buffer in that |
| 3020 | this window. If another buffer has been shown in the meantime, or the | 3026 | history will be displayed. |
| 3021 | buffer previously shown no longer exists, this function calls | ||
| 3022 | @code{switch-to-prev-buffer} (@pxref{Window History}) to show some other | ||
| 3023 | buffer instead. | ||
| 3024 | 3027 | ||
| 3025 | The optional argument @var{bury-or-kill} specifies how to deal with | 3028 | The optional argument @var{bury-or-kill} specifies how to deal with |
| 3026 | @var{window}'s buffer. The following values are handled: | 3029 | @var{window}'s buffer. The following values are handled: |
| @@ -3048,9 +3051,24 @@ buffer again without killing the buffer. | |||
| 3048 | This means to kill @var{window}'s buffer. | 3051 | This means to kill @var{window}'s buffer. |
| 3049 | @end table | 3052 | @end table |
| 3050 | 3053 | ||
| 3051 | @code{quit-restore-window} bases its decisions on information stored in | 3054 | Typically, the display routines run by @code{display-buffer} will set |
| 3052 | @var{window}'s @code{quit-restore} window parameter (@pxref{Window | 3055 | the @code{quit-restore} window parameter correctly. It's also |
| 3053 | Parameters}), and resets that parameter to @code{nil} after it's done. | 3056 | possible to set it manually, using the following code for displaying |
| 3057 | @var{buffer} in @var{window}: | ||
| 3058 | |||
| 3059 | @example | ||
| 3060 | @group | ||
| 3061 | (display-buffer-record-window type window buffer) | ||
| 3062 | |||
| 3063 | (set-window-buffer window buffer) | ||
| 3064 | |||
| 3065 | (set-window-prev-buffers window nil) | ||
| 3066 | @end group | ||
| 3067 | @end example | ||
| 3068 | |||
| 3069 | Setting the window history to nil ensures that a future call to | ||
| 3070 | @code{quit-window} can delete the window altogether. | ||
| 3071 | |||
| 3054 | @end defun | 3072 | @end defun |
| 3055 | 3073 | ||
| 3056 | The following option specifies how to deal with a frame containing just | 3074 | The following option specifies how to deal with a frame containing just |
| @@ -4845,25 +4863,32 @@ This parameter is installed by the buffer display functions | |||
| 4845 | (@pxref{Choosing Window}) and consulted by @code{quit-restore-window} | 4863 | (@pxref{Choosing Window}) and consulted by @code{quit-restore-window} |
| 4846 | (@pxref{Quitting Windows}). It contains four elements: | 4864 | (@pxref{Quitting Windows}). It contains four elements: |
| 4847 | 4865 | ||
| 4848 | The first element is one of the symbols @code{window}, meaning that the | 4866 | The first element is one of the symbols @code{window}, meaning that |
| 4849 | window has been specially created by @code{display-buffer}; @code{frame}, | 4867 | the window has been specially created by @code{display-buffer}; |
| 4850 | a separate frame has been created; @code{same}, the window has | 4868 | @code{frame}, a separate frame has been created; @code{same}, the |
| 4851 | displayed the same buffer before; or @code{other}, the window showed | 4869 | window has only ever displayed this buffer; or @code{other}, the |
| 4852 | another buffer before. | 4870 | window showed another buffer before. @code{frame} and @code{window} |
| 4871 | affect how the window is quit, while @code{same} and @code{other} | ||
| 4872 | affect the redisplay of buffers previously shown in this window. | ||
| 4853 | 4873 | ||
| 4854 | The second element is either one of the symbols @code{window} or | 4874 | The second element is either one of the symbols @code{window} or |
| 4855 | @code{frame}, or a list whose elements are the buffer shown in the | 4875 | @code{frame}, or a list whose elements are the buffer shown in the |
| 4856 | window before, that buffer's window start and window point positions, | 4876 | window before, that buffer's window start and window point positions, |
| 4857 | and the window's height at that time. | 4877 | and the window's height at that time. If that buffer is still live |
| 4878 | when the window is quit, then the function @code{quit-restore-window} | ||
| 4879 | reuses the window to display the buffer. | ||
| 4858 | 4880 | ||
| 4859 | The third element is the window selected at the time the parameter was | 4881 | The third element is the window selected at the time the parameter was |
| 4860 | created. The function @code{quit-restore-window} tries to reselect that | 4882 | created. If @code{quit-restore-window} deletes the window passed to |
| 4861 | window when it deletes the window passed to it as argument. | 4883 | it as argument, it then tries to reselect this window. |
| 4862 | 4884 | ||
| 4863 | The fourth element is the buffer whose display caused the creation of | 4885 | The fourth element is the buffer whose display caused the creation of |
| 4864 | this parameter. @code{quit-restore-window} deletes the specified window | 4886 | this parameter. @code{quit-restore-window} deletes the specified window |
| 4865 | only if it still shows that buffer. | 4887 | only if it still shows that buffer. |
| 4866 | 4888 | ||
| 4889 | See the description of @code{quit-restore-window} in @ref{Quitting | ||
| 4890 | Windows} for details. | ||
| 4891 | |||
| 4867 | @item @code{window-side} @code{window-slot} | 4892 | @item @code{window-side} @code{window-slot} |
| 4868 | These parameters are used for implementing side windows (@pxref{Side | 4893 | These parameters are used for implementing side windows (@pxref{Side |
| 4869 | Windows}). | 4894 | Windows}). |
| @@ -4894,9 +4919,6 @@ applications. It might be replaced by an improved solution in future | |||
| 4894 | versions of Emacs. | 4919 | versions of Emacs. |
| 4895 | @end table | 4920 | @end table |
| 4896 | 4921 | ||
| 4897 | The @code{window-atom} parameter is used for implementing atomic windows. | ||
| 4898 | |||
| 4899 | |||
| 4900 | @node Window Hooks | 4922 | @node Window Hooks |
| 4901 | @section Hooks for Window Scrolling and Changes | 4923 | @section Hooks for Window Scrolling and Changes |
| 4902 | @cindex hooks for window operations | 4924 | @cindex hooks for window operations |