diff lisp/image-file.el @ 90203:187d6a1f84f7

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-71 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 485-492) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 92-94) - Merge from emacs--cvs-trunk--0 - Update from CVS
author Miles Bader <miles@gnu.org>
date Fri, 22 Jul 2005 08:27:27 +0000
parents f9a65d7ebd29 a0c4a6096f55
children 890cc78a5a24
line wrap: on
line diff
--- a/lisp/image-file.el	Tue Jul 19 02:58:20 2005 +0000
+++ b/lisp/image-file.el	Fri Jul 22 08:27:27 2005 +0000
@@ -118,6 +118,7 @@
 	      (create-image data nil t))
 	     (props
 	      `(display ,image
+			yank-handler (image-file-yank-handler)
 			intangible ,image
 			rear-nonsticky (display intangible)
 			;; This a cheap attempt to make the whole buffer
@@ -135,6 +136,19 @@
 	  (setq truncate-lines t))))
     rval))
 
+;; We use a yank-handler to make yanked images unique, so that
+;; yanking two copies of the same image next to each other are
+;; recognized as two different images.
+(defun image-file-yank-handler (string)
+  "Yank handler for inserting an image into a buffer."
+  (let ((image (get-text-property 0 'display string)))
+    (if (consp image)
+	(put-text-property 0 (length string)
+			   'display
+			   (cons (car image) (cdr image))
+			   string))
+    (insert string)))
+
 (put 'image-file-handler 'safe-magic t)
 (defun image-file-handler (operation &rest args)
   "Filename handler for inserting image files.