summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2006-01-30 20:44:44 +0000
committerChong Yidong <cyd@stupidchicken.com>2006-01-30 20:44:44 +0000
commit2bd53dc0718af4f3184d213f096bde5bbcc46a90 (patch)
treeec8a0d1446c04240124137773b2cce20b6c002ad /lisp
parentc45c309fe28b83f7ab0c59ea225084374c783931 (diff)
downloademacs-2bd53dc0718af4f3184d213f096bde5bbcc46a90.tar.gz
* image-mode.el (image-toggle-display): Use file name if possible,
instead of unnecessarily allocating a (possibly huge) lisp string.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/image-mode.el13
2 files changed, 13 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ca86a0a27b6..5a03a2e8502 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -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
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 67d1bcee995..3c0544edf89 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -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