Function: window-toggle-side-windows

window-toggle-side-windows is an interactive and byte-compiled function defined in window.el.gz.

Signature

(window-toggle-side-windows &optional FRAME)

Documentation

Toggle display of side windows on specified FRAME.

FRAME must be a live frame and defaults to the selected one.

If FRAME has at least one side window, delete all side windows on FRAME after saving FRAME's state in the FRAME's window-state frame parameter. Otherwise, restore any side windows recorded in FRAME's window-state parameter, leaving FRAME's main window alone. Signal an error if FRAME has no side windows and no saved state for it is found.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window-toggle-side-windows (&optional frame)
  "Toggle display of side windows on specified FRAME.
FRAME must be a live frame and defaults to the selected one.

If FRAME has at least one side window, delete all side
windows on FRAME after saving FRAME's state in the
FRAME's `window-state' frame parameter.  Otherwise,
restore any side windows recorded in FRAME's `window-state'
parameter, leaving FRAME's main window alone.  Signal an
error if FRAME has no side windows and no saved state for
it is found."
  (interactive)
  (let* ((frame (window-normalize-frame frame))
         (window--sides-inhibit-check t)
         state)
    (cond
     ((window-with-parameter 'window-side nil frame)
      ;; At least one side window exists.  Remove all side windows after
      ;; saving FRAME's state in its `window-state' parameter.
      (set-frame-parameter
       frame 'window-state (window-state-get (frame-root-window frame)))
      (let ((ignore-window-parameters t))
        (delete-other-windows (window-main-window frame))))
     ((setq state (frame-parameter frame 'window-state))
      ;; A window state was saved for FRAME.  Restore it and put the
      ;; current root window into its main window.
      (let ((window-combination-resize t)
            (main-state (window-state-get (frame-root-window frame))))
        (window-state-put state (frame-root-window frame) t)
        (window-state-put main-state (window-main-window frame)))
      (window--sides-reverse-frame frame))
     (t
      (error "No side windows state found")))))