mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-04 11:40:22 +00:00
(with-selected-window): Use save-current-buffer.
This commit is contained in:
parent
198081c871
commit
4c6d1e1617
27
lisp/subr.el
27
lisp/subr.el
@ -1717,8 +1717,12 @@ See also `with-temp-buffer'."
|
|||||||
(defmacro with-selected-window (window &rest body)
|
(defmacro with-selected-window (window &rest body)
|
||||||
"Execute the forms in BODY with WINDOW as the selected window.
|
"Execute the forms in BODY with WINDOW as the selected window.
|
||||||
The value returned is the value of the last form in BODY.
|
The value returned is the value of the last form in BODY.
|
||||||
This does not alter the buffer list ordering.
|
|
||||||
This function saves and restores the selected window, as well as
|
This macro saves and restores the current buffer, since otherwise
|
||||||
|
its normal operation could potentially make a different
|
||||||
|
buffer current. It does not alter the buffer list ordering.
|
||||||
|
|
||||||
|
This macro saves and restores the selected window, as well as
|
||||||
the selected window in each frame. If the previously selected
|
the selected window in each frame. If the previously selected
|
||||||
window of some frame is no longer live at the end of BODY, that
|
window of some frame is no longer live at the end of BODY, that
|
||||||
frame's selected window is left alone. If the selected window is
|
frame's selected window is left alone. If the selected window is
|
||||||
@ -1734,15 +1738,16 @@ See also `with-temp-buffer'."
|
|||||||
(save-selected-window-alist
|
(save-selected-window-alist
|
||||||
(mapcar (lambda (frame) (list frame (frame-selected-window frame)))
|
(mapcar (lambda (frame) (list frame (frame-selected-window frame)))
|
||||||
(frame-list))))
|
(frame-list))))
|
||||||
(unwind-protect
|
(save-current-buffer
|
||||||
(progn (select-window ,window 'norecord)
|
(unwind-protect
|
||||||
,@body)
|
(progn (select-window ,window 'norecord)
|
||||||
(dolist (elt save-selected-window-alist)
|
,@body)
|
||||||
(and (frame-live-p (car elt))
|
(dolist (elt save-selected-window-alist)
|
||||||
(window-live-p (cadr elt))
|
(and (frame-live-p (car elt))
|
||||||
(set-frame-selected-window (car elt) (cadr elt))))
|
(window-live-p (cadr elt))
|
||||||
(if (window-live-p save-selected-window-window)
|
(set-frame-selected-window (car elt) (cadr elt))))
|
||||||
(select-window save-selected-window-window 'norecord)))))
|
(if (window-live-p save-selected-window-window)
|
||||||
|
(select-window save-selected-window-window 'norecord))))))
|
||||||
|
|
||||||
(defmacro with-temp-file (file &rest body)
|
(defmacro with-temp-file (file &rest body)
|
||||||
"Create a new buffer, evaluate BODY there, and write the buffer to FILE.
|
"Create a new buffer, evaluate BODY there, and write the buffer to FILE.
|
||||||
|
Loading…
Reference in New Issue
Block a user