aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2005-07-21 08:56:23 +0000
committerKim F. Storm2005-07-21 08:56:23 +0000
commit6ed554f2ac35c8cf4365c7bb435e99cf54122ff3 (patch)
tree433a06b3a088d146655f67a742215f7b7b347545
parent3a7f4c189c171c9f72135b785cb3df6ce6e35024 (diff)
downloademacs-6ed554f2ac35c8cf4365c7bb435e99cf54122ff3.tar.gz
emacs-6ed554f2ac35c8cf4365c7bb435e99cf54122ff3.zip
(insert-image-file): Add yank-handler.
(image-file-yank-handler): Yank handler to make unique copies of images when they are yanked into a buffer next to each other.
-rw-r--r--lisp/image-file.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/image-file.el b/lisp/image-file.el
index 8f74dd63c0a..be95470184c 100644
--- a/lisp/image-file.el
+++ b/lisp/image-file.el
@@ -118,6 +118,7 @@ the command `insert-file-contents'."
118 (create-image data nil t)) 118 (create-image data nil t))
119 (props 119 (props
120 `(display ,image 120 `(display ,image
121 yank-handler (image-file-yank-handler)
121 intangible ,image 122 intangible ,image
122 rear-nonsticky (display intangible) 123 rear-nonsticky (display intangible)
123 ;; This a cheap attempt to make the whole buffer 124 ;; This a cheap attempt to make the whole buffer
@@ -135,6 +136,19 @@ the command `insert-file-contents'."
135 (setq truncate-lines t)))) 136 (setq truncate-lines t))))
136 rval)) 137 rval))
137 138
139;; We use a yank-handler to make yanked images unique, so that
140;; yanking two copies of the same image next to each other are
141;; recognized as two different images.
142(defun image-file-yank-handler (string)
143 "Yank handler for inserting an image into a buffer."
144 (let ((image (get-text-property 0 'display string)))
145 (if (consp image)
146 (put-text-property 0 (length string)
147 'display
148 (cons (car image) (cdr image))
149 string))
150 (insert string)))
151
138(put 'image-file-handler 'safe-magic t) 152(put 'image-file-handler 'safe-magic t)
139(defun image-file-handler (operation &rest args) 153(defun image-file-handler (operation &rest args)
140 "Filename handler for inserting image files. 154 "Filename handler for inserting image files.