aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGnus developers2010-12-05 22:17:34 +0000
committerKatsumi Yamaoka2010-12-05 22:17:34 +0000
commit04db63bc416d65a76fe6eb057039eed9e731397d (patch)
tree5911475669cfff079084dd335e1e45943de8d3b5
parentd23d86081b976717a19d93ff92e37f72619b9545 (diff)
downloademacs-04db63bc416d65a76fe6eb057039eed9e731397d.tar.gz
emacs-04db63bc416d65a76fe6eb057039eed9e731397d.zip
Merge changes made in Gnus trunk.
nnir.el (nnir-categorize): Replace mapcar with mapc. shr.el (shr-urlify): Display the title in <a> tags. shr.el (shr-urlify): Show the URL before the title to avoid misleading URLs. gnus-sum.el (gnus-summary-show-article): Reverse the meanings of `C-u C-u g' and `C-u g' so that `C-u g' does what it traditionally did. gnus.texi (Paging the Article): Note the reverse meanings of `C-u C-u g'. gnus-html.el (gnus-html-put-image): Use widget instead of local maps so that TAB works. nnir.el (nnir-run-gmane): Use more careful test for gmane nntp server. nnimap.el (nnimap-process-expiry-targets): Avoid downloading articles unless necessary. gnus-util.el (gnus-output-to-mail): Require nnmail before using nnmail variables. shr.el (shr-stylesheet): New dynamic variable for cascading the styles. (shr-colorize-region): New function. (shr-insert-background-overlay): Remove. (shr-render-td): Background setting should be taken care of on a higher level. (shr-tag-body): Use post-hoc colorizations. (shr-descend): Only render color/background when they change. (shr-tag-body): Set up a style sheet based on bgcolor/fgcolor. (shr-put-color-1): Don't overwrite old colors. (shr-colorize-region): When the background color isn't explicit, use a fixed background. gnus.el (gnus-valid-select-methods): Allow nnimap to respool. nntp.el (nntp-snarf-error-message): nnheader-report takes a format string as the parameter. gnus-sum.el (gnus-summary-respool-article): The completion function expects a list instead of an alist.
-rw-r--r--doc/misc/ChangeLog5
-rw-r--r--doc/misc/gnus.texi8
-rw-r--r--lisp/gnus/ChangeLog54
-rw-r--r--lisp/gnus/gnus-html.el16
-rw-r--r--lisp/gnus/gnus-int.el27
-rw-r--r--lisp/gnus/gnus-sum.el10
-rw-r--r--lisp/gnus/gnus-util.el3
-rw-r--r--lisp/gnus/gnus.el2
-rw-r--r--lisp/gnus/nnimap.el52
-rw-r--r--lisp/gnus/nnir.el7
-rw-r--r--lisp/gnus/nntp.el5
-rw-r--r--lisp/gnus/shr.el179
12 files changed, 238 insertions, 130 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 8d47de4f2a0..468a68b0a80 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,8 @@
12010-12-04 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * gnus.texi (Paging the Article): Note the reverse meanings of `C-u C-u
4 g'.
5
12010-12-02 Julien Danjou <julien@danjou.info> 62010-12-02 Julien Danjou <julien@danjou.info>
2 7
3 * gnus.texi (Archived Messages): Remove gnus-outgoing-message-group. 8 * gnus.texi (Archived Messages): Remove gnus-outgoing-message-group.
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 9e2e0b817b6..5b8a0b45683 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -6152,10 +6152,10 @@ Scroll the current article one line backward
6152@findex gnus-summary-show-article 6152@findex gnus-summary-show-article
6153@vindex gnus-summary-show-article-charset-alist 6153@vindex gnus-summary-show-article-charset-alist
6154(Re)fetch the current article (@code{gnus-summary-show-article}). If 6154(Re)fetch the current article (@code{gnus-summary-show-article}). If
6155given a prefix, fetch the current article, but don't run any of the 6155given a prefix, show a completely ``raw'' article, just the way it
6156article treatment functions. If given a prefix twice (i.e., @kbd{C-u 6156came from the server. If given a prefix twice (i.e., @kbd{C-u C-u
6157C-u g'}), show a completely ``raw'' article, just the way it came from 6157g'}), fetch the current article, but don't run any of the article
6158the server. 6158treatment functions.
6159 6159
6160@cindex charset, view article with different charset 6160@cindex charset, view article with different charset
6161If given a numerical prefix, you can do semi-manual charset stuff. 6161If given a numerical prefix, you can do semi-manual charset stuff.
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 7d8e954debd..6ca94d17600 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,57 @@
12010-12-05 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * gnus-sum.el (gnus-summary-respool-article): The completion function
4 expects a list instead of an alist.
5
6 * nntp.el (nntp-snarf-error-message): nnheader-report takes a format
7 string as the parameter.
8
9 * gnus.el (gnus-valid-select-methods): Allow nnimap to respool.
10
11 * shr.el (shr-stylesheet): New dynamic variable for cascading the
12 styles.
13 (shr-colorize-region): New function.
14 (shr-insert-background-overlay): Remove.
15 (shr-render-td): Background setting should be taken care of on a higher
16 level.
17 (shr-tag-body): Use post-hoc colorizations.
18 (shr-tag-body): Set up a style sheet based on bgcolor/fgcolor.
19 (shr-put-color-1): Don't overwrite old colors.
20 (shr-colorize-region): When the background color isn't explicit, use
21 a fixed background.
22
23 * gnus-util.el (gnus-output-to-mail): Require nnmail before using
24 nnmail variables.
25
262010-12-05 Bjørn Mork <bjorn@mork.no>
27
28 * nnimap.el (nnimap-process-expiry-targets): Avoid downloading articles
29 unless necessary.
30
312010-12-05 Andrew Cohen <cohen@andy.bu.edu>
32
33 * nnir.el (nnir-run-gmane): Use more careful test for gmane nntp
34 server.
35
362010-12-04 Lars Magne Ingebrigtsen <larsi@gnus.org>
37
38 * gnus-html.el (gnus-html-put-image): Use widget instead of local maps
39 so that TAB works.
40
41 * gnus-sum.el (gnus-summary-show-article): Reverse the meanings of `C-u
42 C-u g' and `C-u g' so that `C-u g' does what it traditionally did.
43
44 * shr.el (shr-urlify): Show the URL before the title to avoid
45 misleading URLs.
46
472010-12-04 Adam Sjøgren <asjo@koldfront.dk>
48
49 * shr.el (shr-urlify): Display the title in <a> tags.
50
512010-12-04 Andrew Cohen <cohen@andy.bu.edu>
52
53 * nnir.el (nnir-categorize): Replace mapcar with mapc.
54
12010-12-03 Andrew Cohen <cohen@andy.bu.edu> 552010-12-03 Andrew Cohen <cohen@andy.bu.edu>
2 56
3 * nnir.el: Rearrange code to allow macros to be autoloaded by 57 * nnir.el: Rearrange code to allow macros to be autoloaded by
diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el
index 174e128a7e9..63a14b204fb 100644
--- a/lisp/gnus/gnus-html.el
+++ b/lisp/gnus/gnus-html.el
@@ -199,8 +199,11 @@ CHARS is a regexp-like character alternative (e.g., \"[)$]\")."
199 (gnus-html-display-image url start end 199 (gnus-html-display-image url start end
200 ,alt-text)) 200 ,alt-text))
201 'gnus-image (list url start end alt-text))) 201 'gnus-image (list url start end alt-text)))
202 (gnus-overlay-put (gnus-make-overlay start end) 202 (widget-convert-button
203 'local-map gnus-html-image-map) 203 'url-link start (point)
204 :help-echo alt-text
205 :keymap gnus-html-image-map
206 url)
204 (if (string-match "\\`cid:" url) 207 (if (string-match "\\`cid:" url)
205 ;; URLs with cid: have their content stashed in other 208 ;; URLs with cid: have their content stashed in other
206 ;; parts of the MIME structure, so just insert them 209 ;; parts of the MIME structure, so just insert them
@@ -473,10 +476,11 @@ Return a string with image data."
473 (let ((image (gnus-rescale-image image (gnus-html-maximum-image-size)))) 476 (let ((image (gnus-rescale-image image (gnus-html-maximum-image-size))))
474 (delete-region start end) 477 (delete-region start end)
475 (gnus-put-image image alt-text 'external) 478 (gnus-put-image image alt-text 'external)
476 (gnus-put-text-property start (point) 'help-echo alt-text) 479 (widget-convert-button
477 (gnus-overlay-put 480 'url-link start (point)
478 (gnus-make-overlay start (point)) 'local-map 481 :help-echo alt-text
479 gnus-html-displayed-image-map) 482 :keymap gnus-html-displayed-image-map
483 url)
480 (gnus-put-text-property start (point) 484 (gnus-put-text-property start (point)
481 'gnus-alt-text alt-text) 485 'gnus-alt-text alt-text)
482 (when url 486 (when url
diff --git a/lisp/gnus/gnus-int.el b/lisp/gnus/gnus-int.el
index bcfff347968..767ac2e9fc5 100644
--- a/lisp/gnus/gnus-int.el
+++ b/lisp/gnus/gnus-int.el
@@ -259,20 +259,21 @@ If it is down, start it up (again)."
259 (gnus-message 1 "Denied server %s" server) 259 (gnus-message 1 "Denied server %s" server)
260 nil) 260 nil)
261 ;; Open the server. 261 ;; Open the server.
262 (let* ((open-server-function (gnus-get-function gnus-command-method 'open-server)) 262 (let* ((open-server-function
263 (gnus-get-function gnus-command-method 'open-server))
263 (result 264 (result
264 (condition-case err 265 (condition-case err
265 (funcall open-server-function 266 (funcall open-server-function
266 (nth 1 gnus-command-method) 267 (nth 1 gnus-command-method)
267 (nthcdr 2 gnus-command-method)) 268 (nthcdr 2 gnus-command-method))
268 (error 269 (error
269 (gnus-message 1 "Unable to open server %s due to: %s" 270 (gnus-message 1 "Unable to open server %s due to: %s"
270 server (error-message-string err)) 271 server (error-message-string err))
271 nil) 272 nil)
272 (quit 273 (quit
273 (gnus-message 1 "Quit trying to open server %s" server) 274 (gnus-message 1 "Quit trying to open server %s" server)
274 nil))) 275 nil)))
275 open-offline) 276 open-offline)
276 ;; If this hasn't been opened before, we add it to the list. 277 ;; If this hasn't been opened before, we add it to the list.
277 (unless elem 278 (unless elem
278 (setq elem (list gnus-command-method nil) 279 (setq elem (list gnus-command-method nil)
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index ba124d5115d..2bb39af3fb8 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -9475,6 +9475,9 @@ C-u g', show the raw article."
9475 ((or (equal arg '(16)) 9475 ((or (equal arg '(16))
9476 (eq arg t)) 9476 (eq arg t))
9477 ;; C-u C-u g 9477 ;; C-u C-u g
9478 (let ((gnus-inhibit-article-treatments t))
9479 (gnus-summary-select-article nil 'force)))
9480 (t
9478 ;; We have to require this here to make sure that the following 9481 ;; We have to require this here to make sure that the following
9479 ;; dynamic binding isn't shadowed by autoloading. 9482 ;; dynamic binding isn't shadowed by autoloading.
9480 (require 'gnus-async) 9483 (require 'gnus-async)
@@ -9492,9 +9495,6 @@ C-u g', show the raw article."
9492 ;; Set it to nil for safety reason. 9495 ;; Set it to nil for safety reason.
9493 (setq gnus-article-mime-handle-alist nil) 9496 (setq gnus-article-mime-handle-alist nil)
9494 (setq gnus-article-mime-handles nil))) 9497 (setq gnus-article-mime-handles nil)))
9495 (gnus-summary-select-article nil 'force)))
9496 (t
9497 (let ((gnus-inhibit-article-treatments t))
9498 (gnus-summary-select-article nil 'force)))) 9498 (gnus-summary-select-article nil 'force))))
9499 (gnus-summary-goto-subject gnus-current-article) 9499 (gnus-summary-goto-subject gnus-current-article)
9500 (gnus-summary-position-point)) 9500 (gnus-summary-position-point))
@@ -9934,7 +9934,7 @@ ACTION can be either `move' (the default), `crosspost' or `copy'."
9934 9934
9935 ;;;!!!Why is this necessary? 9935 ;;;!!!Why is this necessary?
9936 (set-buffer gnus-summary-buffer) 9936 (set-buffer gnus-summary-buffer)
9937 9937
9938 (when (eq action 'move) 9938 (when (eq action 'move)
9939 (save-excursion 9939 (save-excursion
9940 (gnus-summary-goto-subject article) 9940 (gnus-summary-goto-subject article)
@@ -10004,7 +10004,7 @@ current group into whatever groups they are destined to. In the
10004latter case, they will be copied into the relevant groups." 10004latter case, they will be copied into the relevant groups."
10005 (interactive 10005 (interactive
10006 (list current-prefix-arg 10006 (list current-prefix-arg
10007 (let* ((methods (gnus-methods-using 'respool)) 10007 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10008 (methname 10008 (methname
10009 (symbol-name (or gnus-summary-respool-default-method 10009 (symbol-name (or gnus-summary-respool-default-method
10010 (car (gnus-find-method-for-group 10010 (car (gnus-find-method-for-group
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index 55d6ce55ebb..45fd26c86c0 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -902,6 +902,7 @@ Bind `print-quoted' and `print-readably' to t, and `print-length' and
902 902
903(defun gnus-write-buffer (file) 903(defun gnus-write-buffer (file)
904 "Write the current buffer's contents to FILE." 904 "Write the current buffer's contents to FILE."
905 (require 'nnmail)
905 (let ((file-name-coding-system nnmail-pathname-coding-system)) 906 (let ((file-name-coding-system nnmail-pathname-coding-system))
906 ;; Make sure the directory exists. 907 ;; Make sure the directory exists.
907 (gnus-make-directory (file-name-directory file)) 908 (gnus-make-directory (file-name-directory file))
@@ -1137,6 +1138,7 @@ In Emacs 22 this writes Babyl format; in Emacs 23 it writes mbox unless
1137FILENAME exists and is Babyl format." 1138FILENAME exists and is Babyl format."
1138 (require 'rmail) 1139 (require 'rmail)
1139 (require 'mm-util) 1140 (require 'mm-util)
1141 (require 'nnmail)
1140 ;; Some of this codes is borrowed from rmailout.el. 1142 ;; Some of this codes is borrowed from rmailout.el.
1141 (setq filename (expand-file-name filename)) 1143 (setq filename (expand-file-name filename))
1142 ;; FIXME should we really be messing with this defcustom? 1144 ;; FIXME should we really be messing with this defcustom?
@@ -1228,6 +1230,7 @@ FILENAME exists and is Babyl format."
1228 1230
1229(defun gnus-output-to-mail (filename &optional ask) 1231(defun gnus-output-to-mail (filename &optional ask)
1230 "Append the current article to a mail file named FILENAME." 1232 "Append the current article to a mail file named FILENAME."
1233 (require 'nnmail)
1231 (setq filename (expand-file-name filename)) 1234 (setq filename (expand-file-name filename))
1232 (let ((artbuf (current-buffer)) 1235 (let ((artbuf (current-buffer))
1233 (tmpbuf (get-buffer-create " *Gnus-output*"))) 1236 (tmpbuf (get-buffer-create " *Gnus-output*")))
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index d32ecac5dc3..b4f7f836189 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -1608,7 +1608,7 @@ slower."
1608 ("nnweb" none) 1608 ("nnweb" none)
1609 ("nnrss" none) 1609 ("nnrss" none)
1610 ("nnagent" post-mail) 1610 ("nnagent" post-mail)
1611 ("nnimap" post-mail address prompt-address physical-address) 1611 ("nnimap" post-mail address prompt-address physical-address respool)
1612 ("nnmaildir" mail respool address) 1612 ("nnmaildir" mail respool address)
1613 ("nnnil" none)) 1613 ("nnnil" none))
1614 "*An alist of valid select methods. 1614 "*An alist of valid select methods.
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index a53f9ac468d..4b4793dcfee 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -793,22 +793,42 @@ textual parts.")
793 793
794(defun nnimap-process-expiry-targets (articles group server) 794(defun nnimap-process-expiry-targets (articles group server)
795 (let ((deleted-articles nil)) 795 (let ((deleted-articles nil))
796 (dolist (article articles) 796 (cond
797 (let ((target nnmail-expiry-target)) 797 ;; shortcut further processing if we're going to delete the articles
798 (with-temp-buffer 798 ((eq nnmail-expiry-target 'delete)
799 (mm-disable-multibyte) 799 (setq deleted-articles articles)
800 (when (nnimap-request-article article group server (current-buffer)) 800 t)
801 (nnheader-message 7 "Expiring article %s:%d" group article) 801 ;; or just move them to another folder on the same IMAP server
802 (when (functionp target) 802 ((and (not (functionp nnmail-expiry-target))
803 (setq target (funcall target group))) 803 (gnus-server-equal (gnus-group-method nnmail-expiry-target)
804 (when (and target 804 (gnus-server-to-method
805 (not (eq target 'delete))) 805 (format "nnimap:%s" server))))
806 (if (or (gnus-request-group target t) 806 (and (nnimap-possibly-change-group group server)
807 (gnus-request-create-group target)) 807 (with-current-buffer (nnimap-buffer)
808 (nnmail-expiry-target-group target group) 808 (nnheader-message 7 "Expiring articles from %s: %s" group articles)
809 (setq target nil))) 809 (nnimap-command
810 (when target 810 "UID COPY %s %S"
811 (push article deleted-articles)))))) 811 (nnimap-article-ranges (gnus-compress-sequence articles))
812 (utf7-encode (gnus-group-real-name nnmail-expiry-target) t))
813 (setq deleted-articles articles)))
814 t)
815 (t
816 (dolist (article articles)
817 (let ((target nnmail-expiry-target))
818 (with-temp-buffer
819 (mm-disable-multibyte)
820 (when (nnimap-request-article article group server (current-buffer))
821 (nnheader-message 7 "Expiring article %s:%d" group article)
822 (when (functionp target)
823 (setq target (funcall target group)))
824 (when (and target
825 (not (eq target 'delete)))
826 (if (or (gnus-request-group target t)
827 (gnus-request-create-group target))
828 (nnmail-expiry-target-group target group)
829 (setq target nil)))
830 (when target
831 (push article deleted-articles))))))))
812 ;; Change back to the current group again. 832 ;; Change back to the current group again.
813 (nnimap-possibly-change-group group server) 833 (nnimap-possibly-change-group group server)
814 (setq deleted-articles (nreverse deleted-articles)) 834 (setq deleted-articles (nreverse deleted-articles))
diff --git a/lisp/gnus/nnir.el b/lisp/gnus/nnir.el
index 7e1bd309c9d..b706d150f7d 100644
--- a/lisp/gnus/nnir.el
+++ b/lisp/gnus/nnir.el
@@ -269,7 +269,7 @@ as `(keyfunc member)' and the corresponding element is just
269is `(valuefunc member)'." 269is `(valuefunc member)'."
270 `(unless (null ,sequence) 270 `(unless (null ,sequence)
271 (let (value) 271 (let (value)
272 (mapcar 272 (mapc
273 (lambda (member) 273 (lambda (member)
274 (let ((y (,keyfunc member)) 274 (let ((y (,keyfunc member))
275 (x ,(if valuefunc 275 (x ,(if valuefunc
@@ -1381,7 +1381,10 @@ Tested with Namazu 2.0.6 on a GNU/Linux system."
1381;; gmane interface 1381;; gmane interface
1382(defun nnir-run-gmane (query srv &optional groups) 1382(defun nnir-run-gmane (query srv &optional groups)
1383 "Run a search against a gmane back-end server." 1383 "Run a search against a gmane back-end server."
1384 (if (gnus-string-match-p "gmane.org$" srv) 1384 (if (gnus-string-match-p
1385 "gmane.org$"
1386 (or (cadr (assoc 'nntp-address (cddr (gnus-server-to-method srv))))
1387 ""))
1385 (let* ((case-fold-search t) 1388 (let* ((case-fold-search t)
1386 (qstring (cdr (assq 'query query))) 1389 (qstring (cdr (assq 'query query)))
1387 (server (cadr (gnus-server-to-method srv))) 1390 (server (cadr (gnus-server-to-method srv)))
diff --git a/lisp/gnus/nntp.el b/lisp/gnus/nntp.el
index 6504f05c9d2..9c9054a49c7 100644
--- a/lisp/gnus/nntp.el
+++ b/lisp/gnus/nntp.el
@@ -398,7 +398,8 @@ be restored and the command retried."
398 (cond ((looking-at "480") 398 (cond ((looking-at "480")
399 (nntp-handle-authinfo process)) 399 (nntp-handle-authinfo process))
400 ((looking-at "482") 400 ((looking-at "482")
401 (nnheader-report 'nntp (get 'nntp-authinfo-rejected 'error-message)) 401 (nnheader-report 'nntp "%s"
402 (get 'nntp-authinfo-rejected 'error-message))
402 (signal 'nntp-authinfo-rejected nil)) 403 (signal 'nntp-authinfo-rejected nil))
403 ((looking-at "^.*\n") 404 ((looking-at "^.*\n")
404 (delete-region (point) (progn (forward-line 1) (point))))) 405 (delete-region (point) (progn (forward-line 1) (point)))))
@@ -1411,7 +1412,7 @@ password contained in '~/.nntp-authinfo'."
1411 (let ((message (buffer-string))) 1412 (let ((message (buffer-string)))
1412 (while (string-match "[\r\n]+" message) 1413 (while (string-match "[\r\n]+" message)
1413 (setq message (replace-match " " t t message))) 1414 (setq message (replace-match " " t t message)))
1414 (nnheader-report 'nntp message) 1415 (nnheader-report 'nntp "%s" message)
1415 message)) 1416 message))
1416 1417
1417(defun nntp-accept-process-output (process) 1418(defun nntp-accept-process-output (process)
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index c07bb34ef8d..0b2fa939b1f 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -94,6 +94,7 @@ cid: URL as the argument.")
94(defvar shr-content-cache nil) 94(defvar shr-content-cache nil)
95(defvar shr-kinsoku-shorten nil) 95(defvar shr-kinsoku-shorten nil)
96(defvar shr-table-depth 0) 96(defvar shr-table-depth 0)
97(defvar shr-stylesheet nil)
97 98
98(defvar shr-map 99(defvar shr-map
99 (let ((map (make-sparse-keymap))) 100 (let ((map (make-sparse-keymap)))
@@ -191,18 +192,21 @@ redirects somewhere else."
191(defun shr-descend (dom) 192(defun shr-descend (dom)
192 (let ((function (intern (concat "shr-tag-" (symbol-name (car dom))) obarray)) 193 (let ((function (intern (concat "shr-tag-" (symbol-name (car dom))) obarray))
193 (style (cdr (assq :style (cdr dom)))) 194 (style (cdr (assq :style (cdr dom))))
195 (shr-stylesheet shr-stylesheet)
194 (start (point))) 196 (start (point)))
195 (when (and style 197 (when (and style
196 (string-match "color" style)) 198 (string-match "color" style))
197 (setq style (shr-parse-style style))) 199 (setq shr-stylesheet (nconc (shr-parse-style style)
200 shr-stylesheet)))
198 (if (fboundp function) 201 (if (fboundp function)
199 (funcall function (cdr dom)) 202 (funcall function (cdr dom))
200 (shr-generic (cdr dom))) 203 (shr-generic (cdr dom)))
201 (when (consp style) 204 (let ((color (cdr (assq 'color shr-stylesheet)))
202 (shr-insert-background-overlay (cdr (assq 'background-color style)) 205 (background (cdr (assq 'background-color
203 start) 206 shr-stylesheet))))
204 (shr-insert-foreground-overlay (cdr (assq 'color style)) 207 (when (and shr-stylesheet
205 start (point))))) 208 (or color background))
209 (shr-colorize-region start (point) color background)))))
206 210
207(defun shr-generic (cont) 211(defun shr-generic (cont)
208 (dolist (sub cont) 212 (dolist (sub cont)
@@ -544,10 +548,10 @@ START, and END."
544 548
545(autoload 'widget-convert-button "wid-edit") 549(autoload 'widget-convert-button "wid-edit")
546 550
547(defun shr-urlify (start url) 551(defun shr-urlify (start url &optional title)
548 (widget-convert-button 552 (widget-convert-button
549 'url-link start (point) 553 'url-link start (point)
550 :help-echo url 554 :help-echo (if title (format "%s (%s)" url title) url)
551 :keymap shr-map 555 :keymap shr-map
552 url) 556 url)
553 (put-text-property start (point) 'shr-url url)) 557 (put-text-property start (point) 'shr-url url))
@@ -581,41 +585,58 @@ ones, in case fg and bg are nil."
581 (t 585 (t
582 (shr-color-visible bg fg))))))) 586 (shr-color-visible bg fg)))))))
583 587
584(defun shr-get-background (pos) 588(defun shr-colorize-region (start end fg &optional bg)
585 "Return background color at POS."
586 (dolist (overlay (overlays-in pos (1+ pos)))
587 (let ((background (plist-get (overlay-get overlay 'face)
588 :background)))
589 (when background
590 (return background)))))
591
592(defun shr-insert-foreground-overlay (fg start end)
593 (when fg 589 (when fg
594 (let ((bg (shr-get-background start))) 590 (let ((new-colors (shr-color-check fg bg)))
595 (let ((new-colors (shr-color-check fg bg)))
596 (when new-colors
597 (overlay-put (make-overlay start end) 'face
598 (list :foreground (cadr new-colors))))))))
599
600(defun shr-insert-background-overlay (bg start)
601 "Insert an overlay with background color BG at START.
602The overlay has rear-advance set to t, so it will be used when
603text will be inserted at start."
604 (when bg
605 (let ((new-colors (shr-color-check nil bg)))
606 (when new-colors 591 (when new-colors
607 (overlay-put (make-overlay start start nil nil t) 'face 592 (shr-put-color start end :foreground (cadr new-colors))
608 (list :background (car new-colors))))))) 593 (when bg
594 (shr-put-color start end :background (car new-colors)))))))
595
596;; Put a color in the region, but avoid putting colors on on blank
597;; text at the start of the line, and the newline at the end, to avoid
598;; ugliness. Also, don't overwrite any existing color information,
599;; since this can be called recursively, and we want the "inner" color
600;; to win.
601(defun shr-put-color (start end type color)
602 (save-excursion
603 (goto-char start)
604 (while (< (point) end)
605 (when (bolp)
606 (skip-chars-forward " "))
607 (when (> (line-end-position) (point))
608 (shr-put-color-1 (point) (min (line-end-position) end) type color))
609 (if (< (line-end-position) end)
610 (forward-line 1)
611 (goto-char end)))))
612
613(defun shr-put-color-1 (start end type color)
614 (let* ((old-props (get-text-property start 'face))
615 (do-put (not (memq type old-props)))
616 change)
617 (while (< start end)
618 (setq change (next-single-property-change start 'face nil end))
619 (when do-put
620 (put-text-property start change 'face
621 (nconc (list type color) old-props)))
622 (setq old-props (get-text-property change 'face))
623 (setq do-put (not (memq type old-props)))
624 (setq start change))
625 (when (and do-put
626 (> end start))
627 (put-text-property start end 'face
628 (nconc (list type color old-props))))))
609 629
610;;; Tag-specific rendering rules. 630;;; Tag-specific rendering rules.
611 631
612(defun shr-tag-body (cont) 632(defun shr-tag-body (cont)
613 (let ((start (point)) 633 (let* ((start (point))
614 (fgcolor (cdr (assq :fgcolor cont))) 634 (fgcolor (cdr (assq :fgcolor cont)))
615 (bgcolor (cdr (assq :bgcolor cont)))) 635 (bgcolor (cdr (assq :bgcolor cont)))
616 (shr-insert-background-overlay bgcolor start) 636 (shr-stylesheet (list (cons :color fgcolor)
637 (cons :background-color bgcolor))))
617 (shr-generic cont) 638 (shr-generic cont)
618 (shr-insert-foreground-overlay fgcolor start (point)))) 639 (shr-colorize-region start (point) fgcolor bgcolor)))
619 640
620(defun shr-tag-p (cont) 641(defun shr-tag-p (cont)
621 (shr-ensure-paragraph) 642 (shr-ensure-paragraph)
@@ -669,10 +690,11 @@ text will be inserted at start."
669 690
670(defun shr-tag-a (cont) 691(defun shr-tag-a (cont)
671 (let ((url (cdr (assq :href cont))) 692 (let ((url (cdr (assq :href cont)))
693 (title (cdr (assq :title cont)))
672 (start (point)) 694 (start (point))
673 shr-start) 695 shr-start)
674 (shr-generic cont) 696 (shr-generic cont)
675 (shr-urlify (or shr-start start) url))) 697 (shr-urlify (or shr-start start) url title)))
676 698
677(defun shr-tag-object (cont) 699(defun shr-tag-object (cont)
678 (let ((start (point)) 700 (let ((start (point))
@@ -818,7 +840,7 @@ text will be inserted at start."
818 (let ((start (point)) 840 (let ((start (point))
819 (color (cdr (assq :color cont)))) 841 (color (cdr (assq :color cont))))
820 (shr-generic cont) 842 (shr-generic cont)
821 (shr-insert-foreground-overlay color start (point)))) 843 (shr-colorize-region start (point) color)))
822 844
823;;; Table rendering algorithm. 845;;; Table rendering algorithm.
824 846
@@ -870,7 +892,6 @@ text will be inserted at start."
870 (nheader (if header (shr-max-columns header))) 892 (nheader (if header (shr-max-columns header)))
871 (nbody (if body (shr-max-columns body))) 893 (nbody (if body (shr-max-columns body)))
872 (nfooter (if footer (shr-max-columns footer)))) 894 (nfooter (if footer (shr-max-columns footer))))
873 (shr-insert-background-overlay bgcolor (point))
874 (shr-tag-table-1 895 (shr-tag-table-1
875 (nconc 896 (nconc
876 (if caption `((tr (td ,@caption)))) 897 (if caption `((tr (td ,@caption))))
@@ -1013,48 +1034,44 @@ text will be inserted at start."
1013 (nreverse trs))) 1034 (nreverse trs)))
1014 1035
1015(defun shr-render-td (cont width fill) 1036(defun shr-render-td (cont width fill)
1016 (let ((background (shr-get-background (point)))) 1037 (with-temp-buffer
1017 (with-temp-buffer 1038 (let ((cache (cdr (assoc (cons width cont) shr-content-cache))))
1018 (let ((cache (cdr (assoc (cons width cont) shr-content-cache)))) 1039 (if cache
1019 (if cache 1040 (insert cache)
1020 (insert cache) 1041 (let ((shr-width width)
1021 (shr-insert-background-overlay (or (cdr (assq :bgcolor cont)) 1042 (shr-indentation 0))
1022 background) 1043 (shr-generic cont))
1023 (point)) 1044 (delete-region
1024 (let ((shr-width width) 1045 (point)
1025 (shr-indentation 0)) 1046 (+ (point)
1026 (shr-generic cont)) 1047 (skip-chars-backward " \t\n")))
1027 (delete-region 1048 (push (cons (cons width cont) (buffer-string))
1028 (point) 1049 shr-content-cache)))
1029 (+ (point) 1050 (goto-char (point-min))
1030 (skip-chars-backward " \t\n"))) 1051 (let ((max 0))
1031 (push (cons (cons width cont) (buffer-string)) 1052 (while (not (eobp))
1032 shr-content-cache))) 1053 (end-of-line)
1033 (goto-char (point-min)) 1054 (setq max (max max (current-column)))
1034 (let ((max 0)) 1055 (forward-line 1))
1035 (while (not (eobp)) 1056 (when fill
1036 (end-of-line) 1057 (goto-char (point-min))
1037 (setq max (max max (current-column))) 1058 ;; If the buffer is totally empty, then put a single blank
1038 (forward-line 1)) 1059 ;; line here.
1039 (when fill 1060 (if (zerop (buffer-size))
1040 (goto-char (point-min)) 1061 (insert (make-string width ? ))
1041 ;; If the buffer is totally empty, then put a single blank 1062 ;; Otherwise, fill the buffer.
1042 ;; line here. 1063 (while (not (eobp))
1043 (if (zerop (buffer-size)) 1064 (end-of-line)
1044 (insert (make-string width ? )) 1065 (when (> (- width (current-column)) 0)
1045 ;; Otherwise, fill the buffer. 1066 (insert (make-string (- width (current-column)) ? )))
1046 (while (not (eobp)) 1067 (forward-line 1))))
1047 (end-of-line) 1068 (if fill
1048 (when (> (- width (current-column)) 0) 1069 (list max
1049 (insert (make-string (- width (current-column)) ? ))) 1070 (count-lines (point-min) (point-max))
1050 (forward-line 1)))) 1071 (split-string (buffer-string) "\n")
1051 (if fill 1072 (shr-collect-overlays))
1052 (list max 1073 (list max
1053 (count-lines (point-min) (point-max)) 1074 (shr-natural-width))))))
1054 (split-string (buffer-string) "\n")
1055 (shr-collect-overlays))
1056 (list max
1057 (shr-natural-width)))))))
1058 1075
1059(defun shr-natural-width () 1076(defun shr-natural-width ()
1060 (goto-char (point-min)) 1077 (goto-char (point-min))