(shr-image-fetched, shr-image-displayer, shr-tag-img): Funcall it.
(shr-put-image): Return scaled image.
gnus-art.el (gnus-shr-put-image): New function.
(gnus-article-prepare-display): Bind shr-put-image-function to it.
gnus-html.el (gnus-html-wash-images): Register scaled images, not original ones, as deletable.
+2011-05-10 Katsumi Yamaoka <yamaoka@jpl.org>
+
+ * shr.el (shr-put-image-function): New variable.
+ (shr-image-fetched, shr-image-displayer, shr-tag-img): Funcall it.
+ (shr-put-image): Return scaled image.
+
+ * gnus-art.el (gnus-shr-put-image): New function.
+ (gnus-article-prepare-display): Bind shr-put-image-function to it.
+
+ * gnus-html.el (gnus-html-wash-images): Register scaled images, not
+ original ones, as deletable.
+
2011-05-09 Stefan Monnier <monnier@iro.umontreal.ca>
* nntp.el (nntp-open-connection): Set TCP keepalive option.
(gnus-run-hooks 'gnus-article-prepare-hook)
t))))))
+(defvar shr-put-image-function)
+
;;;###autoload
(defun gnus-article-prepare-display ()
"Make the current buffer look like a nice article."
(setq buffer-read-only nil
gnus-article-wash-types nil
gnus-article-image-alist nil)
+ (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
(gnus-run-hooks 'gnus-tmp-internal-hook)
(when gnus-display-mime-function
(funcall gnus-display-mime-function))))
(not gnus-inhibit-hiding))
(gnus-article-hide-headers)))
+(declare-function shr-put-image "shr" (data alt))
+
+(defun gnus-shr-put-image (data alt)
+ "Put image DATA with a string ALT. Enable image to be deleted."
+ (let ((image (shr-put-image data (propertize (or alt "*")
+ 'gnus-image-category 'shr))))
+ (when image
+ (gnus-add-image 'shr image))))
+
;;; Article savers.
(defun gnus-output-to-file (file-name)
(mm-with-part handle (buffer-string))
nil t))))
(if image
- (progn
- (gnus-put-image
- (gnus-rescale-image
- image (gnus-html-maximum-image-size))
- (gnus-string-or (prog1
- (buffer-substring start end)
- (delete-region start end))
- "*")
- 'cid)
- (gnus-add-image 'cid image))
+ (gnus-add-image
+ 'cid
+ (gnus-put-image
+ (gnus-rescale-image
+ image (gnus-html-maximum-image-size))
+ (gnus-string-or (prog1
+ (buffer-substring start end)
+ (delete-region start end))
+ "*")
+ 'cid))
(widget-convert-button
'link start end
:action 'gnus-html-insert-image
This is used for cid: URLs, and the function is called with the
cid: URL as the argument.")
+(defvar shr-put-image-function 'shr-put-image
+ "Function called to put image and alt string.")
+
(defface shr-strike-through '((t (:strike-through t)))
"Font for <s> elements."
:group 'shr)
(inhibit-read-only t))
(delete-region start end)
(goto-char start)
- (shr-put-image data alt)))))))
+ (funcall shr-put-image-function data alt)))))))
(kill-buffer (current-buffer)))
(defun shr-put-image (data alt)
+ "Put image DATA with a string ALT. Return image."
(if (display-graphic-p)
(let ((image (ignore-errors
(shr-rescale-image data))))
(when (and (> (current-column) 0)
(> (car (image-size image t)) 400))
(insert "\n"))
- (insert-image image (or alt "*"))))
+ (insert-image image (or alt "*")))
+ image)
(insert alt)))
(defun shr-rescale-image (data)
(substring url (match-end 0)))))
(when image
(goto-char start)
- (shr-put-image image
- (buffer-substring-no-properties start end))
+ (funcall shr-put-image-function
+ image (buffer-substring-no-properties start end))
(delete-region (point) end))))
(url-retrieve url 'shr-image-fetched
(list (current-buffer) start end)
(if (or (not shr-content-function)
(not (setq image (funcall shr-content-function url))))
(insert alt)
- (shr-put-image image alt))))
+ (funcall shr-put-image-function image alt))))
((or shr-inhibit-images
(and shr-blocked-images
(string-match shr-blocked-images url)))
(shr-insert (truncate-string-to-width alt 8))
(shr-insert alt))))
((url-is-cached (shr-encode-url url))
- (shr-put-image (shr-get-image-data url) alt))
+ (funcall shr-put-image-function (shr-get-image-data url) alt))
(t
(insert alt)
(funcall