]> git.eshelyaron.com Git - emacs.git/commitdiff
(image-toggle-display): Use image-refresh.
authorChong Yidong <cyd@stupidchicken.com>
Tue, 7 Aug 2007 16:40:29 +0000 (16:40 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Tue, 7 Aug 2007 16:40:29 +0000 (16:40 +0000)
lisp/image-mode.el

index deacf38c48df6b8668b7a216cd5b723f7681ec3a..7604d2911e2be4cb2bdbaf3aca7f452fb6b34423 100644 (file)
@@ -295,16 +295,17 @@ and showing the image as an image."
            (message "Repeat this command to go back to displaying the image")))
     ;; Turn the image data into a real image, but only if the whole file
     ;; was inserted
-    (let* ((image
-           (if (and (buffer-file-name)
-                    (not (file-remote-p (buffer-file-name)))
+    (let* ((filename (buffer-file-name))
+          (image
+           (if (and filename
+                    (file-readable-p filename)
+                    (not (file-remote-p filename))
                     (not (buffer-modified-p))
                     (not (and (boundp 'archive-superior-buffer)
                               archive-superior-buffer))
                     (not (and (boundp 'tar-superior-buffer)
                               tar-superior-buffer)))
-               (progn (clear-image-cache)
-                      (create-image (buffer-file-name)))
+               (create-image filename)
              (create-image
               (string-make-unibyte
                (buffer-substring-no-properties (point-min) (point-max)))
@@ -313,13 +314,11 @@ and showing the image as an image."
            `(display ,image
                      intangible ,image
                      rear-nonsticky (display intangible)
-                     ;; This a cheap attempt to make the whole buffer
-                     ;; read-only when we're visiting the file (as
-                     ;; opposed to just inserting it).
                      read-only t front-sticky (read-only)))
           (inhibit-read-only t)
           (buffer-undo-list t)
           (modified (buffer-modified-p)))
+      (image-refresh image)
       (add-text-properties (point-min) (point-max) props)
       (set-buffer-modified-p modified)
       ;; Inhibit the cursor when the buffer contains only an image,