summaryrefslogtreecommitdiff
path: root/lisp/image.el
diff options
context:
space:
mode:
authorDave Love <fx@gnu.org>2000-06-12 20:36:40 +0000
committerDave Love <fx@gnu.org>2000-06-12 20:36:40 +0000
commit0dc91c572f0e5dc98f0543d27d0cd71f9b2ac429 (patch)
tree371e0d3d7142bd01aadbad502ce140e62dc8c086 /lisp/image.el
parentc68833d2cadec9c4ff62040a9e5e2fcfb0099db5 (diff)
downloademacs-0dc91c572f0e5dc98f0543d27d0cd71f9b2ac429.tar.gz
(insert-image): Save a little consing.
Diffstat (limited to 'lisp/image.el')
-rw-r--r--lisp/image.el19
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/image.el b/lisp/image.el
index 9b04784ec00..339e176c223 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -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)))))