aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatsumi Yamaoka2010-11-17 07:22:19 +0000
committerKatsumi Yamaoka2010-11-17 07:22:19 +0000
commit40de2c6dd32a746e3d31492a0f43a290e9ef5d1d (patch)
tree1be1f4f4c0b083cc1c871d0e7a4e8c24877d5132
parent6b4bb7039fa9078206e35cf071ad098a706a0988 (diff)
downloademacs-40de2c6dd32a746e3d31492a0f43a290e9ef5d1d.tar.gz
emacs-40de2c6dd32a746e3d31492a0f43a290e9ef5d1d.zip
gnus-art.el (gnus-inhibit-images): New user option.
* gnus-art.el (gnus-inhibit-images): New user option. (gnus-mime-display-single): Don't display image if it is non-nil. * mm-decode.el (mm-shr): Bind shr-inhibit-images to the value of gnus-inhibit-images. * shr.el (shr-image-displayer): New function. (shr-tag-img): Use it.
-rw-r--r--lisp/gnus/ChangeLog11
-rw-r--r--lisp/gnus/gnus-art.el10
-rw-r--r--lisp/gnus/mm-decode.el2
-rw-r--r--lisp/gnus/shr.el25
4 files changed, 43 insertions, 5 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 2cf48e24c7c..7d3b2d06835 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,14 @@
12010-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
2
3 * gnus-art.el (gnus-inhibit-images): New user option.
4 (gnus-mime-display-single): Don't display image if it is non-nil.
5
6 * mm-decode.el (mm-shr): Bind shr-inhibit-images to the value of
7 gnus-inhibit-images.
8
9 * shr.el (shr-image-displayer): New function.
10 (shr-tag-img): Use it.
11
12010-11-16 Daniel Dehennin <daniel.dehennin@baby-gnu.org> 122010-11-16 Daniel Dehennin <daniel.dehennin@baby-gnu.org>
2 13
3 * mml2015.el (mml2015-epg-sign): Use From header. 14 * mml2015.el (mml2015-epg-sign): Use From header.
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index e2be314f8d1..4ff36e7a589 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -1636,6 +1636,12 @@ This requires GNU Libidn, and by default only enabled if it is found."
1636 :group 'gnus-article 1636 :group 'gnus-article
1637 :type 'boolean) 1637 :type 'boolean)
1638 1638
1639(defcustom gnus-inhibit-images nil
1640 "Non-nil means inhibit displaying of images inline in the article body."
1641 :version "24.1"
1642 :group 'gnus-article
1643 :type 'boolean)
1644
1639(defcustom gnus-blocked-images 'gnus-block-private-groups 1645(defcustom gnus-blocked-images 'gnus-block-private-groups
1640 "Images that have URLs matching this regexp will be blocked. 1646 "Images that have URLs matching this regexp will be blocked.
1641This can also be a function to be evaluated. If so, it will be 1647This can also be a function to be evaluated. If so, it will be
@@ -5845,7 +5851,9 @@ If displaying \"text/html\" is discouraged \(see
5845 (while ignored 5851 (while ignored
5846 (when (string-match (pop ignored) type) 5852 (when (string-match (pop ignored) type)
5847 (throw 'ignored nil))) 5853 (throw 'ignored nil)))
5848 (if (and (setq not-attachment 5854 (if (and (not (and gnus-inhibit-images
5855 (string-match "\\`image/" type)))
5856 (setq not-attachment
5849 (and (not (mm-inline-override-p handle)) 5857 (and (not (mm-inline-override-p handle))
5850 (or (not (mm-handle-disposition handle)) 5858 (or (not (mm-handle-disposition handle))
5851 (equal (car (mm-handle-disposition handle)) 5859 (equal (car (mm-handle-disposition handle))
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index 2ab5a548e42..f27cc5907b0 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -1687,6 +1687,7 @@ If RECURSIVE, search recursively."
1687 (start end &optional base-url)) 1687 (start end &optional base-url))
1688(declare-function shr-insert-document "shr" (dom)) 1688(declare-function shr-insert-document "shr" (dom))
1689(defvar shr-blocked-images) 1689(defvar shr-blocked-images)
1690(defvar gnus-inhibit-images)
1690(autoload 'gnus-blocked-images "gnus-art") 1691(autoload 'gnus-blocked-images "gnus-art")
1691 1692
1692(defun mm-shr (handle) 1693(defun mm-shr (handle)
@@ -1703,6 +1704,7 @@ If RECURSIVE, search recursively."
1703 (when handle 1704 (when handle
1704 (mm-with-part handle 1705 (mm-with-part handle
1705 (buffer-string)))))) 1706 (buffer-string))))))
1707 (shr-inhibit-images gnus-inhibit-images)
1706 charset) 1708 charset)
1707 (unless handle 1709 (unless handle
1708 (setq handle (mm-dissect-buffer t))) 1710 (setq handle (mm-dissect-buffer t)))
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index 4f3b20531f5..2dd33ecbc13 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -435,6 +435,26 @@ Return a string with image data."
435 (search-forward "\r\n\r\n" nil t)) 435 (search-forward "\r\n\r\n" nil t))
436 (buffer-substring (point) (point-max)))))) 436 (buffer-substring (point) (point-max))))))
437 437
438(defun shr-image-displayer (content-function)
439 "Return a function to display an image.
440CONTENT-FUNCTION is a function to retrieve an image for a cid url that
441is an argument. The function to be returned takes three arguments URL,
442START, and END."
443 `(lambda (url start end)
444 (if (string-match "\\`cid:" url)
445 ,(when content-function
446 `(let ((image (funcall ,content-function
447 (substring url (match-end 0)))))
448 (when image
449 (goto-char start)
450 (shr-put-image image
451 (prog1
452 (buffer-substring-no-properties start end)
453 (delete-region start end))))))
454 (url-retrieve url 'shr-image-fetched
455 (list (current-buffer) start end)
456 t))))
457
438(defun shr-heading (cont &rest types) 458(defun shr-heading (cont &rest types)
439 (shr-ensure-paragraph) 459 (shr-ensure-paragraph)
440 (apply #'shr-fontize-cont cont types) 460 (apply #'shr-fontize-cont cont types)
@@ -574,10 +594,7 @@ Return a string with image data."
574 (put-text-property start (point) 'shr-alt alt) 594 (put-text-property start (point) 'shr-alt alt)
575 (put-text-property start (point) 'image-url url) 595 (put-text-property start (point) 'image-url url)
576 (put-text-property start (point) 'image-displayer 596 (put-text-property start (point) 'image-displayer
577 (lambda (url start end) 597 (shr-image-displayer shr-content-function))
578 (url-retrieve url 'shr-image-fetched
579 (list (current-buffer) start end)
580 t)))
581 (put-text-property start (point) 'help-echo alt) 598 (put-text-property start (point) 'help-echo alt)
582 (setq shr-state 'image))))) 599 (setq shr-state 'image)))))
583 600