]> git.eshelyaron.com Git - emacs.git/commitdiff
* image-mode.el (image-toggle-display): Use file name if possible,
authorChong Yidong <cyd@stupidchicken.com>
Mon, 30 Jan 2006 20:44:44 +0000 (20:44 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Mon, 30 Jan 2006 20:44:44 +0000 (20:44 +0000)
instead of unnecessarily allocating a (possibly huge) lisp string.

lisp/ChangeLog
lisp/image-mode.el

index ca86a0a27b6d3dd80b4552d5f46b4b7f4254447a..5a03a2e85020af1d722d5c0b7e4d8a07a5bdd541 100644 (file)
@@ -1,3 +1,8 @@
+2006-01-30  Chong Yidong  <cyd@stupidchicken.com>
+
+       * image-mode.el (image-toggle-display): Use file name if possible,
+       instead of unnecessarily allocating a (possibly huge) lisp string.
+
 2006-01-30  John Paul Wallington  <jpw@pobox.com>
 
        * subr.el (toplevel): Define `cl-assertion-failed' condition here
index 67d1bcee995682ffec181152abbf3a29a1a01fb1..3c0544edf8984253f5f240d612314f158b64acb2 100644 (file)
@@ -137,11 +137,14 @@ 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* ((data
-           (string-make-unibyte
-            (buffer-substring-no-properties (point-min) (point-max))))
-          (image
-           (create-image data nil t))
+    (let* ((image
+           (if (and (buffer-file-name)
+                    (not (buffer-modified-p)))
+               (create-image (buffer-file-name))
+             (create-image
+              (string-make-unibyte
+               (buffer-substring-no-properties (point-min) (point-max)))
+              nil t)))
           (props
            `(display ,image
                      intangible ,image