Managing windows and frames

Table of Contents

Window/frame commands


task window frame
make/create C-x 2, C-x 3 C-x 5 2
delete C-x 0, C-x 4 0 C-x 5 0
delete others C-x 1 C-x 5 1

Details on window functions:

keybinding function
C-x 0 (delete-window)
C-x 4 0 (kill-buffer-and-window)
C-x 2 (split-vertically)
C-x 3 (split-horizonally)

Other window/frame commands

function -other-window) -other-frame)
(find-file C-x 4 C-f C-x 5 C-f
(find-file-read-only C-x 4 r C-x 5 r
(dired C-x 4 d C-x 5 d
(switch-to-buffer C-x 4 b C-x 5 b
(display-buffer C-x 4 C-o C-x 5 C-o
(clone-indirect-buffer C-x 4 c C-x 5 c
(find-tag C-x 4 . C-x 5 .

Listing windows/frames

object function
window (window-list)
frame (frame-list)

Switching among windows/frames

keybinding function
C-x o (other-window)
C-x 5 o (other-frame)

Packages to manage window layouts

The following libraries are useful for preserving window layout within frames (but not the buffers within windows). Note: if the frame is deleted, configurations recorded by winner-mode and elscreen are lost.


Rather than using multiple frames, Elscreen can be used to manage simultaneous window configurations in a single (optionally tabbed) frame. Keybindings

APEL and elscreen should be installed. Setup here.

The following is just FYI as it is already implemented in the aprl-emacs confuration. I think there is a comparison of windows configurations between the return value of (elscreen-get-window-configuration) and the prior value saved from (elscreen-set-window-configuration). The latter function is not called when the screen is resized, so elscreen tries to redraw the frame (redraw-frame) with every keystroke.

There is probably a more elegant fix, but this just cycles through all the elscreen tabs so that the window-configuration is synced with the present frame and window geometries.

(defun elscreen-reset ()
  "Cycles through screens so that window configurations are reset 
(prevents flashing from redraw-frame[?] after each keystroke)"
  ;; only happens when number of screens > 1
  (when (> (elscreen-get-number-of-screens) 1)
    (let* ((screen-list (elscreen-get-screen-list))
           (current-screen (elscreen-get-current-screen))
           (screen-seq (append (delq current-screen screen-list)
                               (list current-screen))))
      (mapc 'elscreen-goto screen-seq))))

;; define keybinding
(define-key elscreen-map "r" 'elscreen-reset)


Setup here.

Winner-mode recalls (one of past 60) frames in current context.

The relevant keybindings are:

keybinding function
C-c <left> (winner-redo)
C-c <right> (winner-undo)


keybinding elisp function
C-x r w r (window-configuration-to-register)
C-x r f r (frame-configuration-to-register)

To recall one of these configuration, use jump-to-register (C-x r j r).

See section on registers for more information.

Emacs pages: main aprl-config

Generated by Org-mode 9.2 with Emacs 26