aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGnus developers2010-11-24 22:54:47 +0000
committerKatsumi Yamaoka2010-11-24 22:54:47 +0000
commit144b7b5c83962d353d6037f83b8d699a34da9f22 (patch)
tree374fc0e21a8402ac0eaa9683e480b227dd466c0e
parent872ab164598b4d20e72f5e2b6b1087636bc47cd1 (diff)
downloademacs-144b7b5c83962d353d6037f83b8d699a34da9f22.tar.gz
emacs-144b7b5c83962d353d6037f83b8d699a34da9f22.zip
Merge changes made in Gnus trunk.
shr-color.el (shr-color-visible): Really return original background if fixed. shr.el (shr-insert-color-overlay): Replace deprecated syntax. shr.el (shr-tag-body, shr-descend): Add background support. shr.el (shr-tag-title): Add. gnus-sum.el (gnus-summary-articles-in-thread): Fix a bug that causes this function to return incorrect results. shr.el (shr-parse-style): Drop !important from styles. message.el (message-goto-body): Remove the <#secure special-casing, which is too special. mm-util.el (mm-enable-multibyte): Use `to' instead of t. This fixes something or other in Emacs 23, and is backwards compatible. message.el (message-goto-body): Use called-interactively-p. message.el (message-in-body-p): message-goto-body returns point. nnimap.el (nnimap-request-move-article): It's no longer necessary to clear marks before moving, since they're synced from the Gnus side first. gnus-sum.el (gnus-summary-push-marks-to-backend): New function. gnus-sum.el (gnus-summary-move-article): Copy over all marks before moving, so that IMAP doesn't think a new article has arrived. message.el (message-goto-body): called-interactively-p needs a parameter, so use `any'. gnus-cache.el (gnus-summary-insert-cached-articles): Use it. gnus-sum.el (gnus-summary-include-articles): New function. shr.el (shr-tag-table, shr-render-td): Add bgcolor support. shr-color.el (shr-color-visible): Fix docstring. shr.el (shr-insert-background-overlay): Fix typo. shr.el (shr-render-td): Copy the background before rendering.
-rw-r--r--lisp/gnus/ChangeLog62
-rw-r--r--lisp/gnus/gnus-cache.el11
-rw-r--r--lisp/gnus/gnus-sum.el35
-rw-r--r--lisp/gnus/message.el8
-rw-r--r--lisp/gnus/mm-util.el2
-rw-r--r--lisp/gnus/nnimap.el3
-rw-r--r--lisp/gnus/shr-color.el13
-rw-r--r--lisp/gnus/shr.el164
8 files changed, 227 insertions, 71 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index e6cb7d11d94..4f06225f8ca 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,5 +1,64 @@
12010-11-24 Lars Magne Ingebrigtsen <larsi@gnus.org> 12010-11-24 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 2
3 * gnus-cache.el (gnus-summary-insert-cached-articles): Use it.
4
5 * gnus-sum.el (gnus-summary-include-articles): New function.
6
7 * message.el (message-goto-body): called-interactively-p needs a
8 parameter, so use `any'.
9
10 * nnimap.el (nnimap-request-move-article): It's no longer necessary to
11 clear marks before moving, since they're synced from the Gnus side
12 first.
13
14 * gnus-sum.el (gnus-summary-push-marks-to-backend): New function.
15 (gnus-summary-move-article): Copy over all marks before moving, so that
16 IMAP doesn't think a new article has arrived.
17
182010-11-24 Julien Danjou <julien@danjou.info>
19
20 * shr.el (shr-insert-background-overlay): Fix typo.
21 (shr-render-td): Copy the background before rendering.
22
23 * shr-color.el (shr-color-visible): Fix docstring.
24
25 * shr.el (shr-tag-table): Add bgcolor support.
26 (shr-render-td): Add bgcolor support.
27 (shr-get-background): Add.
28 (shr-insert-foreground-overlay): Use shr-get-background.
29
30 * message.el (message-goto-body): Use called-interactively-p.
31 (message-in-body-p): message-goto-body returns point.
32
332010-11-24 Lars Magne Ingebrigtsen <larsi@gnus.org>
34
35 * mm-util.el (mm-enable-multibyte): Use `to' instead of t. This fixes
36 Fixes something or other in Emacs 23, and is backwards compatible.
37
38 * message.el (message-goto-body): Remove the <#secure special-casing,
39 which is too special.
40
41 * shr.el (shr-parse-style): Drop !important from styles.
42
432010-11-24 Daniel Schoepe <daniel.schoepe@googlemail.com> (tiny change)
44
45 * gnus-sum.el (gnus-summary-articles-in-thread): Fix a bug that causes
46 this function to return incorrect results when calling it with an
47 explicit article argument different from
48 (gnus-summary-article-number).
49
502010-11-24 Julien Danjou <julien@danjou.info>
51
52 * shr.el (shr-insert-color-overlay): Replace deprecated syntax.
53 (shr-tag-body): Add background support.
54 (shr-descend): Add background support.
55 (shr-tag-title): Add.
56
57 * shr-color.el (shr-color-visible): Really return original background
58 if fixed.
59
602010-11-24 Lars Magne Ingebrigtsen <larsi@gnus.org>
61
3 * shr.el (shr-color-check): Protect against non-existant colour names. 62 * shr.el (shr-color-check): Protect against non-existant colour names.
4 63
52010-11-24 Julien Danjou <julien@danjou.info> 642010-11-24 Julien Danjou <julien@danjou.info>
@@ -46,7 +105,8 @@
46 105
47 * shr.el (shr-parse-style): Replace \n with space in style parsing. 106 * shr.el (shr-parse-style): Replace \n with space in style parsing.
48 107
49 * shr-color.el (shr-color-hsl-to-rgb-fractions): Use shr-color-hue-to-rgb. 108 * shr-color.el (shr-color-hsl-to-rgb-fractions): Use
109 shr-color-hue-to-rgb.
50 (shr-color->hexadecimal): Call shr-color-hsl-to-rgb-fractions. 110 (shr-color->hexadecimal): Call shr-color-hsl-to-rgb-fractions.
51 111
522010-11-23 Lars Magne Ingebrigtsen <larsi@gnus.org> 1122010-11-23 Lars Magne Ingebrigtsen <larsi@gnus.org>
diff --git a/lisp/gnus/gnus-cache.el b/lisp/gnus/gnus-cache.el
index 822996069cc..50ab1c64a23 100644
--- a/lisp/gnus/gnus-cache.el
+++ b/lisp/gnus/gnus-cache.el
@@ -383,9 +383,14 @@ Returns the list of articles removed."
383 "Insert all the articles cached for this group into the current buffer." 383 "Insert all the articles cached for this group into the current buffer."
384 (interactive) 384 (interactive)
385 (let ((gnus-verbose (max 6 gnus-verbose))) 385 (let ((gnus-verbose (max 6 gnus-verbose)))
386 (if (not gnus-newsgroup-cached) 386 (cond
387 (gnus-message 3 "No cached articles for this group") 387 ((not gnus-newsgroup-cached)
388 (gnus-summary-goto-subjects gnus-newsgroup-cached)))) 388 (gnus-message 3 "No cached articles for this group"))
389 ;; This is faster if there are few articles to insert.
390 ((< (length gnus-newsgroup-cached) 20)
391 (gnus-summary-goto-subjects gnus-newsgroup-cached))
392 (t
393 (gnus-summary-include-articles gnus-newsgroup-cached)))))
389 394
390(defun gnus-summary-limit-include-cached () 395(defun gnus-summary-limit-include-cached ()
391 "Limit the summary buffer to articles that are cached." 396 "Limit the summary buffer to articles that are cached."
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index ff85d45d7b0..72b6d40defd 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -8500,6 +8500,18 @@ fetched for this group."
8500 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit)) 8500 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8501 (gnus-summary-position-point))) 8501 (gnus-summary-position-point)))
8502 8502
8503(defun gnus-summary-include-articles (articles)
8504 "Fetch the headers for ARTICLES and then display the summary lines."
8505 (let ((gnus-inhibit-demon t)
8506 (gnus-agent nil)
8507 (gnus-read-all-available-headers t))
8508 (setq gnus-newsgroup-headers
8509 (gnus-merge
8510 'list gnus-newsgroup-headers
8511 (gnus-fetch-headers articles nil t)
8512 'gnus-article-sort-by-number))
8513 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8514
8503(defun gnus-summary-limit-exclude-dormant () 8515(defun gnus-summary-limit-exclude-dormant ()
8504 "Hide all dormant articles." 8516 "Hide all dormant articles."
8505 (interactive) 8517 (interactive)
@@ -9705,6 +9717,9 @@ ACTION can be either `move' (the default), `crosspost' or `copy'."
9705 articles) 9717 articles)
9706 (while articles 9718 (while articles
9707 (setq article (pop articles)) 9719 (setq article (pop articles))
9720 ;; Set any marks that may have changed in the summary buffer.
9721 (when gnus-preserve-marks
9722 (gnus-summary-push-marks-to-backend article))
9708 (let ((gnus-newsgroup-original-name gnus-newsgroup-name) 9723 (let ((gnus-newsgroup-original-name gnus-newsgroup-name)
9709 (gnus-article-original-subject 9724 (gnus-article-original-subject
9710 (mail-header-subject 9725 (mail-header-subject
@@ -9921,6 +9936,25 @@ ACTION can be either `move' (the default), `crosspost' or `copy'."
9921 (gnus-summary-position-point) 9936 (gnus-summary-position-point)
9922 (gnus-set-mode-line 'summary))) 9937 (gnus-set-mode-line 'summary)))
9923 9938
9939(defun gnus-summary-push-marks-to-backend (article)
9940 (let ((add nil)
9941 (delete nil)
9942 (marks gnus-article-mark-lists))
9943 (if (memq article gnus-newsgroup-unreads)
9944 (push 'read add)
9945 (push 'read delete))
9946 (while marks
9947 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9948 (if (memq article (symbol-value
9949 (intern (format "gnus-newsgroup-%s"
9950 (caar marks)))))
9951 (push (cdar marks) add)
9952 (push (cdar marks) delete)))
9953 (pop marks))
9954 (gnus-request-set-mark gnus-newsgroup-name
9955 `(((,article) add ,add)
9956 ((,article) del ,delete)))))
9957
9924(defun gnus-summary-copy-article (&optional n to-newsgroup select-method) 9958(defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9925 "Copy the current article to some other group. 9959 "Copy the current article to some other group.
9926If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to. 9960If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
@@ -11232,6 +11266,7 @@ with that article."
11232 (mail-header-subject (gnus-data-header (car data))))) 11266 (mail-header-subject (gnus-data-header (car data)))))
11233 (t nil))) 11267 (t nil)))
11234 (end-point (save-excursion 11268 (end-point (save-excursion
11269 (goto-char (gnus-data-pos (car data)))
11235 (if (gnus-summary-go-to-next-thread) 11270 (if (gnus-summary-go-to-next-thread)
11236 (point) (point-max)))) 11271 (point) (point-max))))
11237 articles) 11272 articles)
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 07ffaf14fcb..bd6aa82b77a 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -3047,10 +3047,10 @@ M-RET `message-newline-and-reformat' (break the line and reformat)."
3047 (interactive) 3047 (interactive)
3048 (message-position-on-field "Summary" "Subject")) 3048 (message-position-on-field "Summary" "Subject"))
3049 3049
3050(defun message-goto-body (&optional interactivep) 3050(defun message-goto-body ()
3051 "Move point to the beginning of the message body." 3051 "Move point to the beginning of the message body."
3052 (interactive (list t)) 3052 (interactive)
3053 (when (and interactivep 3053 (when (and (called-interactively-p 'any)
3054 (looking-at "[ \t]*\n")) 3054 (looking-at "[ \t]*\n"))
3055 (expand-abbrev)) 3055 (expand-abbrev))
3056 (goto-char (point-min)) 3056 (goto-char (point-min))
@@ -3059,7 +3059,7 @@ M-RET `message-newline-and-reformat' (break the line and reformat)."
3059 3059
3060(defun message-in-body-p () 3060(defun message-in-body-p ()
3061 "Return t if point is in the message body." 3061 "Return t if point is in the message body."
3062 (let ((body (save-excursion (message-goto-body) (point)))) 3062 (let ((body (save-excursion (message-goto-body))))
3063 (>= (point) body))) 3063 (>= (point) body)))
3064 3064
3065(defun message-goto-eoh () 3065(defun message-goto-eoh ()
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index 67b41e0cb3a..700c1a6bb64 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -903,7 +903,7 @@ mail with multiple parts is preferred to sending a Unicode one.")
903 "Set the multibyte flag of the current buffer. 903 "Set the multibyte flag of the current buffer.
904Only do this if the default value of `enable-multibyte-characters' is 904Only do this if the default value of `enable-multibyte-characters' is
905non-nil. This is a no-op in XEmacs." 905non-nil. This is a no-op in XEmacs."
906 (set-buffer-multibyte t))) 906 (set-buffer-multibyte 'to)))
907 907
908 (if (featurep 'xemacs) 908 (if (featurep 'xemacs)
909 (defalias 'mm-disable-multibyte 'ignore) 909 (defalias 'mm-disable-multibyte 'ignore)
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index f6315a5aab7..86bba98c208 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -783,9 +783,6 @@ textual parts.")
783 (if internal-move-group 783 (if internal-move-group
784 (let ((result 784 (let ((result
785 (with-current-buffer (nnimap-buffer) 785 (with-current-buffer (nnimap-buffer)
786 ;; Clear all flags before moving.
787 (nnimap-send-command "UID STORE %d FLAGS.SILENT ()"
788 article)
789 (nnimap-command "UID COPY %d %S" 786 (nnimap-command "UID COPY %d %S"
790 article 787 article
791 (utf7-encode internal-move-group t))))) 788 (utf7-encode internal-move-group t)))))
diff --git a/lisp/gnus/shr-color.el b/lisp/gnus/shr-color.el
index 78fd0395290..2a4a6b3d4b7 100644
--- a/lisp/gnus/shr-color.el
+++ b/lisp/gnus/shr-color.el
@@ -318,8 +318,8 @@ If FIXED is t, then val1 will not be touched."
318 318
319(defun shr-color-visible (bg fg &optional fixed-background) 319(defun shr-color-visible (bg fg &optional fixed-background)
320 "Check that BG and FG colors are visible if they are drawn on each other. 320 "Check that BG and FG colors are visible if they are drawn on each other.
321Return t if they are. If they are too similar, two new colors are 321Return (bg fg) if they are. If they are too similar, two new
322returned instead. 322colors are returned instead.
323If FIXED-BACKGROUND is set, and if the color are not visible, a 323If FIXED-BACKGROUND is set, and if the color are not visible, a
324new background color will not be computed. Only the foreground 324new background color will not be computed. Only the foreground
325color will be adapted to be visible on BG." 325color will be adapted to be visible on BG."
@@ -337,11 +337,14 @@ color will be adapted to be visible on BG."
337 (let ((Ls (set-minimum-interval (car bg-lab) (car fg-lab) 0 100 337 (let ((Ls (set-minimum-interval (car bg-lab) (car fg-lab) 0 100
338 shr-color-visible-luminance-min 338 shr-color-visible-luminance-min
339 fixed-background))) 339 fixed-background)))
340 (setcar bg-lab (car Ls)) 340 (unless fixed-background
341 (setcar bg-lab (car Ls)))
341 (setcar fg-lab (cadr Ls)) 342 (setcar fg-lab (cadr Ls))
342 (list 343 (list
343 (apply 'format "#%02x%02x%02x" 344 (if fixed-background
344 (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) (apply 'lab->rgb bg-lab))) 345 bg
346 (apply 'format "#%02x%02x%02x"
347 (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) (apply 'lab->rgb bg-lab))))
345 (apply 'format "#%02x%02x%02x" 348 (apply 'format "#%02x%02x%02x"
346 (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) (apply 'lab->rgb fg-lab)))))))) 349 (mapcar (lambda (x) (* (max (min 1 x) 0) 255)) (apply 'lab->rgb fg-lab))))))))
347 350
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index 36c8d703e46..26d2b3b4cd2 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -201,7 +201,10 @@ redirects somewhere else."
201 (funcall function (cdr dom)) 201 (funcall function (cdr dom))
202 (shr-generic (cdr dom))) 202 (shr-generic (cdr dom)))
203 (when (consp style) 203 (when (consp style)
204 (shr-insert-color-overlay (cdr (assq 'color style)) start (point))))) 204 (shr-insert-background-overlay (cdr (assq 'background-color style))
205 start)
206 (shr-insert-foreground-overlay (cdr (assq 'color style))
207 start (point)))))
205 208
206(defun shr-generic (cont) 209(defun shr-generic (cont)
207 (dolist (sub cont) 210 (dolist (sub cont)
@@ -494,23 +497,65 @@ START, and END."
494 497
495(autoload 'shr-color-visible "shr-color") 498(autoload 'shr-color-visible "shr-color")
496(autoload 'shr-color->hexadecimal "shr-color") 499(autoload 'shr-color->hexadecimal "shr-color")
497(defun shr-color-check (fg &optional bg) 500
498 "Check that FG is visible on BG." 501(defun shr-color-check (fg bg)
499 (let ((hex-color (shr-color->hexadecimal fg))) 502 "Check that FG is visible on BG.
500 (when hex-color 503Returns (fg bg) with corrected values.
501 (shr-color-visible (or (shr-color->hexadecimal bg) 504Returns nil if the colors that would be used are the default
502 (frame-parameter nil 'background-color)) 505ones, in case fg and bg are nil."
503 hex-color (not bg))))) 506 (when (or fg bg)
504 507 (let ((fixed (cond ((null fg) 'fg)
505(defun shr-insert-color-overlay (color start end) 508 ((null bg) 'bg))))
506 (when color 509 ;; Convert colors to hexadecimal, or set them to default.
507 (let ((new-color (cadr (shr-color-check color)))) 510 (let ((fg (or (shr-color->hexadecimal fg)
508 (when new-color 511 (frame-parameter nil 'foreground-color)))
509 (overlay-put (make-overlay start end) 'face 512 (bg (or (shr-color->hexadecimal bg)
510 (cons 'foreground-color new-color)))))) 513 (frame-parameter nil 'background-color))))
514 (cond ((eq fixed 'bg)
515 ;; Only return the new fg
516 (list nil (cadr (shr-color-visible bg fg t))))
517 ((eq fixed 'fg)
518 ;; Invert args and results and return only the new bg
519 (list (cadr (shr-color-visible fg bg t)) nil))
520 (t
521 (shr-color-visible bg fg)))))))
522
523(defun shr-get-background (pos)
524 "Return background color at POS."
525 (dolist (overlay (overlays-in start (1+ start)))
526 (let ((background (plist-get (overlay-get overlay 'face)
527 :background)))
528 (when background
529 (return background)))))
530
531(defun shr-insert-foreground-overlay (fg start end)
532 (when fg
533 (let ((bg (shr-get-background start)))
534 (let ((new-colors (shr-color-check fg bg)))
535 (when new-colors
536 (overlay-put (make-overlay start end) 'face
537 (list :foreground (cadr new-colors))))))))
538
539(defun shr-insert-background-overlay (bg start)
540 "Insert an overlay with background color BG at START.
541The overlay has rear-advance set to t, so it will be used when
542text will be inserted at start."
543 (when bg
544 (let ((new-colors (shr-color-check nil bg)))
545 (when new-colors
546 (overlay-put (make-overlay start start nil nil t) 'face
547 (list :background (car new-colors)))))))
511 548
512;;; Tag-specific rendering rules. 549;;; Tag-specific rendering rules.
513 550
551(defun shr-tag-body (cont)
552 (let ((start (point))
553 (fgcolor (cdr (assq :fgcolor cont)))
554 (bgcolor (cdr (assq :bgcolor cont))))
555 (shr-insert-background-overlay bgcolor start)
556 (shr-generic cont)
557 (shr-insert-foreground-overlay fgcolor start (point))))
558
514(defun shr-tag-p (cont) 559(defun shr-tag-p (cont)
515 (shr-ensure-paragraph) 560 (shr-ensure-paragraph)
516 (shr-indent) 561 (shr-indent)
@@ -554,6 +599,8 @@ START, and END."
554 (cadr elem)) 599 (cadr elem))
555 (let ((name (replace-regexp-in-string "^ +\\| +$" "" (car elem))) 600 (let ((name (replace-regexp-in-string "^ +\\| +$" "" (car elem)))
556 (value (replace-regexp-in-string "^ +\\| +$" "" (cadr elem)))) 601 (value (replace-regexp-in-string "^ +\\| +$" "" (cadr elem))))
602 (when (string-match " *!important\\'" value)
603 (setq value (substring value 0 (match-beginning 0))))
557 (push (cons (intern name obarray) 604 (push (cons (intern name obarray)
558 value) 605 value)
559 plist))))) 606 plist)))))
@@ -703,11 +750,14 @@ START, and END."
703 (shr-ensure-newline) 750 (shr-ensure-newline)
704 (insert (make-string shr-width shr-hr-line) "\n")) 751 (insert (make-string shr-width shr-hr-line) "\n"))
705 752
753(defun shr-tag-title (cont)
754 (shr-heading cont 'bold 'underline))
755
706(defun shr-tag-font (cont) 756(defun shr-tag-font (cont)
707 (let ((start (point)) 757 (let ((start (point))
708 (color (cdr (assq :color cont)))) 758 (color (cdr (assq :color cont))))
709 (shr-generic cont) 759 (shr-generic cont)
710 (shr-insert-color-overlay color start (point)))) 760 (shr-insert-foreground-overlay color start (point))))
711 761
712;;; Table rendering algorithm. 762;;; Table rendering algorithm.
713 763
@@ -755,9 +805,11 @@ START, and END."
755 (header (cdr (assq 'thead cont))) 805 (header (cdr (assq 'thead cont)))
756 (body (or (cdr (assq 'tbody cont)) cont)) 806 (body (or (cdr (assq 'tbody cont)) cont))
757 (footer (cdr (assq 'tfoot cont))) 807 (footer (cdr (assq 'tfoot cont)))
808 (bgcolor (cdr (assq :bgcolor cont)))
758 (nheader (if header (shr-max-columns header))) 809 (nheader (if header (shr-max-columns header)))
759 (nbody (if body (shr-max-columns body))) 810 (nbody (if body (shr-max-columns body)))
760 (nfooter (if footer (shr-max-columns footer)))) 811 (nfooter (if footer (shr-max-columns footer))))
812 (shr-insert-background-overlay bgcolor (point))
761 (shr-tag-table-1 813 (shr-tag-table-1
762 (nconc 814 (nconc
763 (if caption `((tr (td ,@caption)))) 815 (if caption `((tr (td ,@caption))))
@@ -900,44 +952,48 @@ START, and END."
900 (nreverse trs))) 952 (nreverse trs)))
901 953
902(defun shr-render-td (cont width fill) 954(defun shr-render-td (cont width fill)
903 (with-temp-buffer 955 (let ((background (shr-get-background (point))))
904 (let ((cache (cdr (assoc (cons width cont) shr-content-cache)))) 956 (with-temp-buffer
905 (if cache 957 (let ((cache (cdr (assoc (cons width cont) shr-content-cache))))
906 (insert cache) 958 (if cache
907 (let ((shr-width width) 959 (insert cache)
908 (shr-indentation 0)) 960 (shr-insert-background-overlay (or (cdr (assq :bgcolor cont))
909 (shr-generic cont)) 961 background)
910 (delete-region 962 (point))
911 (point) 963 (let ((shr-width width)
912 (+ (point) 964 (shr-indentation 0))
913 (skip-chars-backward " \t\n"))) 965 (shr-generic cont))
914 (push (cons (cons width cont) (buffer-string)) 966 (delete-region
915 shr-content-cache))) 967 (point)
916 (goto-char (point-min)) 968 (+ (point)
917 (let ((max 0)) 969 (skip-chars-backward " \t\n")))
918 (while (not (eobp)) 970 (push (cons (cons width cont) (buffer-string))
919 (end-of-line) 971 shr-content-cache)))
920 (setq max (max max (current-column))) 972 (goto-char (point-min))
921 (forward-line 1)) 973 (let ((max 0))
922 (when fill 974 (while (not (eobp))
923 (goto-char (point-min)) 975 (end-of-line)
924 ;; If the buffer is totally empty, then put a single blank 976 (setq max (max max (current-column)))
925 ;; line here. 977 (forward-line 1))
926 (if (zerop (buffer-size)) 978 (when fill
927 (insert (make-string width ? )) 979 (goto-char (point-min))
928 ;; Otherwise, fill the buffer. 980 ;; If the buffer is totally empty, then put a single blank
929 (while (not (eobp)) 981 ;; line here.
930 (end-of-line) 982 (if (zerop (buffer-size))
931 (when (> (- width (current-column)) 0) 983 (insert (make-string width ? ))
932 (insert (make-string (- width (current-column)) ? ))) 984 ;; Otherwise, fill the buffer.
933 (forward-line 1)))) 985 (while (not (eobp))
934 (if fill 986 (end-of-line)
935 (list max 987 (when (> (- width (current-column)) 0)
936 (count-lines (point-min) (point-max)) 988 (insert (make-string (- width (current-column)) ? )))
937 (split-string (buffer-string) "\n") 989 (forward-line 1))))
938 (shr-collect-overlays)) 990 (if fill
939 (list max 991 (list max
940 (shr-natural-width)))))) 992 (count-lines (point-min) (point-max))
993 (split-string (buffer-string) "\n")
994 (shr-collect-overlays))
995 (list max
996 (shr-natural-width)))))))
941 997
942(defun shr-natural-width () 998(defun shr-natural-width ()
943 (goto-char (point-min)) 999 (goto-char (point-min))