Source

emacs.d / __dss-recursive-edit.el

Full commit
;; http://www.emacswiki.org/emacs/RecursiveEditPreservingWindowConfig
;; inspired by Erik Naggum's `recursive-edit-with-single-window'
(defmacro recursive-edit-preserving-window-config (body)
  "*Return a command that enters a recursive edit after executing BODY.
 Upon exiting the recursive edit (with\\[exit-recursive-edit] (exit)
 or \\[abort-recursive-edit] (abort)), restore window configuration
 in current frame."
  `(lambda ()
     "See the documentation for `recursive-edit-preserving-window-config'."
     (interactive)
     (save-window-excursion
       ,body
       (recursive-edit))))

(global-set-key (kbd "C-c 0") (recursive-edit-preserving-window-config (delete-window)))
(global-set-key (kbd "C-c 1") (recursive-edit-preserving-window-config
                               (if (one-window-p 'ignore-minibuffer)
                                   (error "Current window is the only window in its frame")
                                 (delete-other-windows))))