emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master bc0adf1: Make shr-rescale-image respect get-buffer-


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master bc0adf1: Make shr-rescale-image respect get-buffer-window again
Date: Thu, 16 May 2019 07:55:06 -0400 (EDT)

branch: master
commit bc0adf112d82a9b89f858f80e04f1ee2f401fa05
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Make shr-rescale-image respect get-buffer-window again
    
    * lisp/net/shr.el (shr-rescale-image): Partially revert previous
    change -- ressurrect the check for `get-buffer-window'.
---
 lisp/net/shr.el | 56 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 29 insertions(+), 27 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 3ff0c24..c1e9fdd 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1101,36 +1101,38 @@ WIDTH and HEIGHT are the sizes given in the HTML data, 
if any.
 The size of the displayed image will not exceed
 MAX-WIDTH/MAX-HEIGHT.  If not given, use the current window
 width/height instead."
-  (let* ((edges (window-inside-pixel-edges
-                 (get-buffer-window (current-buffer))))
-         (max-width (truncate (* shr-max-image-proportion
-                                 (or max-width
-                                     (- (nth 2 edges) (nth 0 edges))))))
-         (max-height (truncate (* shr-max-image-proportion
-                                  (or max-height
-                                      (- (nth 3 edges) (nth 1 edges))))))
-         (scaling (image-compute-scaling-factor image-scaling-factor)))
-    (when (or (and width
-                   (> width max-width))
-              (and height
-                   (> height max-height)))
-      (setq width nil
-            height nil))
-    (if (and width height
-             (< (* width scaling) max-width)
-             (< (* height scaling) max-height))
+  (if (not (get-buffer-window (current-buffer)))
+      (create-image data nil t :ascent 100)
+    (let* ((edges (window-inside-pixel-edges
+                   (get-buffer-window (current-buffer))))
+           (max-width (truncate (* shr-max-image-proportion
+                                   (or max-width
+                                       (- (nth 2 edges) (nth 0 edges))))))
+           (max-height (truncate (* shr-max-image-proportion
+                                    (or max-height
+                                        (- (nth 3 edges) (nth 1 edges))))))
+           (scaling (image-compute-scaling-factor image-scaling-factor)))
+      (when (or (and width
+                     (> width max-width))
+                (and height
+                     (> height max-height)))
+        (setq width nil
+              height nil))
+      (if (and width height
+               (< (* width scaling) max-width)
+               (< (* height scaling) max-height))
+          (create-image
+           data nil t
+           :ascent 100
+           :width width
+           :height height
+           :format content-type)
         (create-image
          data nil t
          :ascent 100
-         :width width
-         :height height
-         :format content-type)
-      (create-image
-       data nil t
-       :ascent 100
-       :max-width max-width
-       :max-height max-height
-       :format content-type))))
+         :max-width max-width
+         :max-height max-height
+         :format content-type)))))
 
 ;; url-cache-extract autoloads url-cache.
 (declare-function url-cache-create-filename "url-cache" (url))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]