Function: save-window-excursion
save-window-excursion is a macro defined in subr.el.gz.
Signature
(save-window-excursion &rest BODY)
Documentation
Execute BODY, then restore previous window configuration.
This macro saves the window configuration on the selected frame,
executes BODY, then calls set-window-configuration to restore
the saved window configuration. The return value is the last
form in BODY. The window configuration is also restored if BODY
exits nonlocally.
BEWARE: Most uses of this macro introduce bugs.
E.g. it should not be used to try and prevent some code from opening
a new window, since that window may sometimes appear in another frame,
in which case save-window-excursion cannot help.
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro save-window-excursion (&rest body)
"Execute BODY, then restore previous window configuration.
This macro saves the window configuration on the selected frame,
executes BODY, then calls `set-window-configuration' to restore
the saved window configuration. The return value is the last
form in BODY. The window configuration is also restored if BODY
exits nonlocally.
BEWARE: Most uses of this macro introduce bugs.
E.g. it should not be used to try and prevent some code from opening
a new window, since that window may sometimes appear in another frame,
in which case `save-window-excursion' cannot help."
(declare (indent 0) (debug t))
(let ((c (make-symbol "wconfig")))
`(let ((,c (current-window-configuration)))
(unwind-protect (progn ,@body)
(set-window-configuration ,c)))))