aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGnus developers2010-10-04 00:17:16 +0000
committerKatsumi Yamaoka2010-10-04 00:17:16 +0000
commita41c2e6d330243fa7b5d1537d5efb211f1c0d30c (patch)
tree5ffaa59adfee8e4fb1b83894e044b7aec9dff128
parent728a982db42d06c3c9db5f920336709387a54cda (diff)
downloademacs-a41c2e6d330243fa7b5d1537d5efb211f1c0d30c.tar.gz
emacs-a41c2e6d330243fa7b5d1537d5efb211f1c0d30c.zip
Merge changes made in Gnus trunk.
shr.el: Rename the tag functions a bit, and add some new ones. gnus-sum.el (gnus-summary-select-article-buffer): If the article buffer isn't shown, then select the current article first instead of bugging out. gnus-sum.el (gnus-summary-select-article-buffer): Show both the article and summary buffers again. shr.el (shr-tag-blockquote): Convert name. shr.el (shr-rescale-image): Use the right image-size variant. shr.el (shr-tag-p): Don't insert newlines at the start of the buffer. shr.el: Implement indentation in blockquotes. gnus-sum.el (gnus-summary-select-article-buffer): Really select the article buffer again. shr.el (shr-ensure-paragraph): Don't insert newlines on empty tags at the beginning of the buffer. gnus-ems.el, gnus-util.el, mm-decode.el, mm-view.el: Add resize for large images in mm. gnus-html.el (gnus-html-put-image): Use gnus-rescale-image. shr.el (shr-tag-p): Don't insert newlines on empty tags at the beginning of the buffer. gnus-ems.el, gnus-html.el, gnus-util.el, mm-decode.el, mm-view.el: Support image resizing. shr.el: Add headings. shr.el (shr-ensure-paragraph): Actually work. shr.el (shr-tag-li): Make <ul> prettier. shr.el (shr-insert): Get white space at the beginning/end of elements right. shr.el (shr-tag-li): Tweak <li> rendering. shr.el (shr-tag-p): Collapse subsequent <p>s. shr.el (shr-ensure-paragraph): Don't insert double line feeds after blank lines. shr.el (shr-tag-h6): Add. shr.el (shr-insert): \t is also space.
-rw-r--r--doc/misc/ChangeLog6
-rw-r--r--doc/misc/emacs-mime.texi12
-rw-r--r--lisp/gnus/ChangeLog58
-rw-r--r--lisp/gnus/gnus-ems.el6
-rw-r--r--lisp/gnus/gnus-html.el44
-rw-r--r--lisp/gnus/gnus-sum.el6
-rw-r--r--lisp/gnus/gnus-util.el20
-rw-r--r--lisp/gnus/mm-decode.el16
-rw-r--r--lisp/gnus/mm-view.el21
-rw-r--r--lisp/gnus/shr.el132
10 files changed, 251 insertions, 70 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 1fce969e1da..5c2766c8532 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,9 @@
12010-10-03 Julien Danjou <julien@danjou.info>
2
3 * emacs-mime.texi (Display Customization): Update
4 mm-inline-large-images documentation and add documentation for
5 mm-inline-large-images-proportion.
6
12010-10-03 Michael Albinus <michael.albinus@gmx.de> 72010-10-03 Michael Albinus <michael.albinus@gmx.de>
2 8
3 * tramp.texi (Frequently Asked Questions): Mention 9 * tramp.texi (Frequently Asked Questions): Mention
diff --git a/doc/misc/emacs-mime.texi b/doc/misc/emacs-mime.texi
index 2a0e8569266..475ce2bb53f 100644
--- a/doc/misc/emacs-mime.texi
+++ b/doc/misc/emacs-mime.texi
@@ -374,12 +374,18 @@ message as follows:
374@vindex mm-inline-large-images 374@vindex mm-inline-large-images
375When displaying inline images that are larger than the window, Emacs 375When displaying inline images that are larger than the window, Emacs
376does not enable scrolling, which means that you cannot see the whole 376does not enable scrolling, which means that you cannot see the whole
377image. To prevent this, the library tries to determine the image size 377image. To prevent this, the library tries to determine the image size
378before displaying it inline, and if it doesn't fit the window, the 378before displaying it inline, and if it doesn't fit the window, the
379library will display it externally (e.g. with @samp{ImageMagick} or 379library will display it externally (e.g. with @samp{ImageMagick} or
380@samp{xv}). Setting this variable to @code{t} disables this check and 380@samp{xv}). Setting this variable to @code{t} disables this check and
381makes the library display all inline images as inline, regardless of 381makes the library display all inline images as inline, regardless of
382their size. 382their size. If you set this variable to @code{resize}, the image will
383be displayed resized to fit in the window, if Emacs has the ability to
384resize images.
385
386@item mm-inline-large-images-proportion
387@vindex mm-inline-images-max-proportion
388The proportion used when resizing large images.
383 389
384@item mm-inline-override-types 390@item mm-inline-override-types
385@vindex mm-inline-override-types 391@vindex mm-inline-override-types
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 54519bc2054..17befd37e61 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,61 @@
12010-10-03 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * shr.el: Add headings.
4 (shr-ensure-paragraph): Actually work.
5 (shr-tag-li): Make <ul> prettier.
6 (shr-insert): Get white space at the beginning/end of elements right.
7 (shr-tag-p): Collapse subsequent <p>s.
8 (shr-ensure-paragraph): Don't insert double line feeds after blank
9 lines.
10 (shr-insert): \t is also space.
11 (shr-tag-s): Fix "s" tag name function.
12 (shr-tag-s): Fix face prop name.
13
142010-10-03 Julien Danjou <julien@danjou.info>
15
16 * gnus-html.el (gnus-html-put-image): Use gnus-rescale-image.
17
18 * mm-view.el (gnus-window-inside-pixel-edges): Add autoload for
19 gnus-window-inside-pixel-edges.
20
21 * gnus-ems.el (gnus-window-inside-pixel-edges): Move from gnus-html to
22 gnus-ems.
23
24 * mm-view.el (mm-inline-image-emacs): Support image resizing.
25
26 * gnus-util.el (gnus-rescale-image): Add generic gnus-rescale-image
27 function.
28
29 * mm-decode.el (mm-inline-large-images): Enhance defcustom and add
30 resize choice.
31
322010-10-03 Lars Magne Ingebrigtsen <larsi@gnus.org>
33
34 * shr.el (shr-tag-p): Don't insert newlines on empty tags at the
35 beginning of the buffer.
36
37 * gnus-sum.el (gnus-summary-select-article-buffer): Really select the
38 article buffer again.
39
40 * shr.el (shr-tag-p): Don't insert newlines at the start of the
41 buffer.
42
43 * mm-decode.el (mm-shr): Narrow before inserting, so that shr can know
44 when it's at the start of the buffer.
45
46 * shr.el (shr-tag-blockquote): Convert name.
47 (shr-rescale-image): Use the right image-size variant.
48
49 * gnus-sum.el (gnus-summary-select-article-buffer): If the article
50 buffer isn't shown, then select the current article first instead of
51 bugging out.
52 (gnus-summary-select-article-buffer): Show both the article and summary
53 buffers again.
54
55 * shr.el (shr-fontize-cont): Protect against regions with no text.
56 Rename tag functions to shr-tag-* for enhanced security.
57 (shr-tag-ul, shr-tag-ol, shr-tag-li, shr-tag-br): New functions.
58
12010-10-03 Chong Yidong <cyd@stupidchicken.com> 592010-10-03 Chong Yidong <cyd@stupidchicken.com>
2 60
3 * shr.el (shr-insert): 61 * shr.el (shr-insert):
diff --git a/lisp/gnus/gnus-ems.el b/lisp/gnus/gnus-ems.el
index b4a2fe960c6..e1e37eb37c2 100644
--- a/lisp/gnus/gnus-ems.el
+++ b/lisp/gnus/gnus-ems.el
@@ -307,6 +307,12 @@
307 end nil)))))) 307 end nil))))))
308 308
309(eval-and-compile 309(eval-and-compile
310 ;; XEmacs does not have window-inside-pixel-edges
311 (defalias 'gnus-window-inside-pixel-edges
312 (if (fboundp 'window-inside-pixel-edges)
313 'window-inside-pixel-edges
314 'window-pixel-edges))
315
310 (if (fboundp 'set-process-plist) 316 (if (fboundp 'set-process-plist)
311 (progn 317 (progn
312 (defalias 'gnus-set-process-plist 'set-process-plist) 318 (defalias 'gnus-set-process-plist 'set-process-plist)
diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el
index c007f71f64c..0f8ba83a60c 100644
--- a/lisp/gnus/gnus-html.el
+++ b/lisp/gnus/gnus-html.el
@@ -105,12 +105,7 @@ CHARS is a regexp-like character alternative (e.g., \"[)$]\")."
105 (match-string 0 encoded-text))) 105 (match-string 0 encoded-text)))
106 t t encoded-text) 106 t t encoded-text)
107 s (1+ s))) 107 s (1+ s)))
108 encoded-text)))) 108 encoded-text)))))
109 ;; XEmacs does not have window-inside-pixel-edges
110 (defalias 'gnus-window-inside-pixel-edges
111 (if (fboundp 'window-inside-pixel-edges)
112 'window-inside-pixel-edges
113 'window-pixel-edges)))
114 109
115(defun gnus-html-encode-url (url) 110(defun gnus-html-encode-url (url)
116 "Encode URL." 111 "Encode URL."
@@ -436,7 +431,17 @@ Return a string with image data."
436 (= (car size) 30) 431 (= (car size) 30)
437 (= (cdr size) 30)))) 432 (= (cdr size) 30))))
438 ;; Good image, add it! 433 ;; Good image, add it!
439 (let ((image (gnus-html-rescale-image image data size))) 434 (let ((image (gnus-html-rescale-image
435 image
436 ;; (width . height)
437 (cons
438 ;; Aimed width
439 (truncate
440 (* gnus-max-image-proportion
441 (- (nth 2 edges) (nth 0 edges))))
442 ;; Aimed height
443 (truncate (* gnus-max-image-proportion
444 (- (nth 3 edges) (nth 1 edges))))))))
440 (delete-region start end) 445 (delete-region start end)
441 (gnus-put-image image alt-text 'external) 446 (gnus-put-image image alt-text 'external)
442 (gnus-put-text-property start (point) 'help-echo alt-text) 447 (gnus-put-text-property start (point) 'help-echo alt-text)
@@ -459,31 +464,6 @@ Return a string with image data."
459 (gnus-add-image 'internal image)) 464 (gnus-add-image 'internal image))
460 nil)))))))) 465 nil))))))))
461 466
462(defun gnus-html-rescale-image (image data size)
463 (if (or (not (fboundp 'imagemagick-types))
464 (not (get-buffer-window (current-buffer))))
465 image
466 (let* ((width (car size))
467 (height (cdr size))
468 (edges (gnus-window-inside-pixel-edges
469 (get-buffer-window (current-buffer))))
470 (window-width (truncate (* gnus-max-image-proportion
471 (- (nth 2 edges) (nth 0 edges)))))
472 (window-height (truncate (* gnus-max-image-proportion
473 (- (nth 3 edges) (nth 1 edges)))))
474 scaled-image)
475 (when (> height window-height)
476 (setq image (or (create-image data 'imagemagick t
477 :height window-height)
478 image))
479 (setq size (image-size image t)))
480 (when (> (car size) window-width)
481 (setq image (or
482 (create-image data 'imagemagick t
483 :width window-width)
484 image)))
485 image)))
486
487(defun gnus-html-image-url-blocked-p (url blocked-images) 467(defun gnus-html-image-url-blocked-p (url blocked-images)
488 "Find out if URL is blocked by BLOCKED-IMAGES." 468 "Find out if URL is blocked by BLOCKED-IMAGES."
489 (let ((ret (and blocked-images 469 (let ((ret (and blocked-images
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index d9a7621baa2..c77fd1c4aa3 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -6933,8 +6933,10 @@ displayed, no centering will be performed."
6933 (interactive) 6933 (interactive)
6934 (if (not (gnus-buffer-live-p gnus-article-buffer)) 6934 (if (not (gnus-buffer-live-p gnus-article-buffer))
6935 (error "There is no article buffer for this summary buffer") 6935 (error "There is no article buffer for this summary buffer")
6936 (select-window (get-buffer-window gnus-article-buffer)) 6936 (unless (get-buffer-window gnus-article-buffer)
6937 (gnus-configure-windows 'only-article t))) 6937 (gnus-summary-show-article))
6938 (gnus-configure-windows 'article t)
6939 (select-window (get-buffer-window gnus-article-buffer))))
6938 6940
6939(defun gnus-summary-universal-argument (arg) 6941(defun gnus-summary-universal-argument (arg)
6940 "Perform any operation on all articles that are process/prefixed." 6942 "Perform any operation on all articles that are process/prefixed."
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index e140c7512d0..26d6e2c08b6 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -1932,6 +1932,26 @@ is allowed once again. (Immediately, if `inhibit-quit' is nil.)"
1932 (get-char-table ,character ,display-table))) 1932 (get-char-table ,character ,display-table)))
1933 `(aref ,display-table ,character))) 1933 `(aref ,display-table ,character)))
1934 1934
1935(defun gnus-rescale-image (image size)
1936 "Rescale IMAGE to SIZE if possible.
1937SIZE is in format (WIDTH . HEIGHT). Return a new image.
1938Sizes are in pixels."
1939 (if (or (not (fboundp 'imagemagick-types))
1940 (not (get-buffer-window (current-buffer))))
1941 image
1942 (let ((new-width (car size))
1943 (new-height (cdr size)))
1944 (when (> (cdr (image-size image t)) new-height)
1945 (setq image (or (create-image (plist-get (cdr image) :data) 'imagemagick t
1946 :height new-height)
1947 image)))
1948 (when (> (car (image-size image t)) new-width)
1949 (setq image (or
1950 (create-image (plist-get (cdr image) :data) 'imagemagick t
1951 :width new-width)
1952 image)))
1953 image)))
1954
1935(provide 'gnus-util) 1955(provide 'gnus-util)
1936 1956
1937;;; gnus-util.el ends here 1957;;; gnus-util.el ends here
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index e98d66683c9..ab96e349bb6 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -369,8 +369,12 @@ enables you to choose manually one of two types those mails include."
369 :group 'mime-display) 369 :group 'mime-display)
370 370
371(defcustom mm-inline-large-images nil 371(defcustom mm-inline-large-images nil
372 "If non-nil, then all images fit in the buffer." 372 "If t, then all images fit in the buffer.
373 :type 'boolean 373If 'resize, try to resize the images so they fit."
374 :type '(radio
375 (const :tag "Inline large images as they are." t)
376 (const :tag "Resize large images." resize)
377 (const :tag "Do not inline large images." nil))
374 :group 'mime-display) 378 :group 'mime-display)
375 379
376(defcustom mm-file-name-rewrite-functions 380(defcustom mm-file-name-rewrite-functions
@@ -1679,9 +1683,11 @@ If RECURSIVE, search recursively."
1679 (let ((article-buffer (current-buffer))) 1683 (let ((article-buffer (current-buffer)))
1680 (unless handle 1684 (unless handle
1681 (setq handle (mm-dissect-buffer t))) 1685 (setq handle (mm-dissect-buffer t)))
1682 (shr-insert-document 1686 (save-restriction
1683 (mm-with-part handle 1687 (narrow-to-region (point) (point))
1684 (libxml-parse-html-region (point-min) (point-max)))))) 1688 (shr-insert-document
1689 (mm-with-part handle
1690 (libxml-parse-html-region (point-min) (point-max)))))))
1685 1691
1686(provide 'mm-decode) 1692(provide 'mm-decode)
1687 1693
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index 566908ce1cb..82be361fce8 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -32,6 +32,7 @@
32(require 'smime) 32(require 'smime)
33 33
34(autoload 'gnus-completing-read "gnus-util") 34(autoload 'gnus-completing-read "gnus-util")
35(autoload 'gnus-window-inside-pixel-edges "gnus-ems")
35(autoload 'gnus-article-prepare-display "gnus-art") 36(autoload 'gnus-article-prepare-display "gnus-art")
36(autoload 'vcard-parse-string "vcard") 37(autoload 'vcard-parse-string "vcard")
37(autoload 'vcard-format-string "vcard") 38(autoload 'vcard-format-string "vcard")
@@ -76,6 +77,13 @@
76 :version "22.1" 77 :version "22.1"
77 :group 'mime-display) 78 :group 'mime-display)
78 79
80(defcustom mm-inline-large-images-proportion 0.9
81 "Maximum proportion of large image resized when
82`mm-inline-large-images' is set to resize."
83 :type 'float
84 :version "24.1"
85 :group 'mime-display)
86
79;;; Internal variables. 87;;; Internal variables.
80 88
81;;; 89;;;
@@ -85,7 +93,18 @@
85(defun mm-inline-image-emacs (handle) 93(defun mm-inline-image-emacs (handle)
86 (let ((b (point-marker)) 94 (let ((b (point-marker))
87 (inhibit-read-only t)) 95 (inhibit-read-only t))
88 (put-image (mm-get-image handle) b) 96 (put-image
97 (let ((image (mm-get-image handle)))
98 (if (eq mm-inline-large-images 'resize)
99 (gnus-rescale-image image
100 (let ((edges (gnus-window-inside-pixel-edges
101 (get-buffer-window (current-buffer)))))
102 (cons (truncate (* mm-inline-large-images-proportion
103 (- (nth 2 edges) (nth 0 edges))))
104 (truncate (* mm-inline-large-images-proportion
105 (- (nth 3 edges) (nth 1 edges)))))))
106 image))
107 b)
89 (insert "\n\n") 108 (insert "\n\n")
90 (mm-handle-set-undisplayer 109 (mm-handle-set-undisplayer
91 handle 110 handle
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index 2b53fee6f06..faeb16a7c01 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -53,6 +53,7 @@ fit these criteria."
53(defvar shr-folding-mode nil) 53(defvar shr-folding-mode nil)
54(defvar shr-state nil) 54(defvar shr-state nil)
55(defvar shr-start nil) 55(defvar shr-start nil)
56(defvar shr-indentation 0)
56 57
57(defvar shr-width 70) 58(defvar shr-width 70)
58 59
@@ -75,7 +76,7 @@ fit these criteria."
75 (shr-descend (shr-transform-dom dom)))) 76 (shr-descend (shr-transform-dom dom))))
76 77
77(defun shr-descend (dom) 78(defun shr-descend (dom)
78 (let ((function (intern (concat "shr-" (symbol-name (car dom))) obarray))) 79 (let ((function (intern (concat "shr-tag-" (symbol-name (car dom))) obarray)))
79 (if (fboundp function) 80 (if (fboundp function)
80 (funcall function (cdr dom)) 81 (funcall function (cdr dom))
81 (shr-generic (cdr dom))))) 82 (shr-generic (cdr dom)))))
@@ -85,37 +86,48 @@ fit these criteria."
85 (cond 86 (cond
86 ((eq (car sub) :text) 87 ((eq (car sub) :text)
87 (shr-insert (cdr sub))) 88 (shr-insert (cdr sub)))
88 ((consp (cdr sub)) 89 ((listp (cdr sub))
89 (shr-descend sub))))) 90 (shr-descend sub)))))
90 91
91(defun shr-p (cont) 92(defun shr-tag-p (cont)
92 (shr-ensure-newline) 93 (shr-ensure-paragraph)
93 (insert "\n")
94 (shr-generic cont) 94 (shr-generic cont)
95 (insert "\n")) 95 (shr-ensure-paragraph))
96 96
97(defun shr-b (cont) 97(defun shr-ensure-paragraph ()
98 (unless (bobp)
99 (if (bolp)
100 (unless (eql (char-after (- (point) 2)) ?\n)
101 (insert "\n"))
102 (if (save-excursion
103 (beginning-of-line)
104 (looking-at " *"))
105 (insert "\n")
106 (insert "\n\n")))))
107
108(defun shr-tag-b (cont)
98 (shr-fontize-cont cont 'bold)) 109 (shr-fontize-cont cont 'bold))
99 110
100(defun shr-i (cont) 111(defun shr-tag-i (cont)
101 (shr-fontize-cont cont 'italic)) 112 (shr-fontize-cont cont 'italic))
102 113
103(defun shr-u (cont) 114(defun shr-tag-u (cont)
104 (shr-fontize-cont cont 'underline)) 115 (shr-fontize-cont cont 'underline))
105 116
106(defun shr-s (cont) 117(defun shr-tag-s (cont)
107 (shr-fontize-cont cont 'strikethru)) 118 (shr-fontize-cont cont 'strike-through))
108 119
109(defun shr-fontize-cont (cont type) 120(defun shr-fontize-cont (cont &rest types)
110 (let (shr-start) 121 (let (shr-start)
111 (shr-generic cont) 122 (shr-generic cont)
112 (shr-add-font shr-start (point) type))) 123 (dolist (type types)
124 (shr-add-font (or shr-start (point)) (point) type))))
113 125
114(defun shr-add-font (start end type) 126(defun shr-add-font (start end type)
115 (let ((overlay (make-overlay start end))) 127 (let ((overlay (make-overlay start end)))
116 (overlay-put overlay 'face type))) 128 (overlay-put overlay 'face type)))
117 129
118(defun shr-a (cont) 130(defun shr-tag-a (cont)
119 (let ((url (cdr (assq :href cont))) 131 (let ((url (cdr (assq :href cont)))
120 shr-start) 132 shr-start)
121 (shr-generic cont) 133 (shr-generic cont)
@@ -129,7 +141,10 @@ fit these criteria."
129(defun shr-browse-url (widget &rest stuff) 141(defun shr-browse-url (widget &rest stuff)
130 (browse-url (widget-get widget :url))) 142 (browse-url (widget-get widget :url)))
131 143
132(defun shr-img (cont) 144(defun shr-tag-img (cont)
145 (when (and (> (current-column) 0)
146 (not (eq shr-state 'image)))
147 (insert "\n"))
133 (let ((start (point-marker))) 148 (let ((start (point-marker)))
134 (let ((alt (cdr (assq :alt cont))) 149 (let ((alt (cdr (assq :alt cont)))
135 (url (cdr (assq :src cont)))) 150 (url (cdr (assq :src cont))))
@@ -166,15 +181,17 @@ fit these criteria."
166(defun shr-put-image (data point alt) 181(defun shr-put-image (data point alt)
167 (if (not (display-graphic-p)) 182 (if (not (display-graphic-p))
168 (insert alt) 183 (insert alt)
169 (let ((image (shr-rescale-image data))) 184 (let ((image (ignore-errors
170 (put-image image point alt)))) 185 (shr-rescale-image data))))
186 (when image
187 (put-image image point alt)))))
171 188
172(defun shr-rescale-image (data) 189(defun shr-rescale-image (data)
173 (if (or (not (fboundp 'imagemagick-types)) 190 (if (or (not (fboundp 'imagemagick-types))
174 (not (get-buffer-window (current-buffer)))) 191 (not (get-buffer-window (current-buffer))))
175 (create-image data nil t) 192 (create-image data nil t)
176 (let* ((image (create-image data nil t)) 193 (let* ((image (create-image data nil t))
177 (size (image-size image)) 194 (size (image-size image t))
178 (width (car size)) 195 (width (car size))
179 (height (cdr size)) 196 (height (cdr size))
180 (edges (window-inside-pixel-edges 197 (edges (window-inside-pixel-edges
@@ -196,14 +213,15 @@ fit these criteria."
196 image))) 213 image)))
197 image))) 214 image)))
198 215
199(defun shr-pre (cont) 216(defun shr-tag-pre (cont)
200 (let ((shr-folding-mode nil)) 217 (let ((shr-folding-mode nil))
201 (shr-ensure-newline) 218 (shr-ensure-newline)
202 (shr-generic cont) 219 (shr-generic cont)
203 (shr-ensure-newline))) 220 (shr-ensure-newline)))
204 221
205(defun shr-blockquote (cont) 222(defun shr-tag-blockquote (cont)
206 (shr-pre cont)) 223 (let ((shr-indentation (+ shr-indentation 4)))
224 (shr-tag-pre cont)))
207 225
208(defun shr-ensure-newline () 226(defun shr-ensure-newline ()
209 (unless (zerop (current-column)) 227 (unless (zerop (current-column))
@@ -217,19 +235,32 @@ fit these criteria."
217 ((eq shr-folding-mode 'none) 235 ((eq shr-folding-mode 'none)
218 (insert t)) 236 (insert t))
219 (t 237 (t
220 (let (column) 238 (let ((first t)
239 column)
240 (when (and (string-match "^[ \t\n]" text)
241 (not (bolp)))
242 (insert " "))
221 (dolist (elem (split-string text)) 243 (dolist (elem (split-string text))
222 (setq column (current-column)) 244 (setq column (current-column))
223 (when (> column 0) 245 (when (> column 0)
224 (if (> (+ column (length elem) 1) shr-width) 246 (cond
225 (insert "\n") 247 ((> (+ column (length elem) 1) shr-width)
226 (insert " "))) 248 (insert "\n"))
249 ((not first)
250 (insert " "))))
251 (setq first nil)
252 (when (and (bolp)
253 (> shr-indentation 0))
254 (insert (make-string shr-indentation ? )))
227 ;; The shr-start is a special variable that is used to pass 255 ;; The shr-start is a special variable that is used to pass
228 ;; upwards the first point in the buffer where the text really 256 ;; upwards the first point in the buffer where the text really
229 ;; starts. 257 ;; starts.
230 (unless shr-start 258 (unless shr-start
231 (setq shr-start (point))) 259 (setq shr-start (point)))
232 (insert elem)))))) 260 (insert elem))
261 (when (and (string-match "[ \t\n]$" text)
262 (not (bolp)))
263 (insert " "))))))
233 264
234(defun shr-get-image-data (url) 265(defun shr-get-image-data (url)
235 "Get image data for URL. 266 "Get image data for URL.
@@ -241,6 +272,53 @@ Return a string with image data."
241 (search-forward "\r\n\r\n" nil t)) 272 (search-forward "\r\n\r\n" nil t))
242 (buffer-substring (point) (point-max))))) 273 (buffer-substring (point) (point-max)))))
243 274
275(defvar shr-list-mode nil)
276
277(defun shr-tag-ul (cont)
278 (shr-ensure-paragraph)
279 (let ((shr-list-mode 'ul))
280 (shr-generic cont)))
281
282(defun shr-tag-ol (cont)
283 (let ((shr-list-mode 1))
284 (shr-generic cont)))
285
286(defun shr-tag-li (cont)
287 (shr-ensure-newline)
288 (if (numberp shr-list-mode)
289 (progn
290 (insert (format "%d " shr-list-mode))
291 (setq shr-list-mode (1+ shr-list-mode)))
292 (insert "* "))
293 (shr-generic cont))
294
295(defun shr-tag-br (cont)
296 (shr-ensure-newline)
297 (shr-generic cont))
298
299(defun shr-tag-h1 (cont)
300 (shr-heading cont 'bold 'underline))
301
302(defun shr-tag-h2 (cont)
303 (shr-heading cont 'bold))
304
305(defun shr-tag-h3 (cont)
306 (shr-heading cont 'italic))
307
308(defun shr-tag-h4 (cont)
309 (shr-heading cont))
310
311(defun shr-tag-h5 (cont)
312 (shr-heading cont))
313
314(defun shr-tag-h6 (cont)
315 (shr-heading cont))
316
317(defun shr-heading (cont &rest types)
318 (shr-ensure-paragraph)
319 (apply #'shr-fontize-cont cont types)
320 (shr-ensure-paragraph))
321
244(provide 'shr) 322(provide 'shr)
245 323
246;;; shr.el ends here 324;;; shr.el ends here