diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/window-configurations.html | |
new repository
Diffstat (limited to 'devdocs/elisp/window-configurations.html')
| -rw-r--r-- | devdocs/elisp/window-configurations.html | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/devdocs/elisp/window-configurations.html b/devdocs/elisp/window-configurations.html new file mode 100644 index 00000000..e83cec23 --- /dev/null +++ b/devdocs/elisp/window-configurations.html @@ -0,0 +1,39 @@ + <h3 class="section">Window Configurations</h3> <p>A <em>window configuration</em> records the entire layout of one frame—all windows, their sizes, their decorations, which buffers they contain, how those buffers are scrolled, and their value of point, It also includes the value of <code>minibuffer-scroll-window</code>. As a special exception, the window configuration does not record the value of point in the selected window for the current buffer. </p> <p>You can bring back an entire frame layout by restoring a previously saved window configuration. If you want to record the layout of all frames instead of just one, use a frame configuration instead of a window configuration. See <a href="frame-configurations">Frame Configurations</a>. </p> <dl> <dt id="current-window-configuration">Function: <strong>current-window-configuration</strong> <em>&optional frame</em> +</dt> <dd><p>This function returns a new object representing <var>frame</var>’s current window configuration. The default for <var>frame</var> is the selected frame. The variable <code>window-persistent-parameters</code> specifies which window parameters (if any) are saved by this function. See <a href="window-parameters">Window Parameters</a>. </p></dd> +</dl> <dl> <dt id="set-window-configuration">Function: <strong>set-window-configuration</strong> <em>configuration &optional dont-set-frame dont-set-miniwindow</em> +</dt> <dd> +<p>This function restores the configuration of windows and buffers as specified by <var>configuration</var>, for the frame that <var>configuration</var> was created for, regardless of whether that frame is selected or not. The argument <var>configuration</var> must be a value that was previously returned by <code>current-window-configuration</code> for that frame. Normally the function also selects the frame which is recorded in the configuration, but if <var>dont-set-frame</var> is non-<code>nil</code>, it leaves selected the frame which was already selected at the start of the function. </p> <p>Normally the function restores the saved minibuffer (if any), but if <var>dont-set-miniwindow</var> is non-<code>nil</code>, the minibuffer current at the start of the function (if any) remains in the mini-window. </p> <p>If the frame from which <var>configuration</var> was saved is dead, all this function does is to restore the value of the variable <code>minibuffer-scroll-window</code> and to adjust the value returned by <code>minibuffer-selected-window</code>. In this case, the function returns <code>nil</code>. Otherwise, it returns <code>t</code>. </p> <p>If the buffer of a window of <var>configuration</var> has been killed since <var>configuration</var> was made, that window is, as a rule, removed from the restored configuration. However, if that window is the last window remaining in the restored configuration, another live buffer is shown in it. </p> <p>Here is a way of using this function to get the same effect as <code>save-window-excursion</code>: </p> <div class="example"> <pre class="example">(let ((config (current-window-configuration))) + (unwind-protect + (progn (split-window-below nil) + …) + (set-window-configuration config))) +</pre> +</div> </dd> +</dl> <dl> <dt id="save-window-excursion">Macro: <strong>save-window-excursion</strong> <em>forms…</em> +</dt> <dd> +<p>This macro records the window configuration of the selected frame, executes <var>forms</var> in sequence, then restores the earlier window configuration. The return value is the value of the final form in <var>forms</var>. </p> <p>Most Lisp code should not use this macro; <code>save-selected-window</code> is typically sufficient. In particular, this macro cannot reliably prevent the code in <var>forms</var> from opening new windows, because new windows might be opened in other frames (see <a href="choosing-window">Choosing Window</a>), and <code>save-window-excursion</code> only saves and restores the window configuration on the current frame. </p> +</dd> +</dl> <dl> <dt id="window-configuration-p">Function: <strong>window-configuration-p</strong> <em>object</em> +</dt> <dd><p>This function returns <code>t</code> if <var>object</var> is a window configuration. </p></dd> +</dl> <dl> <dt id="compare-window-configurations">Function: <strong>compare-window-configurations</strong> <em>config1 config2</em> +</dt> <dd><p>This function compares two window configurations as regards the structure of windows, but ignores the values of point and the saved scrolling positions—it can return <code>t</code> even if those aspects differ. </p></dd> +</dl> <dl> <dt id="window-configuration-frame">Function: <strong>window-configuration-frame</strong> <em>config</em> +</dt> <dd><p>This function returns the frame for which the window configuration <var>config</var> was made. </p></dd> +</dl> <p>Other primitives to look inside of window configurations would make sense, but are not implemented because we did not need them. See the file <samp>winner.el</samp> for some more operations on windows configurations. </p> <p>The objects returned by <code>current-window-configuration</code> die together with the Emacs process. In order to store a window configuration on disk and read it back in another Emacs session, you can use the functions described next. These functions are also useful to clone the state of a frame into an arbitrary live window (<code>set-window-configuration</code> effectively clones the windows of a frame into the root window of that very frame only). </p> <dl> <dt id="window-state-get">Function: <strong>window-state-get</strong> <em>&optional window writable</em> +</dt> <dd> +<p>This function returns the state of <var>window</var> as a Lisp object. The argument <var>window</var> must be a valid window and defaults to the root window of the selected frame. </p> <p>If the optional argument <var>writable</var> is non-<code>nil</code>, this means to not use markers for sampling positions like <code>window-point</code> or <code>window-start</code>. This argument should be non-<code>nil</code> when the state will be written to disk and read back in another session. </p> <p>Together, the argument <var>writable</var> and the variable <code>window-persistent-parameters</code> specify which window parameters are saved by this function. See <a href="window-parameters">Window Parameters</a>. </p> +</dd> +</dl> <p>The value returned by <code>window-state-get</code> can be used in the same session to make a clone of a window in another window. It can be also written to disk and read back in another session. In either case, use the following function to restore the state of the window. </p> <dl> <dt id="window-state-put">Function: <strong>window-state-put</strong> <em>state &optional window ignore</em> +</dt> <dd> +<p>This function puts the window state <var>state</var> into <var>window</var>. The argument <var>state</var> should be the state of a window returned by an earlier invocation of <code>window-state-get</code>, see above. The optional argument <var>window</var> can be either a live window or an internal window (see <a href="windows-and-frames">Windows and Frames</a>). If <var>window</var> is not a live window, it is replaced by a new live window created on the same frame before putting <var>state</var> into it. If <var>window</var> is <code>nil</code>, it puts the window state into a new window. </p> <p>If the optional argument <var>ignore</var> is non-<code>nil</code>, it means to ignore minimum window sizes and fixed-size restrictions. If <var>ignore</var> is <code>safe</code>, this means windows can get as small as one line and/or two columns. </p> +</dd> +</dl> <p>The functions <code>window-state-get</code> and <code>window-state-put</code> also allow to exchange the contents of two live windows. The following function does precisely that: </p> <dl> <dt id="window-swap-states">Command: <strong>window-swap-states</strong> <em>&optional window-1 window-2 size</em> +</dt> <dd> +<p>This command swaps the states of the two live windows <var>window-1</var> and <var>window-2</var>. <var>window-1</var> must specify a live window and defaults to the selected one. <var>window-2</var> must specify a live window and defaults to the window following <var>window-1</var> in the cyclic ordering of windows, excluding minibuffer windows and including live windows on all visible frames. </p> <p>Optional argument <var>size</var> non-<code>nil</code> means to try swapping the sizes of <var>window-1</var> and <var>window-2</var> as well. A value of <code>height</code> means to swap heights only, a value of <code>width</code> means to swap widths only, while <code>t</code> means to swap both widths and heights, if possible. Frames are not resized by this function. </p> +</dd> +</dl><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br> + <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Configurations.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Configurations.html</a> + </p> +</div> |
