New control structure: with-selected-frame.
authorKaroly Lorentey <lorentey@elte.hu>
Sun, 23 May 2004 02:26:21 +0000 (02:26 +0000)
committerKaroly Lorentey <lorentey@elte.hu>
Sun, 23 May 2004 02:26:21 +0000 (02:26 +0000)
lisp/subr.el (with-selected-frame): New macro.
lisp/font-lock.el (lisp-font-lock-keywords-2): Add with-selected-frame.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-168

lisp/font-lock.el
lisp/subr.el

index 044c414..96caba5 100644 (file)
@@ -1893,7 +1893,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
                    "with-current-buffer" "with-electric-help"
                    "with-local-quit" "with-no-warnings"
                    "with-output-to-string" "with-output-to-temp-buffer"
-                   "with-selected-window" "with-syntax-table"
+                   "with-selected-window" "with-selected-frame" "with-syntax-table"
                    "with-temp-buffer" "with-temp-file" "with-temp-message"
                    "with-timeout" "with-timeout-handler") t)
             "\\>")
index 5302558..8559de2 100644 (file)
@@ -1812,6 +1812,18 @@ See also `with-temp-buffer'."
           ;; This is where the code differs from save-selected-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.