summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 3bdef5988ce..4818d37156b 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1784,6 +1784,18 @@ See also `with-temp-buffer'."
(if (window-live-p save-selected-window-window)
(select-window save-selected-window-window 'norecord)))))
+(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.
+See also `with-temp-buffer'."
+ (declare (indent 1) (debug t))
+ `(let ((save-selected-frame (selected-frame)))
+ (unwind-protect
+ (progn (select-frame ,frame)
+ ,@body)
+ (if (frame-live-p save-selected-frame)
+ (select-frame save-selected-frame)))))
+
(defmacro with-temp-file (file &rest body)
"Create a new buffer, evaluate BODY there, and write the buffer to FILE.
The value returned is the value of the last form in BODY.