Mercurial > emacs
comparison lisp/subr.el @ 99327:d646820f5ba2
(with-selected-window): Call set-frame-selected-window
with new argument NORECORD set. Update doc-string.
(with-selected-frame): Call select-frame with new argument
NORECORD set. Update doc-string.
author | Martin Rudalics <rudalics@gmx.at> |
---|---|
date | Sun, 02 Nov 2008 11:02:58 +0000 |
parents | fc215de0bf93 |
children | d0975c52c7cc |
comparison
equal
deleted
inserted
replaced
99326:100dbcced8f3 | 99327:d646820f5ba2 |
---|---|
2497 | 2497 |
2498 (defmacro with-selected-window (window &rest body) | 2498 (defmacro with-selected-window (window &rest body) |
2499 "Execute the forms in BODY with WINDOW as the selected window. | 2499 "Execute the forms in BODY with WINDOW as the selected window. |
2500 The value returned is the value of the last form in BODY. | 2500 The value returned is the value of the last form in BODY. |
2501 | 2501 |
2502 This macro saves and restores the current buffer, since otherwise | 2502 This macro saves and restores the selected window, as well as the |
2503 its normal operation could potentially make a different | 2503 selected window of each frame. It does not change the order of |
2504 buffer current. It does not alter the buffer list ordering. | 2504 recently selected windows. If the previously selected window of |
2505 | 2505 some frame is no longer live at the end of BODY, that frame's |
2506 This macro saves and restores the selected window, as well as | 2506 selected window is left alone. If the selected window is no |
2507 the selected window in each frame. If the previously selected | 2507 longer live, then whatever window is selected at the end of BODY |
2508 window of some frame is no longer live at the end of BODY, that | 2508 remains selected. |
2509 frame's selected window is left alone. If the selected window is | 2509 |
2510 no longer live, then whatever window is selected at the end of | 2510 This macro uses `save-current-buffer' to save and restore the |
2511 BODY remains selected. | 2511 current buffer, since otherwise its normal operation could |
2512 See also `with-temp-buffer'." | 2512 potentially make a different buffer current. It does not alter |
2513 the buffer list ordering." | |
2513 (declare (indent 1) (debug t)) | 2514 (declare (indent 1) (debug t)) |
2514 ;; Most of this code is a copy of save-selected-window. | 2515 ;; Most of this code is a copy of save-selected-window. |
2515 `(let ((save-selected-window-window (selected-window)) | 2516 `(let ((save-selected-window-window (selected-window)) |
2516 ;; It is necessary to save all of these, because calling | 2517 ;; It is necessary to save all of these, because calling |
2517 ;; select-window changes frame-selected-window for whatever | 2518 ;; select-window changes frame-selected-window for whatever |
2524 (progn (select-window ,window 'norecord) | 2525 (progn (select-window ,window 'norecord) |
2525 ,@body) | 2526 ,@body) |
2526 (dolist (elt save-selected-window-alist) | 2527 (dolist (elt save-selected-window-alist) |
2527 (and (frame-live-p (car elt)) | 2528 (and (frame-live-p (car elt)) |
2528 (window-live-p (cadr elt)) | 2529 (window-live-p (cadr elt)) |
2529 (set-frame-selected-window (car elt) (cadr elt)))) | 2530 (set-frame-selected-window (car elt) (cadr elt) 'norecord))) |
2530 (if (window-live-p save-selected-window-window) | 2531 (when (window-live-p save-selected-window-window) |
2531 (select-window save-selected-window-window 'norecord)))))) | 2532 (select-window save-selected-window-window 'norecord)))))) |
2532 | 2533 |
2533 (defmacro with-selected-frame (frame &rest body) | 2534 (defmacro with-selected-frame (frame &rest body) |
2534 "Execute the forms in BODY with FRAME as the selected frame. | 2535 "Execute the forms in BODY with FRAME as the selected frame. |
2535 The value returned is the value of the last form in BODY. | 2536 The value returned is the value of the last form in BODY. |
2536 See also `with-temp-buffer'." | 2537 |
2538 This macro neither changes the order of recently selected windows | |
2539 nor the buffer list." | |
2537 (declare (indent 1) (debug t)) | 2540 (declare (indent 1) (debug t)) |
2538 (let ((old-frame (make-symbol "old-frame")) | 2541 (let ((old-frame (make-symbol "old-frame")) |
2539 (old-buffer (make-symbol "old-buffer"))) | 2542 (old-buffer (make-symbol "old-buffer"))) |
2540 `(let ((,old-frame (selected-frame)) | 2543 `(let ((,old-frame (selected-frame)) |
2541 (,old-buffer (current-buffer))) | 2544 (,old-buffer (current-buffer))) |
2542 (unwind-protect | 2545 (unwind-protect |
2543 (progn (select-frame ,frame) | 2546 (progn (select-frame ,frame 'norecord) |
2544 ,@body) | 2547 ,@body) |
2545 (if (frame-live-p ,old-frame) | 2548 (when (frame-live-p ,old-frame) |
2546 (select-frame ,old-frame)) | 2549 (select-frame ,old-frame 'norecord)) |
2547 (if (buffer-live-p ,old-buffer) | 2550 (when (buffer-live-p ,old-buffer) |
2548 (set-buffer ,old-buffer)))))) | 2551 (set-buffer ,old-buffer)))))) |
2549 | 2552 |
2550 (defmacro with-temp-file (file &rest body) | 2553 (defmacro with-temp-file (file &rest body) |
2551 "Create a new buffer, evaluate BODY there, and write the buffer to FILE. | 2554 "Create a new buffer, evaluate BODY there, and write the buffer to FILE. |
2552 The value returned is the value of the last form in BODY. | 2555 The value returned is the value of the last form in BODY. |
2553 See also `with-temp-buffer'." | 2556 See also `with-temp-buffer'." |