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.
The layout of such a frame might appear as follows:
| *Buffer List* |
| | | |
| * | | * |
| d | | T |
| i | | a |
| r | Main Window Area | g |
| e | | s |
| d | | * |
| * | | |
| *help*/*grep*/ | *shell*/ |
| *Completions* | *compilation* |
| Echo Area |
The following example illustrates how window parameters (see Window Parameters) can be used with
display-buffer-in-side-window (see Displaying Buffers in Side Windows) to set up code for producing the frame layout sketched above.
'(window-parameters . ((no-other-window . t)
(no-delete-other-windows . t))))
(setq fit-window-to-buffer-horizontally t)
(setq window-resize-pixelwise t)
`(("\\*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)
(side . bottom) (slot . -1) (preserve-size . (nil . t))
(side . bottom) (slot . 1) (preserve-size . (nil . t))
display-buffer-alist entries (see Choosing Window) for buffers with fixed names. In particular, it asks for showing
*Buffer List* with adjustable height at the top of the frame and
*Tags List* with adjustable width on the frame’s right. It also asks for having the
*Completions* buffers share a window on the bottom left side of the frame and the
*compilation* buffers appear in a window on the bottom right side of the frame.
Note that the option
fit-window-to-buffer-horizontally must have a non-
nil 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
window-resize-pixelwise is set to a non-
nil value. See Resizing Windows.
The last form also makes sure that none of the created side windows are accessible via
C-x o by installing the
no-other-window parameter for each of these windows. In addition, it makes sure that side windows are not deleted via
C-x 1 by installing the
no-delete-other-windows parameter for each of these windows.
dired buffers have no fixed names, we use a special function
dired-default-directory-on-left in order to display a lean directory buffer on the left side of the frame.
(defun dired-default-directory-on-left ()
"Display `default-directory' in side window on left, hiding details."
(let ((buffer (dired-noselect default-directory)))
(with-current-buffer buffer (dired-hide-details-mode t))
buffer `((side . left) (slot . 0)
(window-width . fit-window-to-buffer)
(preserve-size . (t . nil)) ,parameters))))
Evaluating the preceding forms and typing, in any order,
M-x list-tags, and
M-x dired-default-directory-on-left should now reproduce the frame layout sketched above.