aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatsumi Yamaoka2011-05-10 03:14:44 +0000
committerKatsumi Yamaoka2011-05-10 03:14:44 +0000
commitb9bdaf749fb16229ef78c71a8cba2d4c37f4a6d9 (patch)
tree82c45ae18ed7ec54d0560f99c8d5ee2849453283
parentb8f82dc15fc7370329930323082d9faf2a5fc7ad (diff)
downloademacs-b9bdaf749fb16229ef78c71a8cba2d4c37f4a6d9.tar.gz
emacs-b9bdaf749fb16229ef78c71a8cba2d4c37f4a6d9.zip
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.
-rw-r--r--lisp/gnus/ChangeLog12
-rw-r--r--lisp/gnus/gnus-art.el12
-rw-r--r--lisp/gnus/gnus-html.el20
-rw-r--r--lisp/gnus/shr.el17
4 files changed, 45 insertions, 16 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index aa07038635d..1460896dd89 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,15 @@
12011-05-10 Katsumi Yamaoka <yamaoka@jpl.org>
2
3 * shr.el (shr-put-image-function): New variable.
4 (shr-image-fetched, shr-image-displayer, shr-tag-img): Funcall it.
5 (shr-put-image): Return scaled image.
6
7 * gnus-art.el (gnus-shr-put-image): New function.
8 (gnus-article-prepare-display): Bind shr-put-image-function to it.
9
10 * gnus-html.el (gnus-html-wash-images): Register scaled images, not
11 original ones, as deletable.
12
12011-05-09 Stefan Monnier <monnier@iro.umontreal.ca> 132011-05-09 Stefan Monnier <monnier@iro.umontreal.ca>
2 14
3 * nntp.el (nntp-open-connection): Set TCP keepalive option. 15 * nntp.el (nntp-open-connection): Set TCP keepalive option.
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 690e29cb65a..13531bf434e 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -4656,6 +4656,8 @@ If ALL-HEADERS is non-nil, no headers are hidden."
4656 (gnus-run-hooks 'gnus-article-prepare-hook) 4656 (gnus-run-hooks 'gnus-article-prepare-hook)
4657 t)))))) 4657 t))))))
4658 4658
4659(defvar shr-put-image-function)
4660
4659;;;###autoload 4661;;;###autoload
4660(defun gnus-article-prepare-display () 4662(defun gnus-article-prepare-display ()
4661 "Make the current buffer look like a nice article." 4663 "Make the current buffer look like a nice article."
@@ -4669,6 +4671,7 @@ If ALL-HEADERS is non-nil, no headers are hidden."
4669 (setq buffer-read-only nil 4671 (setq buffer-read-only nil
4670 gnus-article-wash-types nil 4672 gnus-article-wash-types nil
4671 gnus-article-image-alist nil) 4673 gnus-article-image-alist nil)
4674 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4672 (gnus-run-hooks 'gnus-tmp-internal-hook) 4675 (gnus-run-hooks 'gnus-tmp-internal-hook)
4673 (when gnus-display-mime-function 4676 (when gnus-display-mime-function
4674 (funcall gnus-display-mime-function)))) 4677 (funcall gnus-display-mime-function))))
@@ -6139,6 +6142,15 @@ Provided for backwards compatibility."
6139 (not gnus-inhibit-hiding)) 6142 (not gnus-inhibit-hiding))
6140 (gnus-article-hide-headers))) 6143 (gnus-article-hide-headers)))
6141 6144
6145(declare-function shr-put-image "shr" (data alt))
6146
6147(defun gnus-shr-put-image (data alt)
6148 "Put image DATA with a string ALT. Enable image to be deleted."
6149 (let ((image (shr-put-image data (propertize (or alt "*")
6150 'gnus-image-category 'shr))))
6151 (when image
6152 (gnus-add-image 'shr image))))
6153
6142;;; Article savers. 6154;;; Article savers.
6143 6155
6144(defun gnus-output-to-file (file-name) 6156(defun gnus-output-to-file (file-name)
diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el
index f380d079d7b..b7f0c0922a3 100644
--- a/lisp/gnus/gnus-html.el
+++ b/lisp/gnus/gnus-html.el
@@ -215,16 +215,16 @@ CHARS is a regexp-like character alternative (e.g., \"[)$]\")."
215 (mm-with-part handle (buffer-string)) 215 (mm-with-part handle (buffer-string))
216 nil t)))) 216 nil t))))
217 (if image 217 (if image
218 (progn 218 (gnus-add-image
219 (gnus-put-image 219 'cid
220 (gnus-rescale-image 220 (gnus-put-image
221 image (gnus-html-maximum-image-size)) 221 (gnus-rescale-image
222 (gnus-string-or (prog1 222 image (gnus-html-maximum-image-size))
223 (buffer-substring start end) 223 (gnus-string-or (prog1
224 (delete-region start end)) 224 (buffer-substring start end)
225 "*") 225 (delete-region start end))
226 'cid) 226 "*")
227 (gnus-add-image 'cid image)) 227 'cid))
228 (widget-convert-button 228 (widget-convert-button
229 'link start end 229 'link start end
230 :action 'gnus-html-insert-image 230 :action 'gnus-html-insert-image
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index 2e7968e8dee..da27edca6e5 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -87,6 +87,9 @@ used."
87This is used for cid: URLs, and the function is called with the 87This is used for cid: URLs, and the function is called with the
88cid: URL as the argument.") 88cid: URL as the argument.")
89 89
90(defvar shr-put-image-function 'shr-put-image
91 "Function called to put image and alt string.")
92
90(defface shr-strike-through '((t (:strike-through t))) 93(defface shr-strike-through '((t (:strike-through t)))
91 "Font for <s> elements." 94 "Font for <s> elements."
92 :group 'shr) 95 :group 'shr)
@@ -500,10 +503,11 @@ redirects somewhere else."
500 (inhibit-read-only t)) 503 (inhibit-read-only t))
501 (delete-region start end) 504 (delete-region start end)
502 (goto-char start) 505 (goto-char start)
503 (shr-put-image data alt))))))) 506 (funcall shr-put-image-function data alt)))))))
504 (kill-buffer (current-buffer))) 507 (kill-buffer (current-buffer)))
505 508
506(defun shr-put-image (data alt) 509(defun shr-put-image (data alt)
510 "Put image DATA with a string ALT. Return image."
507 (if (display-graphic-p) 511 (if (display-graphic-p)
508 (let ((image (ignore-errors 512 (let ((image (ignore-errors
509 (shr-rescale-image data)))) 513 (shr-rescale-image data))))
@@ -513,7 +517,8 @@ redirects somewhere else."
513 (when (and (> (current-column) 0) 517 (when (and (> (current-column) 0)
514 (> (car (image-size image t)) 400)) 518 (> (car (image-size image t)) 400))
515 (insert "\n")) 519 (insert "\n"))
516 (insert-image image (or alt "*")))) 520 (insert-image image (or alt "*")))
521 image)
517 (insert alt))) 522 (insert alt)))
518 523
519(defun shr-rescale-image (data) 524(defun shr-rescale-image (data)
@@ -576,8 +581,8 @@ START, and END. Note that START and END should be merkers."
576 (substring url (match-end 0))))) 581 (substring url (match-end 0)))))
577 (when image 582 (when image
578 (goto-char start) 583 (goto-char start)
579 (shr-put-image image 584 (funcall shr-put-image-function
580 (buffer-substring-no-properties start end)) 585 image (buffer-substring-no-properties start end))
581 (delete-region (point) end)))) 586 (delete-region (point) end))))
582 (url-retrieve url 'shr-image-fetched 587 (url-retrieve url 'shr-image-fetched
583 (list (current-buffer) start end) 588 (list (current-buffer) start end)
@@ -864,7 +869,7 @@ ones, in case fg and bg are nil."
864 (if (or (not shr-content-function) 869 (if (or (not shr-content-function)
865 (not (setq image (funcall shr-content-function url)))) 870 (not (setq image (funcall shr-content-function url))))
866 (insert alt) 871 (insert alt)
867 (shr-put-image image alt)))) 872 (funcall shr-put-image-function image alt))))
868 ((or shr-inhibit-images 873 ((or shr-inhibit-images
869 (and shr-blocked-images 874 (and shr-blocked-images
870 (string-match shr-blocked-images url))) 875 (string-match shr-blocked-images url)))
@@ -874,7 +879,7 @@ ones, in case fg and bg are nil."
874 (shr-insert (truncate-string-to-width alt 8)) 879 (shr-insert (truncate-string-to-width alt 8))
875 (shr-insert alt)))) 880 (shr-insert alt))))
876 ((url-is-cached (shr-encode-url url)) 881 ((url-is-cached (shr-encode-url url))
877 (shr-put-image (shr-get-image-data url) alt)) 882 (funcall shr-put-image-function (shr-get-image-data url) alt))
878 (t 883 (t
879 (insert alt) 884 (insert alt)
880 (funcall 885 (funcall