]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix auto-revert resizing in image mode
authorCarlos Pita <carlosjosepita@gmail.com>
Sun, 23 Jun 2019 20:49:47 +0000 (22:49 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 23 Jun 2019 20:50:46 +0000 (22:50 +0200)
* lisp/image-mode.el (image-transform-properties): Get image
parameters right after reverting; in particular, compute the
correct max size (bug#33631).

lisp/image-mode.el

index fa1362c471b5f480e3fd872c7dcd0fedb21fe4ed..5c30f4085c34f278e8ae7478a5ed52bcd5e83750 100644 (file)
@@ -736,8 +736,7 @@ was inserted."
         ;; If we have a `fit-width' or a `fit-height', don't limit
         ;; the size of the image to the window size.
         (edges (and (null image-transform-resize)
-                    (window-inside-pixel-edges
-                     (get-buffer-window (current-buffer)))))
+                    (window-inside-pixel-edges (get-buffer-window))))
         (type (if (image--imagemagick-wanted-p filename)
                   'imagemagick
                 (image-type file-or-data nil data-p)))
@@ -1150,6 +1149,7 @@ compiled with ImageMagick support."
     ;; Note: `image-size' looks up and thus caches the untransformed
     ;; image.  There's no easy way to prevent that.
     (let* ((size (image-size spec t))
+           (edges (window-inside-pixel-edges (get-buffer-window)))
           (resized
            (cond
             ((numberp image-transform-resize)
@@ -1159,13 +1159,11 @@ compiled with ImageMagick support."
             ((eq image-transform-resize 'fit-width)
              (image-transform-fit-width
               (car size) (cdr size)
-              (- (nth 2 (window-inside-pixel-edges))
-                 (nth 0 (window-inside-pixel-edges)))))
+              (- (nth 2 edges) (nth 0 edges))))
             ((eq image-transform-resize 'fit-height)
              (let ((res (image-transform-fit-width
                          (cdr size) (car size)
-                         (- (nth 3 (window-inside-pixel-edges))
-                            (nth 1 (window-inside-pixel-edges))))))
+                         (- (nth 3 edges) (nth 1 edges)))))
                (cons (cdr res) (car res)))))))
       `(,@(when (car resized)
            (list :width (car resized)))