diff options
| author | Martin Rudalics | 2017-04-15 16:16:26 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2017-04-15 16:16:26 +0200 |
| commit | 23d3eeb798c7edc27898b0dbd4c2364a6ca6247d (patch) | |
| tree | a0b22ccde7f4652a4d1e1d1016b7dcb2b8e84dd7 | |
| parent | 28718c4449972640c39a7be1b62ccc7f50c6e801 (diff) | |
| download | emacs-23d3eeb798c7edc27898b0dbd4c2364a6ca6247d.tar.gz emacs-23d3eeb798c7edc27898b0dbd4c2364a6ca6247d.zip | |
Fix bugs in `with-displayed-buffer-window' and `fit-window-to-buffer'
* lisp/window.el (with-displayed-buffer-window): When a
'window-height' action alist entry specifies a function, call
`temp-buffer-window-show' with a '(window-height . t)' dummy
entry so `window--try-to-split-window' will bind
`window-combination-limit' to t and that function does not
resize any other window but the one we split this one off
(Bug#25055, Bug#25179).
(fit-window-to-buffer): Call `window-max-delta' with NOUP t so
we steal space only from windows in the same combination.
Stealing space from other windows would not allow us to return
that space later when this window is deleted (Bug#25055,
Bug#25179).
| -rw-r--r-- | lisp/window.el | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/lisp/window.el b/lisp/window.el index f4a834c0d8c..8b07ed462c9 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -235,14 +235,27 @@ displays the buffer specified by BUFFER-OR-NAME before running BODY." | |||
| 235 | (vquit-function quit-function)) | 235 | (vquit-function quit-function)) |
| 236 | `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) | 236 | `(let* ((,buffer (temp-buffer-window-setup ,vbuffer-or-name)) |
| 237 | (standard-output ,buffer) | 237 | (standard-output ,buffer) |
| 238 | ;; If a 'window-height' entry specifies a function, | ||
| 239 | ;; remember it here in order to call it below but replace | ||
| 240 | ;; the entry so `window--try-to-split-window' will bind | ||
| 241 | ;; `window-combination-limit' to t and the function does | ||
| 242 | ;; not resize any other window but the one we split this | ||
| 243 | ;; one off (Bug#25055, Bug#25179). | ||
| 244 | (vheight-function | ||
| 245 | (let ((window-height (assq 'window-height (cdr ,vaction)))) | ||
| 246 | (when (functionp (cdr window-height)) | ||
| 247 | (cdr window-height)))) | ||
| 248 | (vaction-copied | ||
| 249 | (when vheight-function | ||
| 250 | (cons (car , vaction) | ||
| 251 | (cons | ||
| 252 | '(window-height . t) | ||
| 253 | (assq-delete-all | ||
| 254 | 'window-height (cdr (copy-sequence ,vaction))))))) | ||
| 238 | ,window ,value) | 255 | ,window ,value) |
| 239 | (with-current-buffer ,buffer | 256 | (with-current-buffer ,buffer |
| 240 | (setq ,window (temp-buffer-window-show | 257 | (setq ,window (temp-buffer-window-show |
| 241 | ,buffer | 258 | ,buffer (or vaction-copied ,vaction)))) |
| 242 | ;; Remove window-height when it's handled below. | ||
| 243 | (if (functionp (cdr (assq 'window-height (cdr ,vaction)))) | ||
| 244 | (assq-delete-all 'window-height (copy-sequence ,vaction)) | ||
| 245 | ,vaction)))) | ||
| 246 | 259 | ||
| 247 | (let ((inhibit-read-only t) | 260 | (let ((inhibit-read-only t) |
| 248 | (inhibit-modification-hooks t)) | 261 | (inhibit-modification-hooks t)) |
| @@ -250,9 +263,10 @@ displays the buffer specified by BUFFER-OR-NAME before running BODY." | |||
| 250 | 263 | ||
| 251 | (set-window-point ,window (point-min)) | 264 | (set-window-point ,window (point-min)) |
| 252 | 265 | ||
| 253 | (when (functionp (cdr (assq 'window-height (cdr ,vaction)))) | 266 | (when vheight-function |
| 254 | (ignore-errors | 267 | (ignore-errors |
| 255 | (funcall (cdr (assq 'window-height (cdr ,vaction))) ,window))) | 268 | (set-window-parameter ,window 'preserve-size nil) |
| 269 | (funcall vheight-function ,window))) | ||
| 256 | 270 | ||
| 257 | (when (consp (cdr (assq 'preserve-size (cdr ,vaction)))) | 271 | (when (consp (cdr (assq 'preserve-size (cdr ,vaction)))) |
| 258 | (window-preserve-size | 272 | (window-preserve-size |
| @@ -8152,12 +8166,12 @@ accessible position." | |||
| 8152 | (min | 8166 | (min |
| 8153 | (+ total-height | 8167 | (+ total-height |
| 8154 | (window-max-delta | 8168 | (window-max-delta |
| 8155 | window nil window nil nil nil pixelwise)) | 8169 | window nil window nil t nil pixelwise)) |
| 8156 | (if pixelwise | 8170 | (if pixelwise |
| 8157 | (* char-height max-height) | 8171 | (* char-height max-height) |
| 8158 | max-height)) | 8172 | max-height)) |
| 8159 | (+ total-height (window-max-delta | 8173 | (+ total-height (window-max-delta |
| 8160 | window nil window nil nil nil pixelwise)))) | 8174 | window nil window nil t nil pixelwise)))) |
| 8161 | height) | 8175 | height) |
| 8162 | (cond | 8176 | (cond |
| 8163 | ;; If WINDOW is vertically combined, try to resize it | 8177 | ;; If WINDOW is vertically combined, try to resize it |
| @@ -8209,12 +8223,12 @@ accessible position." | |||
| 8209 | (if (numberp max-width) | 8223 | (if (numberp max-width) |
| 8210 | (min (+ total-width | 8224 | (min (+ total-width |
| 8211 | (window-max-delta | 8225 | (window-max-delta |
| 8212 | window t window nil nil nil pixelwise)) | 8226 | window t window nil t nil pixelwise)) |
| 8213 | (if pixelwise | 8227 | (if pixelwise |
| 8214 | (* char-width max-width) | 8228 | (* char-width max-width) |
| 8215 | max-width)) | 8229 | max-width)) |
| 8216 | (+ total-width (window-max-delta | 8230 | (+ total-width (window-max-delta |
| 8217 | window t window nil nil nil pixelwise)))) | 8231 | window t window nil t nil pixelwise)))) |
| 8218 | ;; When fitting horizontally, assume that WINDOW's | 8232 | ;; When fitting horizontally, assume that WINDOW's |
| 8219 | ;; start position remains unaltered. WINDOW can't get | 8233 | ;; start position remains unaltered. WINDOW can't get |
| 8220 | ;; wider than its frame's pixel width, its height | 8234 | ;; wider than its frame's pixel width, its height |