aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatsumi Yamaoka2010-08-31 13:28:02 +0000
committerKatsumi Yamaoka2010-08-31 13:28:02 +0000
commitad1421332b1bf192e0f59367c86e3a128c4b7329 (patch)
treec8fe4072cf0a8493330cc8a36dac375d4a76ccc3
parentc8977b2e622e2c1ff46a160b252feff30bc1025e (diff)
downloademacs-ad1421332b1bf192e0f59367c86e3a128c4b7329.tar.gz
emacs-ad1421332b1bf192e0f59367c86e3a128c4b7329.zip
Clarify the code a bit by renaming the variable with the url to `url'; Support cid: URLs/images; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
-rw-r--r--lisp/gnus/ChangeLog3
-rw-r--r--lisp/gnus/gnus-ems.el2
-rw-r--r--lisp/gnus/gnus-html.el53
3 files changed, 38 insertions, 20 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index ec4427bb836..03d96b6f36f 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -10,6 +10,9 @@
102010-08-31 Lars Magne Ingebrigtsen <larsi@gnus.org> 102010-08-31 Lars Magne Ingebrigtsen <larsi@gnus.org>
11 11
12 * gnus-html.el: require mm-url. 12 * gnus-html.el: require mm-url.
13 (gnus-html-wash-tags): Clarify the code a bit by renaming the variable
14 with the url to `url'.
15 (gnus-html-wash-tags): Support cid: URLs/images.
13 16
142010-08-30 Lars Magne Ingebrigtsen <larsi@gnus.org> 172010-08-30 Lars Magne Ingebrigtsen <larsi@gnus.org>
15 18
diff --git a/lisp/gnus/gnus-ems.el b/lisp/gnus/gnus-ems.el
index efa74146a91..6b7d6a624a6 100644
--- a/lisp/gnus/gnus-ems.el
+++ b/lisp/gnus/gnus-ems.el
@@ -276,7 +276,7 @@
276 276
277(defun gnus-put-image (glyph &optional string category) 277(defun gnus-put-image (glyph &optional string category)
278 (let ((point (point))) 278 (let ((point (point)))
279 (insert-image glyph (or string " ")) 279 (insert-image glyph (or string "*"))
280 (put-text-property point (point) 'gnus-image-category category) 280 (put-text-property point (point) 'gnus-image-category category)
281 (unless string 281 (unless string
282 (put-text-property (1- (point)) (point) 282 (put-text-property (1- (point)) (point)
diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el
index 77cc5dc18d8..542d1401a80 100644
--- a/lisp/gnus/gnus-html.el
+++ b/lisp/gnus/gnus-html.el
@@ -72,7 +72,7 @@
72 (gnus-html-wash-tags)))) 72 (gnus-html-wash-tags))))
73 73
74(defun gnus-html-wash-tags () 74(defun gnus-html-wash-tags ()
75 (let (tag parameters string start end images) 75 (let (tag parameters string start end images url)
76 (mm-url-decode-entities) 76 (mm-url-decode-entities)
77 (goto-char (point-min)) 77 (goto-char (point-min))
78 (while (re-search-forward "<\\([^ />]+\\)\\([^>]*\\)>" nil t) 78 (while (re-search-forward "<\\([^ />]+\\)\\([^>]*\\)>" nil t)
@@ -89,31 +89,46 @@
89 ;; Fetch and insert a picture. 89 ;; Fetch and insert a picture.
90 ((equal tag "img_alt") 90 ((equal tag "img_alt")
91 (when (string-match "src=\"\\([^\"]+\\)" parameters) 91 (when (string-match "src=\"\\([^\"]+\\)" parameters)
92 (setq parameters (match-string 1 parameters)) 92 (setq url (match-string 1 parameters))
93 (when (or (null mm-w3m-safe-url-regexp) 93 (when (or (null mm-w3m-safe-url-regexp)
94 (string-match mm-w3m-safe-url-regexp parameters)) 94 (string-match mm-w3m-safe-url-regexp url))
95 (let ((file (gnus-html-image-id parameters))) 95 (if (string-match "^cid:\\(.*\\)" url)
96 (if (file-exists-p file) 96 ;; URLs with cid: have their content stashed in other
97 ;; It's already cached, so just insert it. 97 ;; parts of the MIME structure, so just insert them
98 (when (gnus-html-put-image file (point)) 98 ;; immediately.
99 ;; Delete the ALT text. 99 (let ((handle (mm-get-content-id
100 (delete-region start end)) 100 (setq url (match-string 1 url))))
101 ;; We don't have it, so schedule it for fetching 101 image)
102 ;; asynchronously. 102 (when handle
103 (push (list parameters 103 (mm-with-part handle
104 (set-marker (make-marker) start) 104 (setq image (gnus-create-image (buffer-string)
105 (point-marker)) 105 nil t))))
106 images)))))) 106 (when image
107 (delete-region start end)
108 (gnus-put-image image)))
109 ;; Normal, external URL.
110 (let ((file (gnus-html-image-id url)))
111 (if (file-exists-p file)
112 ;; It's already cached, so just insert it.
113 (when (gnus-html-put-image file (point))
114 ;; Delete the ALT text.
115 (delete-region start end))
116 ;; We don't have it, so schedule it for fetching
117 ;; asynchronously.
118 (push (list url
119 (set-marker (make-marker) start)
120 (point-marker))
121 images)))))))
107 ;; Add a link. 122 ;; Add a link.
108 ((equal tag "a") 123 ((equal tag "a")
109 (when (string-match "href=\"\\([^\"]+\\)" parameters) 124 (when (string-match "href=\"\\([^\"]+\\)" parameters)
110 (setq parameters (match-string 1 parameters)) 125 (setq url (match-string 1 parameters))
111 (gnus-article-add-button start end 126 (gnus-article-add-button start end
112 'browse-url parameters 127 'browse-url url
113 parameters) 128 url)
114 (let ((overlay (gnus-make-overlay start end))) 129 (let ((overlay (gnus-make-overlay start end)))
115 (gnus-overlay-put overlay 'evaporate t) 130 (gnus-overlay-put overlay 'evaporate t)
116 (gnus-overlay-put overlay 'gnus-button-url parameters) 131 (gnus-overlay-put overlay 'gnus-button-url url)
117 (when gnus-article-mouse-face 132 (when gnus-article-mouse-face
118 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face))))) 133 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))))
119 ;; Whatever. Just ignore the tag. 134 ;; Whatever. Just ignore the tag.