summaryrefslogtreecommitdiff
path: root/devdocs/elisp/frame-layouts-with-side-windows.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/frame-layouts-with-side-windows.html')
-rw-r--r--devdocs/elisp/frame-layouts-with-side-windows.html59
1 files changed, 59 insertions, 0 deletions
diff --git a/devdocs/elisp/frame-layouts-with-side-windows.html b/devdocs/elisp/frame-layouts-with-side-windows.html
new file mode 100644
index 00000000..978474d0
--- /dev/null
+++ b/devdocs/elisp/frame-layouts-with-side-windows.html
@@ -0,0 +1,59 @@
+ <h4 class="subsection">Frame Layouts with Side Windows</h4> <p>Side windows can be used to create more complex frame layouts like those provided by integrated development environments (IDEs). In such layouts, the area of the main window is where the normal editing activities take place. Side windows are not conceived for editing in the usual sense. Rather, they are supposed to display information complementary to the current editing activity, like lists of files, tags or buffers, help information, search or grep results or shell output. </p> <p>The layout of such a frame might appear as follows: </p> <div class="example"> <pre class="example"> ___________________________________
+ | *Buffer List* |
+ |___________________________________|
+ | | | |
+ | * | | * |
+ | d | | T |
+ | i | | a |
+ | r | Main Window Area | g |
+ | e | | s |
+ | d | | * |
+ | * | | |
+ |_____|_______________________|_____|
+ | *help*/*grep*/ | *shell*/ |
+ | *Completions* | *compilation* |
+ |_________________|_________________|
+ | Echo Area |
+ |___________________________________|
+
+
+</pre>
+</div> <p>The following example illustrates how window parameters (see <a href="window-parameters">Window Parameters</a>) can be used with <code>display-buffer-in-side-window</code> (see <a href="displaying-buffers-in-side-windows">Displaying Buffers in Side Windows</a>) to set up code for producing the frame layout sketched above. </p> <div class="example"> <pre class="example">(defvar parameters
+ '(window-parameters . ((no-other-window . t)
+ (no-delete-other-windows . t))))
+
+(setq fit-window-to-buffer-horizontally t)
+(setq window-resize-pixelwise t)
+
+(setq
+ display-buffer-alist
+ `(("\\*Buffer List\\*" display-buffer-in-side-window
+ (side . top) (slot . 0) (window-height . fit-window-to-buffer)
+ (preserve-size . (nil . t)) ,parameters)
+ ("\\*Tags List\\*" display-buffer-in-side-window
+ (side . right) (slot . 0) (window-width . fit-window-to-buffer)
+ (preserve-size . (t . nil)) ,parameters)
+ ("\\*\\(?:help\\|grep\\|Completions\\)\\*"
+ display-buffer-in-side-window
+ (side . bottom) (slot . -1) (preserve-size . (nil . t))
+ ,parameters)
+ ("\\*\\(?:shell\\|compilation\\)\\*" display-buffer-in-side-window
+ (side . bottom) (slot . 1) (preserve-size . (nil . t))
+ ,parameters)))
+</pre>
+</div> <p>This specifies <code>display-buffer-alist</code> entries (see <a href="choosing-window">Choosing Window</a>) for buffers with fixed names. In particular, it asks for showing <samp>*Buffer List*</samp> with adjustable height at the top of the frame and <samp>*Tags List*</samp> with adjustable width on the frame’s right. It also asks for having the <samp>*help*</samp>, <samp>*grep*</samp> and <samp>*Completions*</samp> buffers share a window on the bottom left side of the frame and the <samp>*shell*</samp> and <samp>*compilation*</samp> buffers appear in a window on the bottom right side of the frame. </p> <p>Note that the option <code>fit-window-to-buffer-horizontally</code> must have a non-<code>nil</code> value in order to allow horizontal adjustment of windows. Entries are also added that ask for preserving the height of side windows at the top and bottom of the frame and the width of side windows at the left or right of the frame. To assure that side windows retain their respective sizes when maximizing the frame, the variable <code>window-resize-pixelwise</code> is set to a non-<code>nil</code> value. See <a href="resizing-windows">Resizing Windows</a>. </p> <p>The last form also makes sure that none of the created side windows are accessible via <kbd><span class="nolinebreak">C-x</span> o</kbd> by installing the <code>no-other-window</code> parameter for each of these windows. In addition, it makes sure that side windows are not deleted via <kbd><span class="nolinebreak">C-x</span> 1</kbd> by installing the <code>no-delete-other-windows</code> parameter for each of these windows. </p> <p>Since <code>dired</code> buffers have no fixed names, we use a special function <code>dired-default-directory-on-left</code> in order to display a lean directory buffer on the left side of the frame. </p> <div class="example"> <pre class="example">(defun dired-default-directory-on-left ()
+ "Display `default-directory' in side window on left, hiding details."
+ (interactive)
+ (let ((buffer (dired-noselect default-directory)))
+ (with-current-buffer buffer (dired-hide-details-mode t))
+ (display-buffer-in-side-window
+ buffer `((side . left) (slot . 0)
+ (window-width . fit-window-to-buffer)
+ (preserve-size . (t . nil)) ,parameters))))
+</pre>
+</div> <p>Evaluating the preceding forms and typing, in any order, <kbd><span class="nolinebreak">M-x</span> <span class="nolinebreak">list-buffers</span></kbd>, <kbd>C-h f</kbd>, <kbd>M-x shell</kbd>, <kbd><span class="nolinebreak">M-x</span> <span class="nolinebreak">list-tags</span></kbd>, and <kbd>M-x dired-default-directory-on-left</kbd> should now reproduce the frame layout sketched above. </p><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 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/Frame-Layouts-with-Side-Windows.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Frame-Layouts-with-Side-Windows.html</a>
+ </p>
+</div>