diff options
| author | Martin Rudalics | 2008-11-02 11:02:24 +0000 |
|---|---|---|
| committer | Martin Rudalics | 2008-11-02 11:02:24 +0000 |
| commit | ad91ba441399416d407e0cdc10a913db33bf1225 (patch) | |
| tree | d081430f3aa8f2cabc536d86a7b713d715b0f9f4 | |
| parent | e630dfc6a80f9d21f90fa43bc43bd5e94daeb7ab (diff) | |
| download | emacs-ad91ba441399416d407e0cdc10a913db33bf1225.tar.gz emacs-ad91ba441399416d407e0cdc10a913db33bf1225.zip | |
(save-selected-window-norecord): New macro
(walk-windows): Use save-selected-window-norecord and call
select-window with NORECORD set. (Bug#1237)
(set-window-text-height, fit-window-to-buffer): Use
save-selected-window-norecord and call select-window with
NORECORD set.
| -rw-r--r-- | lisp/window.el | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/lisp/window.el b/lisp/window.el index 39668b31d94..ee56075bd64 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -69,6 +69,27 @@ BODY remains selected." | |||
| 69 | (if (window-live-p save-selected-window-window) | 69 | (if (window-live-p save-selected-window-window) |
| 70 | (select-window save-selected-window-window)))))) | 70 | (select-window save-selected-window-window)))))) |
| 71 | 71 | ||
| 72 | (defmacro save-selected-window-norecord (&rest body) | ||
| 73 | "Execute BODY, then select, but do not record previously selected window. | ||
| 74 | This macro is like `save-selected-window' but changes neither the | ||
| 75 | order of recently selected windows nor the buffer list." | ||
| 76 | `(let ((save-selected-window-window (selected-window)) | ||
| 77 | ;; It is necessary to save all of these, because calling | ||
| 78 | ;; select-window changes frame-selected-window for whatever | ||
| 79 | ;; frame that window is in. | ||
| 80 | (save-selected-window-alist | ||
| 81 | (mapcar (lambda (frame) (cons frame (frame-selected-window frame))) | ||
| 82 | (frame-list)))) | ||
| 83 | (save-current-buffer | ||
| 84 | (unwind-protect | ||
| 85 | (progn ,@body) | ||
| 86 | (dolist (elt save-selected-window-alist) | ||
| 87 | (and (frame-live-p (car elt)) | ||
| 88 | (window-live-p (cdr elt)) | ||
| 89 | (set-frame-selected-window (car elt) (cdr elt) 'norecord))) | ||
| 90 | (when (window-live-p save-selected-window-window) | ||
| 91 | (select-window save-selected-window-window 'norecord)))))) | ||
| 92 | |||
| 72 | (defun window-body-height (&optional window) | 93 | (defun window-body-height (&optional window) |
| 73 | "Return number of lines in WINDOW available for actual buffer text. | 94 | "Return number of lines in WINDOW available for actual buffer text. |
| 74 | WINDOW defaults to the selected window. | 95 | WINDOW defaults to the selected window. |
| @@ -162,13 +183,20 @@ ALL-FRAMES 0 means cycle through all windows on all visible and | |||
| 162 | ALL-FRAMES a frame means cycle through all windows on that frame | 183 | ALL-FRAMES a frame means cycle through all windows on that frame |
| 163 | only. | 184 | only. |
| 164 | Anything else means cycle through all windows on WINDOW's frame | 185 | Anything else means cycle through all windows on WINDOW's frame |
| 165 | and no others." | 186 | and no others. |
| 166 | ;; If we start from the minibuffer window, don't fail to come back to it. | 187 | |
| 167 | (if (window-minibuffer-p (selected-window)) | 188 | This function changes neither the order of recently selected |
| 168 | (setq minibuf t)) | 189 | windows nor the buffer list." |
| 169 | (save-selected-window | 190 | ;; If we start from the minibuffer window, don't fail to come |
| 170 | (if (framep all-frames) | 191 | ;; back to it. |
| 171 | (select-window (frame-first-window all-frames))) | 192 | (when (window-minibuffer-p (selected-window)) |
| 193 | (setq minibuf t)) | ||
| 194 | ;; Make sure to not mess up the order of recently selected | ||
| 195 | ;; windows. Use `save-selected-window-norecord' and `select-window' | ||
| 196 | ;; with second argument non-nil for this purpose. | ||
| 197 | (save-selected-window-norecord | ||
| 198 | (when (framep all-frames) | ||
| 199 | (select-window (frame-first-window all-frames) 'norecord)) | ||
| 172 | (let* (walk-windows-already-seen | 200 | (let* (walk-windows-already-seen |
| 173 | (walk-windows-current (selected-window))) | 201 | (walk-windows-current (selected-window))) |
| 174 | (while (progn | 202 | (while (progn |
| @@ -1202,10 +1230,10 @@ where some error may be present." | |||
| 1202 | ;; bizarre displays because it also allows Emacs to make *other* | 1230 | ;; bizarre displays because it also allows Emacs to make *other* |
| 1203 | ;; windows 1-line tall, which means that there's no more space for | 1231 | ;; windows 1-line tall, which means that there's no more space for |
| 1204 | ;; the modeline. | 1232 | ;; the modeline. |
| 1205 | (let ((window-min-height (min 2 height))) ;One text line plus a modeline. | 1233 | (let ((window-min-height (min 2 height))) ; One text line plus a modeline. |
| 1206 | (if (and window (not (eq window (selected-window)))) | 1234 | (if (and window (not (eq window (selected-window)))) |
| 1207 | (save-selected-window | 1235 | (save-selected-window-norecord |
| 1208 | (select-window window) | 1236 | (select-window window 'norecord) |
| 1209 | (enlarge-window delta)) | 1237 | (enlarge-window delta)) |
| 1210 | (enlarge-window delta)))))) | 1238 | (enlarge-window delta)))))) |
| 1211 | 1239 | ||
| @@ -1322,8 +1350,8 @@ Always return nil." | |||
| 1322 | (and (eobp) (bolp) (not (bobp)))) | 1350 | (and (eobp) (bolp) (not (bobp)))) |
| 1323 | (set-window-point window (1- (window-point window)))) | 1351 | (set-window-point window (1- (window-point window)))) |
| 1324 | 1352 | ||
| 1325 | (save-selected-window | 1353 | (save-selected-window-norecord |
| 1326 | (select-window window) | 1354 | (select-window window 'norecord) |
| 1327 | 1355 | ||
| 1328 | ;; Adjust WINDOW to the nominally correct size (which may actually | 1356 | ;; Adjust WINDOW to the nominally correct size (which may actually |
| 1329 | ;; be slightly off because of variable height text, etc). | 1357 | ;; be slightly off because of variable height text, etc). |
| @@ -1373,7 +1401,7 @@ Return non-nil if the window was shrunk, nil otherwise." | |||
| 1373 | (mini (frame-parameter frame 'minibuffer)) | 1401 | (mini (frame-parameter frame 'minibuffer)) |
| 1374 | (edges (window-edges window))) | 1402 | (edges (window-edges window))) |
| 1375 | (if (and (not (eq window (frame-root-window frame))) | 1403 | (if (and (not (eq window (frame-root-window frame))) |
| 1376 | (window-safely-shrinkable-p) | 1404 | (window-safely-shrinkable-p window) |
| 1377 | (pos-visible-in-window-p (point-min) window) | 1405 | (pos-visible-in-window-p (point-min) window) |
| 1378 | (not (eq mini 'only)) | 1406 | (not (eq mini 'only)) |
| 1379 | (or (not mini) | 1407 | (or (not mini) |