aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-02-10 10:49:20 +1100
committerLars Ingebrigtsen2016-02-10 11:01:03 +1100
commit34662c20bc0f0d6cc40af99ab830a80bc4952258 (patch)
treee489bfc701dd5b22fab972db71571e28c4b62107
parent812cddf3060322cc5c59b2864b206e8ddc04e6fe (diff)
downloademacs-34662c20bc0f0d6cc40af99ab830a80bc4952258.tar.gz
emacs-34662c20bc0f0d6cc40af99ab830a80bc4952258.zip
Move non-compat Gnus functions to gnus-util.el
* lisp/gnus/gnus-util.el (gnus-remove-image, gnus-put-image) (gnus-create-image, gnus-image-type-available-p): Move here from gnus-ems.el, since these aren't compat functions.
-rw-r--r--lisp/gnus/gnus-ems.el51
-rw-r--r--lisp/gnus/gnus-util.el48
2 files changed, 48 insertions, 51 deletions
diff --git a/lisp/gnus/gnus-ems.el b/lisp/gnus/gnus-ems.el
index f72031b82dd..a4c091e4de7 100644
--- a/lisp/gnus/gnus-ems.el
+++ b/lisp/gnus/gnus-ems.el
@@ -158,57 +158,6 @@
158 "Non-nil means the mark and region are currently active in this buffer." 158 "Non-nil means the mark and region are currently active in this buffer."
159 mark-active) ; aliased to region-exists-p in XEmacs. 159 mark-active) ; aliased to region-exists-p in XEmacs.
160 160
161(autoload 'gnus-alive-p "gnus-util")
162(autoload 'mm-disable-multibyte "mm-util")
163
164;;; Image functions.
165
166(defun gnus-image-type-available-p (type)
167 (and (fboundp 'image-type-available-p)
168 (if (fboundp 'display-images-p)
169 (display-images-p)
170 t)
171 (image-type-available-p type)))
172
173(defun gnus-create-image (file &optional type data-p &rest props)
174 (let ((face (plist-get props :face)))
175 (when face
176 (setq props (plist-put props :foreground (face-foreground face)))
177 (setq props (plist-put props :background (face-background face))))
178 (ignore-errors
179 (apply 'create-image file type data-p props))))
180
181(defun gnus-put-image (glyph &optional string category)
182 (let ((point (point)))
183 (insert-image glyph (or string " "))
184 (put-text-property point (point) 'gnus-image-category category)
185 (unless string
186 (put-text-property (1- (point)) (point)
187 'gnus-image-text-deletable t))
188 glyph))
189
190(defun gnus-remove-image (image &optional category)
191 "Remove the image matching IMAGE and CATEGORY found first."
192 (let ((start (point-min))
193 val end)
194 (while (and (not end)
195 (or (setq val (get-text-property start 'display))
196 (and (setq start
197 (next-single-property-change start 'display))
198 (setq val (get-text-property start 'display)))))
199 (setq end (or (next-single-property-change start 'display)
200 (point-max)))
201 (if (and (equal val image)
202 (equal (get-text-property start 'gnus-image-category)
203 category))
204 (progn
205 (put-text-property start end 'display nil)
206 (when (get-text-property start 'gnus-image-text-deletable)
207 (delete-region start end)))
208 (unless (= end (point-max))
209 (setq start end
210 end nil))))))
211
212(provide 'gnus-ems) 161(provide 'gnus-ems)
213 162
214;;; gnus-ems.el ends here 163;;; gnus-ems.el ends here
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index 31645fcd315..33d96bd20eb 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -2021,6 +2021,54 @@ lists of strings."
2021 (gnus-setdiff (cdr list1) list2) 2021 (gnus-setdiff (cdr list1) list2)
2022 (cons (car list1) (gnus-setdiff (cdr list1) list2))))) 2022 (cons (car list1) (gnus-setdiff (cdr list1) list2)))))
2023 2023
2024;;; Image functions.
2025
2026(defun gnus-image-type-available-p (type)
2027 (and (fboundp 'image-type-available-p)
2028 (if (fboundp 'display-images-p)
2029 (display-images-p)
2030 t)
2031 (image-type-available-p type)))
2032
2033(defun gnus-create-image (file &optional type data-p &rest props)
2034 (let ((face (plist-get props :face)))
2035 (when face
2036 (setq props (plist-put props :foreground (face-foreground face)))
2037 (setq props (plist-put props :background (face-background face))))
2038 (ignore-errors
2039 (apply 'create-image file type data-p props))))
2040
2041(defun gnus-put-image (glyph &optional string category)
2042 (let ((point (point)))
2043 (insert-image glyph (or string " "))
2044 (put-text-property point (point) 'gnus-image-category category)
2045 (unless string
2046 (put-text-property (1- (point)) (point)
2047 'gnus-image-text-deletable t))
2048 glyph))
2049
2050(defun gnus-remove-image (image &optional category)
2051 "Remove the image matching IMAGE and CATEGORY found first."
2052 (let ((start (point-min))
2053 val end)
2054 (while (and (not end)
2055 (or (setq val (get-text-property start 'display))
2056 (and (setq start
2057 (next-single-property-change start 'display))
2058 (setq val (get-text-property start 'display)))))
2059 (setq end (or (next-single-property-change start 'display)
2060 (point-max)))
2061 (if (and (equal val image)
2062 (equal (get-text-property start 'gnus-image-category)
2063 category))
2064 (progn
2065 (put-text-property start end 'display nil)
2066 (when (get-text-property start 'gnus-image-text-deletable)
2067 (delete-region start end)))
2068 (unless (= end (point-max))
2069 (setq start end
2070 end nil))))))
2071
2024(provide 'gnus-util) 2072(provide 'gnus-util)
2025 2073
2026;;; gnus-util.el ends here 2074;;; gnus-util.el ends here