Function: with-selected-frame
with-selected-frame is a macro defined in subr.el.gz.
Signature
(with-selected-frame FRAME &rest BODY)
Documentation
Execute the forms in BODY with FRAME as the selected frame.
The value returned is the value of the last form in BODY.
This macro saves and restores the selected frame, and changes the order of neither the recently selected windows nor the buffers in the buffer list.
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro with-selected-frame (frame &rest body)
"Execute the forms in BODY with FRAME as the selected frame.
The value returned is the value of the last form in BODY.
This macro saves and restores the selected frame, and changes the
order of neither the recently selected windows nor the buffers in
the buffer list."
(declare (indent 1) (debug t))
(let ((old-frame (make-symbol "old-frame"))
(old-buffer (make-symbol "old-buffer")))
`(let ((,old-frame (selected-frame))
(,old-buffer (current-buffer)))
(unwind-protect
(progn (select-frame ,frame 'norecord)
,@body)
(when (frame-live-p ,old-frame)
(select-frame ,old-frame 'norecord))
(when (buffer-live-p ,old-buffer)
(set-buffer ,old-buffer))))))