diff options
| author | Richard M. Stallman | 2005-06-25 14:03:27 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-06-25 14:03:27 +0000 |
| commit | 7db3c58f2ccd13850536ee2746b9e24984574dfe (patch) | |
| tree | c05c6ff67e4a371347bc712f00af34b22283cb42 | |
| parent | 3e215e3007e1fafab6c19731e3cdeb2fbab7dc6b (diff) | |
| download | emacs-7db3c58f2ccd13850536ee2746b9e24984574dfe.tar.gz emacs-7db3c58f2ccd13850536ee2746b9e24984574dfe.zip | |
(save-selected-window): Use save-current-buffer.
| -rw-r--r-- | lisp/window.el | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/lisp/window.el b/lisp/window.el index 09fac6c520f..69008e194f7 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. |
| 43 | Also restore the selected window of each frame as it was at the start | 43 | The value returned is the value of the last form in BODY. |
| 44 | of this construct. | 44 | |
| 45 | However, if a window has become dead, don't get an error, | 45 | This macro saves and restores the current buffer, since otherwise |
| 46 | just refrain from reselecting it. | 46 | its normal operation could potentially make a different |
| 47 | Return the value of the last form in BODY." | 47 | buffer current. It does not alter the buffer list ordering, |
| 48 | |||
| 49 | This macro saves and restores the selected window, as well as | ||
| 50 | the selected window in each frame. If the previously selected | ||
| 51 | window of some frame is no longer live at the end of BODY, that | ||
| 52 | frame's selected window is left alone. If the selected window is | ||
| 53 | no longer live, then whatever window is selected at the end of | ||
| 54 | BODY 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. |