Mercurial > emacs
comparison lisp/image.el @ 25816:2d53a03a3baa
(put-image, insert-image): Add string argument.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sat, 25 Sep 1999 19:57:50 +0000 |
parents | 697b28471784 |
children | fdc2bd91cf63 |
comparison
equal
deleted
inserted
replaced
25815:768a5bb054df | 25816:2d53a03a3baa |
---|---|
89 (when (image-type-available-p type) | 89 (when (image-type-available-p type) |
90 (append (list 'image :type type :file file) props))) | 90 (append (list 'image :type type :file file) props))) |
91 | 91 |
92 | 92 |
93 ;;;###autoload | 93 ;;;###autoload |
94 (defun put-image (image pos &optional area) | 94 (defun put-image (image pos string &optional area) |
95 "Put image IMAGE in front of POS in the current buffer. | 95 "Put image IMAGE in front of POS in the current buffer. |
96 IMAGE must be an image created with `create-image' or `defimage'. | 96 IMAGE must be an image created with `create-image' or `defimage'. |
97 IMAGE is displayed by putting an overlay into the current buffer with a | |
98 `before-string' STRING that has a `display' property whose value is the | |
99 image. | |
97 POS may be an integer or marker. | 100 POS may be an integer or marker. |
98 AREA is where to display the image. AREA nil or omitted means | 101 AREA is where to display the image. AREA nil or omitted means |
99 display it in the text area, a value of `left-margin' means | 102 display it in the text area, a value of `left-margin' means |
100 display it in the left marginal area, a value of `right-margin' | 103 display it in the left marginal area, a value of `right-margin' |
101 means display it in the right marginal area. | 104 means display it in the right marginal area." |
102 IMAGE is displayed by putting an overlay into the current buffer with a | |
103 `before-string' that has a `display' property whose value is the | |
104 image." | |
105 (let ((buffer (current-buffer))) | 105 (let ((buffer (current-buffer))) |
106 (unless (eq (car image) 'image) | 106 (unless (eq (car image) 'image) |
107 (error "Not an image: %s" image)) | 107 (error "Not an image: %s" image)) |
108 (unless (or (null area) (memq area '(left-margin right-margin))) | 108 (unless (or (null area) (memq area '(left-margin right-margin))) |
109 (error "Invalid area %s" area)) | 109 (error "Invalid area %s" area)) |
110 (setq string (copy-sequence string)) | |
110 (let ((overlay (make-overlay pos pos buffer)) | 111 (let ((overlay (make-overlay pos pos buffer)) |
111 (string (make-string 1 ?x)) | 112 (prop (if (null area) image (list (list 'margin area) image)))) |
112 (prop (if (null area) image (cons area image)))) | 113 (put-text-property 0 (length string) 'display prop string) |
113 (put-text-property 0 1 'display prop string) | |
114 (overlay-put overlay 'put-image t) | 114 (overlay-put overlay 'put-image t) |
115 (overlay-put overlay 'before-string string)))) | 115 (overlay-put overlay 'before-string string)))) |
116 | 116 |
117 | 117 |
118 ;;;###autoload | 118 ;;;###autoload |
119 (defun insert-image (image &optional area) | 119 (defun insert-image (image string &optional area) |
120 "Insert IMAGE into current buffer at point. | 120 "Insert IMAGE into current buffer at point. |
121 IMAGE is displayed by inserting STRING into the current buffer | |
122 with a `display' property whose value is the image. | |
121 AREA is where to display the image. AREA nil or omitted means | 123 AREA is where to display the image. AREA nil or omitted means |
122 display it in the text area, a value of `left-margin' means | 124 display it in the text area, a value of `left-margin' means |
123 display it in the left marginal area, a value of `right-margin' | 125 display it in the left marginal area, a value of `right-margin' |
124 means display it in the right marginal area. | 126 means display it in the right marginal area." |
125 IMAGE is displayed by inserting an \"x\" into the current buffer | |
126 having a `display' property whose value is the image." | |
127 (unless (eq (car image) 'image) | 127 (unless (eq (car image) 'image) |
128 (error "Not an image: %s" image)) | 128 (error "Not an image: %s" image)) |
129 (unless (or (null area) (memq area '(left-margin right-margin))) | 129 (unless (or (null area) (memq area '(left-margin right-margin))) |
130 (error "Invalid area %s" area)) | 130 (error "Invalid area %s" area)) |
131 (insert "x") | 131 (when area |
132 (add-text-properties (1- (point)) (point) | 132 (setq image (list (list 'margin area) image))) |
133 (list 'display (if (null area) image (cons area image)) | 133 (let ((start (point))) |
134 'rear-nonsticky (list 'display)))) | 134 (insert string) |
135 (add-text-properties start (point) | |
136 (list 'display image | |
137 'rear-nonsticky (list 'display))))) | |
135 | 138 |
136 | 139 |
137 ;;;###autoload | 140 ;;;###autoload |
138 (defun remove-images (start end &optional buffer) | 141 (defun remove-images (start end &optional buffer) |
139 "Remove images between START and END in BUFFER. | 142 "Remove images between START and END in BUFFER. |