aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/window.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/window.el')
-rw-r--r--lisp/window.el34
1 files changed, 21 insertions, 13 deletions
diff --git a/lisp/window.el b/lisp/window.el
index 09fac6c520f..75052f9a5f1 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -40,11 +40,18 @@ unless you explicitly change the size, or Emacs has no other choice.")
40 40
41(defmacro save-selected-window (&rest body) 41(defmacro save-selected-window (&rest body)
42 "Execute BODY, then select the window that was selected before BODY. 42 "Execute BODY, then select the window that was selected before BODY.
43Also restore the selected window of each frame as it was at the start 43The value returned is the value of the last form in BODY.
44of this construct. 44
45However, if a window has become dead, don't get an error, 45This macro saves and restores the current buffer, since otherwise
46just refrain from reselecting it. 46its normal operation could potentially make a different
47Return the value of the last form in BODY." 47buffer current. It does not alter the buffer list ordering.
48
49This macro saves and restores the selected window, as well as
50the selected window in each frame. If the previously selected
51window of some frame is no longer live at the end of BODY, that
52frame's selected window is left alone. If the selected window is
53no longer live, then whatever window is selected at the end of
54BODY remains selected."
48 `(let ((save-selected-window-window (selected-window)) 55 `(let ((save-selected-window-window (selected-window))
49 ;; It is necessary to save all of these, because calling 56 ;; It is necessary to save all of these, because calling
50 ;; select-window changes frame-selected-window for whatever 57 ;; select-window changes frame-selected-window for whatever
@@ -52,14 +59,15 @@ Return the value of the last form in BODY."
52 (save-selected-window-alist 59 (save-selected-window-alist
53 (mapcar (lambda (frame) (list frame (frame-selected-window frame))) 60 (mapcar (lambda (frame) (list frame (frame-selected-window frame)))
54 (frame-list)))) 61 (frame-list))))
55 (unwind-protect 62 (save-current-buffer
56 (progn ,@body) 63 (unwind-protect
57 (dolist (elt save-selected-window-alist) 64 (progn ,@body)
58 (and (frame-live-p (car elt)) 65 (dolist (elt save-selected-window-alist)
59 (window-live-p (cadr elt)) 66 (and (frame-live-p (car elt))
60 (set-frame-selected-window (car elt) (cadr elt)))) 67 (window-live-p (cadr elt))
61 (if (window-live-p save-selected-window-window) 68 (set-frame-selected-window (car elt) (cadr elt))))
62 (select-window save-selected-window-window))))) 69 (if (window-live-p save-selected-window-window)
70 (select-window save-selected-window-window))))))
63 71
64(defun window-body-height (&optional window) 72(defun window-body-height (&optional window)
65 "Return number of lines in window WINDOW for actual buffer text. 73 "Return number of lines in window WINDOW for actual buffer text.