summaryrefslogtreecommitdiff
path: root/lisp/doc-view.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2020-10-07 10:51:35 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2020-10-08 09:44:34 -0400
commitd340a979dbbd6150a3af4783cf8b3b65368bbdad (patch)
tree8e4bd1fa7e035f75102ccdee6740b2835d21ffbd /lisp/doc-view.el
parent0a5e9cf2622a0282d56cc150af5a94b5d5fd71be (diff)
downloademacs-d340a979dbbd6150a3af4783cf8b3b65368bbdad.tar.gz
* lisp/doc-view.el: Fix "can't resize root window" error
(doc-view-fit-window-to-page): Change approach to detect when the frame needs to be resized.
Diffstat (limited to 'lisp/doc-view.el')
-rw-r--r--lisp/doc-view.el30
1 files changed, 20 insertions, 10 deletions
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 8aaf38aab21..02d89650b8b 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -910,17 +910,27 @@ Resize the containing frame if needed."
(width-diff (- img-width win-width))
(height-diff (- img-height win-height))
(new-frame-params
+ ;; If we can't resize the window, try and resize the frame.
+ ;; We used to compare the `window-width/height` and the
+ ;; `frame-width/height` instead of catching the errors, but
+ ;; it's too fiddly (e.g. in the presence of the miniwindow,
+ ;; the height the frame should be equal to the height of the
+ ;; root window +1).
(append
- (if (= (window-width) (frame-width))
- `((width . (text-pixels
- . ,(+ (frame-text-width) width-diff))))
- (enlarge-window (/ width-diff (frame-char-width)) 'horiz)
- nil)
- (if (= (window-height) (frame-height))
- `((height . (text-pixels
- . ,(+ (frame-text-height) height-diff))))
- (enlarge-window (/ height-diff (frame-char-height)) nil)
- nil))))
+ (condition-case nil
+ (progn
+ (enlarge-window (/ width-diff (frame-char-width)) 'horiz)
+ nil)
+ (error
+ `((width . (text-pixels
+ . ,(+ (frame-text-width) width-diff))))))
+ (condition-case nil
+ (progn
+ (enlarge-window (/ height-diff (frame-char-height)) nil)
+ nil)
+ (error
+ `((height . (text-pixels
+ . ,(+ (frame-text-height) height-diff)))))))))
(when new-frame-params
(modify-frame-parameters (selected-frame) new-frame-params))))