Temporary Obsessions       Archives

Dedicate a window with Emacs

Sometimes it's handy to "dedicate" a window with Emacs, which means that only the current buffer is displayed in that window, which is usually in its own frame on a multi-window display. It is still possible to split the window for another buffer to be shown.

Sometimes I use this to keep around a window for a log of my work during the day. It's much more convenient if it doesn't get taken over by anything else.

Here's a handy function to make a window dedicated, or to "undedicate" it:

(defun dedicate-window (&optional arg)
  "Set current window to be dedicated.
With prefix ARG, undedicate it."
  (interactive "P")
  (set-window-dedicated-p (get-buffer-window (current-buffer)) (not arg))
  (message (if arg
               "Window '%s' is normal"
             "Window '%s' is dedicated")
           (current-buffer)))