]> code.delx.au - gnu-emacs/commitdiff
(insert-image): Save a little consing.
authorDave Love <fx@gnu.org>
Mon, 12 Jun 2000 20:36:40 +0000 (20:36 +0000)
committerDave Love <fx@gnu.org>
Mon, 12 Jun 2000 20:36:40 +0000 (20:36 +0000)
lisp/ChangeLog
lisp/image.el

index c3ad921c2b43bd93958e4bef70ab1519528ae634..a9a821112cc2eca5d7be96f1d36f48730b21f279 100644 (file)
@@ -1,3 +1,7 @@
+2000-06-12  Dave Love  <fx@gnu.org>
+
+       * image.el (insert-image): Save a little consing.
+
 2000-06-12  Kenichi Handa  <handa@etl.go.jp>
 
        * language/tibet-util.el: Convert all tibetan-1-column characters
index 9b04784ec0071b0fef514cdc4df67e2584a16f14..339e176c223df899c0b02a9e7db5e7b72046b069 100644 (file)
@@ -151,15 +151,22 @@ means display it in the right marginal area."
     (error "Not an image: %s" image))
   (unless (or (null area) (memq area '(left-margin right-margin)))
     (error "Invalid area %s" area))
-  (when area
-    (setq image (list (list 'margin area) image)))
+  (if area
+      (setq image (list (list 'margin area) image))
+    ;; Cons up a new spec equal but not eq to `image' so that
+    ;; inserting it twice in a row (adjacently) displays two copies of
+    ;; the image.  Don't try to avoid this by looking at the display
+    ;; properties on either side so that we DTRT more often with
+    ;; cut-and-paste.  (Yanking killed image text next to another copy
+    ;; of it loses anyway.)
+    (setq image (cons 'image (cdr image))))
   (let ((start (point)))
     (insert string)
-    ;; Copy `image' so that inserting it twice in a row (adjacently)
-    ;; displays two copies of the image.
     (add-text-properties start (point)
-                        (list 'display (copy-sequence image)
-                              'intangible (list t) ; something unique
+                        (list 'display image
+                              ;; `image' has the right properties to
+                              ;; mark an intangible field.
+                              'intangible image
                               'rear-nonsticky (list 'display)))))