Mercurial > emacs
annotate lisp/gnus/shr.el @ 112440:b5017c649dfb
Check return values of some library calls.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 22 Jan 2011 23:30:19 -0800 |
parents | f17e96101723 |
children | 98ad7c9e56a3 |
rev | line source |
---|---|
110698
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
1 ;;; shr.el --- Simple HTML Renderer |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
2 |
112045
52100bac91db
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111973
diff
changeset
|
3 ;; Copyright (C) 2010, 2011 Free Software Foundation, Inc. |
110698
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
4 |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
6 ;; Keywords: html |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
7 |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
9 |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
13 ;; (at your option) any later version. |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
14 |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
19 |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
22 |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
23 ;;; Commentary: |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
24 |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
25 ;; This package takes a HTML parse tree (as provided by |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
26 ;; libxml-parse-html-region) and renders it in the current buffer. It |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
27 ;; does not do CSS, JavaScript or anything advanced: It's geared |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
28 ;; towards rendering typical short snippets of HTML, like what you'd |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
29 ;; find in HTML email and the like. |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
30 |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
31 ;;; Code: |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
32 |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
33 (eval-when-compile (require 'cl)) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
34 (require 'browse-url) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
35 |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
36 (defgroup shr nil |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
37 "Simple HTML Renderer" |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
38 :group 'mail) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
39 |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
40 (defcustom shr-max-image-proportion 0.9 |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
41 "How big pictures displayed are in relation to the window they're in. |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
42 A value of 0.7 means that they are allowed to take up 70% of the |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
43 width and height of the window. If they are larger than this, |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
44 and Emacs supports it, then the images will be rescaled down to |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
45 fit these criteria." |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
46 :version "24.1" |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
47 :group 'shr |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
48 :type 'float) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
49 |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
50 (defcustom shr-blocked-images nil |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
51 "Images that have URLs matching this regexp will be blocked." |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
52 :version "24.1" |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
53 :group 'shr |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
54 :type 'regexp) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
55 |
111627
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
56 (defcustom shr-table-horizontal-line ?- |
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
57 "Character used to draw horizontal table lines." |
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
58 :group 'shr |
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
59 :type 'character) |
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
60 |
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
61 (defcustom shr-table-vertical-line ?| |
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
62 "Character used to draw vertical table lines." |
110873
d98a67277730
shr,el: Allow shr table char to be customized.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110859
diff
changeset
|
63 :group 'shr |
110999
9330a5183ae6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110996
diff
changeset
|
64 :type 'character) |
110873
d98a67277730
shr,el: Allow shr table char to be customized.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110859
diff
changeset
|
65 |
d98a67277730
shr,el: Allow shr table char to be customized.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110859
diff
changeset
|
66 (defcustom shr-table-corner ?+ |
111627
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
67 "Character used to draw table corners." |
110917
3243e7055d49
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
68 :group 'shr |
110999
9330a5183ae6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110996
diff
changeset
|
69 :type 'character) |
110917
3243e7055d49
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
70 |
3243e7055d49
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
71 (defcustom shr-hr-line ?- |
111627
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
72 "Character used to draw hr lines." |
110873
d98a67277730
shr,el: Allow shr table char to be customized.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110859
diff
changeset
|
73 :group 'shr |
110999
9330a5183ae6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110996
diff
changeset
|
74 :type 'character) |
110873
d98a67277730
shr,el: Allow shr table char to be customized.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110859
diff
changeset
|
75 |
110966
0272ba632fc2
shr: make shr-width a defcustom, use it in shr-tag-img.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110957
diff
changeset
|
76 (defcustom shr-width fill-column |
112045
52100bac91db
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111973
diff
changeset
|
77 "Frame width to use for rendering. |
52100bac91db
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111973
diff
changeset
|
78 May either be an integer specifying a fixed width in characters, |
52100bac91db
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111973
diff
changeset
|
79 or nil, meaning that the full width of the window should be |
52100bac91db
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111973
diff
changeset
|
80 used." |
52100bac91db
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111973
diff
changeset
|
81 :type '(choice (integer :tag "Fixed width in characters") |
52100bac91db
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111973
diff
changeset
|
82 (const :tag "Use the width of the window" nil)) |
110966
0272ba632fc2
shr: make shr-width a defcustom, use it in shr-tag-img.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110957
diff
changeset
|
83 :group 'shr) |
0272ba632fc2
shr: make shr-width a defcustom, use it in shr-tag-img.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110957
diff
changeset
|
84 |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
85 (defvar shr-content-function nil |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
86 "If bound, this should be a function that will return the content. |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
87 This is used for cid: URLs, and the function is called with the |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
88 cid: URL as the argument.") |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
89 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
90 ;;; Internal variables. |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
91 |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
92 (defvar shr-folding-mode nil) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
93 (defvar shr-state nil) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
94 (defvar shr-start nil) |
110747
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
95 (defvar shr-indentation 0) |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
96 (defvar shr-inhibit-images nil) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
97 (defvar shr-list-mode nil) |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
98 (defvar shr-content-cache nil) |
111032
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
99 (defvar shr-kinsoku-shorten nil) |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
100 (defvar shr-table-depth 0) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
101 (defvar shr-stylesheet nil) |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
102 |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
103 (defvar shr-map |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
104 (let ((map (make-sparse-keymap))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
105 (define-key map "a" 'shr-show-alt-text) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
106 (define-key map "i" 'shr-browse-image) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
107 (define-key map "I" 'shr-insert-image) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
108 (define-key map "u" 'shr-copy-url) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
109 (define-key map "v" 'shr-browse-url) |
111058
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
110 (define-key map "o" 'shr-save-contents) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
111 (define-key map "\r" 'shr-browse-url) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
112 map)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
113 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
114 ;; Public functions and commands. |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
115 |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
116 ;;;###autoload |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
117 (defun shr-insert-document (dom) |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
118 (setq shr-content-cache nil) |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
119 (let ((shr-state nil) |
112045
52100bac91db
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111973
diff
changeset
|
120 (shr-start nil) |
52100bac91db
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111973
diff
changeset
|
121 (shr-width (or shr-width (window-width)))) |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
122 (shr-descend (shr-transform-dom dom)))) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
123 |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
124 (defun shr-copy-url () |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
125 "Copy the URL under point to the kill ring. |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
126 If called twice, then try to fetch the URL and see whether it |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
127 redirects somewhere else." |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
128 (interactive) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
129 (let ((url (get-text-property (point) 'shr-url))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
130 (cond |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
131 ((not url) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
132 (message "No URL under point")) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
133 ;; Resolve redirected URLs. |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
134 ((equal url (car kill-ring)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
135 (url-retrieve |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
136 url |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
137 (lambda (a) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
138 (when (and (consp a) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
139 (eq (car a) :redirect)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
140 (with-temp-buffer |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
141 (insert (cadr a)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
142 (goto-char (point-min)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
143 ;; Remove common tracking junk from the URL. |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
144 (when (re-search-forward ".utm_.*" nil t) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
145 (replace-match "" t t)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
146 (message "Copied %s" (buffer-string)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
147 (copy-region-as-kill (point-min) (point-max))))))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
148 ;; Copy the URL to the kill ring. |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
149 (t |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
150 (with-temp-buffer |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
151 (insert url) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
152 (copy-region-as-kill (point-min) (point-max)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
153 (message "Copied %s" url)))))) |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
154 |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
155 (defun shr-show-alt-text () |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
156 "Show the ALT text of the image under point." |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
157 (interactive) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
158 (let ((text (get-text-property (point) 'shr-alt))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
159 (if (not text) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
160 (message "No image under point") |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
161 (message "%s" text)))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
162 |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
163 (defun shr-browse-image () |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
164 "Browse the image under point." |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
165 (interactive) |
111556
ee13ba492319
Rework how Gnus is supposed to be able to display all the images in HTML.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111490
diff
changeset
|
166 (let ((url (get-text-property (point) 'image-url))) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
167 (if (not url) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
168 (message "No image under point") |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
169 (message "Browsing %s..." url) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
170 (browse-url url)))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
171 |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
172 (defun shr-insert-image () |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
173 "Insert the image under point into the buffer." |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
174 (interactive) |
111556
ee13ba492319
Rework how Gnus is supposed to be able to display all the images in HTML.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111490
diff
changeset
|
175 (let ((url (get-text-property (point) 'image-url))) |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
176 (if (not url) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
177 (message "No image under point") |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
178 (message "Inserting %s..." url) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
179 (url-retrieve url 'shr-image-fetched |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
180 (list (current-buffer) (1- (point)) (point-marker)) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
181 t)))) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
182 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
183 ;;; Utility functions. |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
184 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
185 (defun shr-transform-dom (dom) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
186 (let ((result (list (pop dom)))) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
187 (dolist (arg (pop dom)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
188 (push (cons (intern (concat ":" (symbol-name (car arg))) obarray) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
189 (cdr arg)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
190 result)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
191 (dolist (sub dom) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
192 (if (stringp sub) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111240
diff
changeset
|
193 (push (cons 'text sub) result) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
194 (push (shr-transform-dom sub) result))) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
195 (nreverse result))) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
196 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
197 (defun shr-descend (dom) |
111682
2c6350617cc3
shr.el (shr-color->hexadecimal): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
198 (let ((function (intern (concat "shr-tag-" (symbol-name (car dom))) obarray)) |
2c6350617cc3
shr.el (shr-color->hexadecimal): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
199 (style (cdr (assq :style (cdr dom)))) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
200 (shr-stylesheet shr-stylesheet) |
111682
2c6350617cc3
shr.el (shr-color->hexadecimal): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
201 (start (point))) |
111838
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
202 (when style |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
203 (if (string-match "color" style) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
204 (setq shr-stylesheet (nconc (shr-parse-style style) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
205 shr-stylesheet)) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
206 (setq style nil))) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
207 (if (fboundp function) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
208 (funcall function (cdr dom)) |
111682
2c6350617cc3
shr.el (shr-color->hexadecimal): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
209 (shr-generic (cdr dom))) |
111838
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
210 ;; If style is set, then this node has set the color. |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
211 (when style |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
212 (shr-colorize-region start (point) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
213 (cdr (assq 'color shr-stylesheet)) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
214 (cdr (assq 'background-color shr-stylesheet)))))) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
215 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
216 (defun shr-generic (cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
217 (dolist (sub cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
218 (cond |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111240
diff
changeset
|
219 ((eq (car sub) 'text) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
220 (shr-insert (cdr sub))) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
221 ((listp (cdr sub)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
222 (shr-descend sub))))) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
223 |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
224 (defmacro shr-char-breakable-p (char) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
225 "Return non-nil if a line can be broken before and after CHAR." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
226 `(aref fill-find-break-point-function-table ,char)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
227 (defmacro shr-char-nospace-p (char) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
228 "Return non-nil if no space is required before and after CHAR." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
229 `(aref fill-nospace-between-words-table ,char)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
230 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
231 ;; KINSOKU is a Japanese word meaning a rule that should not be violated. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
232 ;; In Emacs, it is a term used for characters, e.g. punctuation marks, |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
233 ;; parentheses, and so on, that should not be placed in the beginning |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
234 ;; of a line or the end of a line. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
235 (defmacro shr-char-kinsoku-bol-p (char) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
236 "Return non-nil if a line ought not to begin with CHAR." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
237 `(aref (char-category-set ,char) ?>)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
238 (defmacro shr-char-kinsoku-eol-p (char) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
239 "Return non-nil if a line ought not to end with CHAR." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
240 `(aref (char-category-set ,char) ?<)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
241 (unless (shr-char-kinsoku-bol-p (make-char 'japanese-jisx0208 33 35)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
242 (load "kinsoku" nil t)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
243 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
244 (defun shr-insert (text) |
110917
3243e7055d49
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
245 (when (and (eq shr-state 'image) |
3243e7055d49
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
246 (not (string-match "\\`[ \t\n]+\\'" text))) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
247 (insert "\n") |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
248 (setq shr-state nil)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
249 (cond |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
250 ((eq shr-folding-mode 'none) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
251 (insert text)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
252 (t |
111021
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
253 (when (and (string-match "\\`[ \t\n]" text) |
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
254 (not (bolp)) |
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
255 (not (eq (char-after (1- (point))) ? ))) |
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
256 (insert " ")) |
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
257 (dolist (elem (split-string text)) |
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
258 (when (and (bolp) |
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
259 (> shr-indentation 0)) |
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
260 (shr-indent)) |
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
261 ;; No space is needed behind a wide character categorized as |
111022
d263303441df
shr.el (shr-insert): Comment fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111021
diff
changeset
|
262 ;; kinsoku-bol, between characters both categorized as nospace, |
d263303441df
shr.el (shr-insert): Comment fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111021
diff
changeset
|
263 ;; or at the beginning of a line. |
111021
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
264 (let (prev) |
111973
d60eda14e134
shr.el (shr-insert): Set shr-start after deleting trailing space; don't delete it within indentation.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111862
diff
changeset
|
265 (when (and (> (current-column) shr-indentation) |
d60eda14e134
shr.el (shr-insert): Set shr-start after deleting trailing space; don't delete it within indentation.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111862
diff
changeset
|
266 (eq (preceding-char) ? ) |
111002
62243368de05
shr.el (shr-insert): Remove space inserted before or after a breakable character or at the beginning or the end of a line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110999
diff
changeset
|
267 (or (= (line-beginning-position) (1- (point))) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
268 (and (shr-char-breakable-p |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
269 (setq prev (char-after (- (point) 2)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
270 (shr-char-kinsoku-bol-p prev)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
271 (and (shr-char-nospace-p prev) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
272 (shr-char-nospace-p (aref elem 0))))) |
111021
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
273 (delete-char -1))) |
111973
d60eda14e134
shr.el (shr-insert): Set shr-start after deleting trailing space; don't delete it within indentation.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111862
diff
changeset
|
274 ;; The shr-start is a special variable that is used to pass |
d60eda14e134
shr.el (shr-insert): Set shr-start after deleting trailing space; don't delete it within indentation.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111862
diff
changeset
|
275 ;; upwards the first point in the buffer where the text really |
d60eda14e134
shr.el (shr-insert): Set shr-start after deleting trailing space; don't delete it within indentation.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111862
diff
changeset
|
276 ;; starts. |
d60eda14e134
shr.el (shr-insert): Set shr-start after deleting trailing space; don't delete it within indentation.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111862
diff
changeset
|
277 (unless shr-start |
d60eda14e134
shr.el (shr-insert): Set shr-start after deleting trailing space; don't delete it within indentation.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111862
diff
changeset
|
278 (setq shr-start (point))) |
111021
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
279 (insert elem) |
111485
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
280 (let (found) |
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
281 (while (and (> (current-column) shr-width) |
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
282 (progn |
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
283 (setq found (shr-find-fill-point)) |
111730
55d0f7023d7b
shr.el (shr-insert): Revert last change.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111711
diff
changeset
|
284 (not (eolp)))) |
111490
cd618db8e653
shr.el (shr-insert): Fix last change.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111485
diff
changeset
|
285 (when (eq (preceding-char) ? ) |
cd618db8e653
shr.el (shr-insert): Fix last change.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111485
diff
changeset
|
286 (delete-char -1)) |
cd618db8e653
shr.el (shr-insert): Fix last change.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111485
diff
changeset
|
287 (insert "\n") |
cd618db8e653
shr.el (shr-insert): Fix last change.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111485
diff
changeset
|
288 (unless found |
111485
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
289 (put-text-property (1- (point)) (point) 'shr-break t) |
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
290 ;; No space is needed at the beginning of a line. |
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
291 (when (eq (following-char) ? ) |
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
292 (delete-char 1))) |
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
293 (when (> shr-indentation 0) |
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
294 (shr-indent)) |
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
295 (end-of-line)) |
4c3fdb97fdaf
shr.el (shr-insert): Don't break long line if it is because of kinsoku-bol characters in the line end.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111450
diff
changeset
|
296 (insert " "))) |
111021
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
297 (unless (string-match "[ \t\n]\\'" text) |
7aa9d9b402c8
shr.el (shr-insert): Don't insert space behind a wide character categorized as kinsoku-bol, or between characters both categorized as nospace.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111019
diff
changeset
|
298 (delete-char -1))))) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
299 |
110917
3243e7055d49
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
300 (defun shr-find-fill-point () |
111032
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
301 (when (> (move-to-column shr-width) shr-width) |
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
302 (backward-char 1)) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
303 (let ((bp (point)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
304 failed) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
305 (while (not (or (setq failed (= (current-column) shr-indentation)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
306 (eq (preceding-char) ? ) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
307 (eq (following-char) ? ) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
308 (shr-char-breakable-p (preceding-char)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
309 (shr-char-breakable-p (following-char)) |
111832
7e8cf0f45075
nnir.el (nnir-request-move-article): Remove obsolete code.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111830
diff
changeset
|
310 (if (eq (preceding-char) ?') |
7e8cf0f45075
nnir.el (nnir-request-move-article): Remove obsolete code.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111830
diff
changeset
|
311 (not (memq (char-after (- (point) 2)) |
7e8cf0f45075
nnir.el (nnir-request-move-article): Remove obsolete code.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111830
diff
changeset
|
312 (list nil ?\n ? ))) |
7e8cf0f45075
nnir.el (nnir-request-move-article): Remove obsolete code.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111830
diff
changeset
|
313 (and (shr-char-kinsoku-bol-p (preceding-char)) |
111840
b050075901af
shr.el (shr-find-fill-point): Don't break a line after a kinsoku-bol character if a non-breakable character follows.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111838
diff
changeset
|
314 (shr-char-breakable-p (following-char)) |
111832
7e8cf0f45075
nnir.el (nnir-request-move-article): Remove obsolete code.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111830
diff
changeset
|
315 (not (shr-char-kinsoku-bol-p (following-char))))) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
316 (shr-char-kinsoku-eol-p (following-char)))) |
111032
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
317 (backward-char 1)) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
318 (if (and (not (or failed (eolp))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
319 (eq (preceding-char) ?')) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
320 (while (not (or (setq failed (eolp)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
321 (eq (following-char) ? ) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
322 (shr-char-breakable-p (following-char)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
323 (shr-char-kinsoku-eol-p (following-char)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
324 (forward-char 1))) |
111032
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
325 (if failed |
111002
62243368de05
shr.el (shr-insert): Remove space inserted before or after a breakable character or at the beginning or the end of a line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110999
diff
changeset
|
326 ;; There's no breakable point, so we give it up. |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
327 (let (found) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
328 (goto-char bp) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
329 (unless shr-kinsoku-shorten |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
330 (while (and (setq found (re-search-forward |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
331 "\\(\\c>\\)\\| \\|\\c<\\|\\c|" |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
332 (line-end-position) 'move)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
333 (eq (preceding-char) ?'))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
334 (if (and found (not (match-beginning 1))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
335 (goto-char (match-beginning 0))))) |
111730
55d0f7023d7b
shr.el (shr-insert): Revert last change.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111711
diff
changeset
|
336 (or |
55d0f7023d7b
shr.el (shr-insert): Revert last change.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111711
diff
changeset
|
337 (eolp) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
338 ;; Don't put kinsoku-bol characters at the beginning of a line, |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
339 ;; or kinsoku-eol characters at the end of a line. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
340 (cond |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
341 (shr-kinsoku-shorten |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
342 (while (and (not (memq (preceding-char) (list ?\C-@ ?\n ? ))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
343 (shr-char-kinsoku-eol-p (preceding-char))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
344 (backward-char 1)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
345 (when (setq failed (= (current-column) shr-indentation)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
346 ;; There's no breakable point that doesn't violate kinsoku, |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
347 ;; so we look for the second best position. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
348 (while (and (progn |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
349 (forward-char 1) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
350 (<= (current-column) shr-width)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
351 (progn |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
352 (setq bp (point)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
353 (shr-char-kinsoku-eol-p (following-char))))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
354 (goto-char bp))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
355 ((shr-char-kinsoku-eol-p (preceding-char)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
356 (if (shr-char-kinsoku-eol-p (following-char)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
357 ;; There are consecutive kinsoku-eol characters. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
358 (setq failed t) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
359 (let ((count 4)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
360 (while |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
361 (progn |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
362 (backward-char 1) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
363 (and (> (setq count (1- count)) 0) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
364 (not (memq (preceding-char) (list ?\C-@ ?\n ? ))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
365 (or (shr-char-kinsoku-eol-p (preceding-char)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
366 (shr-char-kinsoku-bol-p (following-char))))))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
367 (if (setq failed (= (current-column) shr-indentation)) |
111730
55d0f7023d7b
shr.el (shr-insert): Revert last change.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111711
diff
changeset
|
368 ;; There's no breakable point that doesn't violate kinsoku, |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
369 ;; so we go to the second best position. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
370 (if (looking-at "\\(\\c<+\\)\\c<") |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
371 (goto-char (match-end 1)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
372 (forward-char 1))))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
373 (t |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
374 (if (shr-char-kinsoku-bol-p (preceding-char)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
375 ;; There are consecutive kinsoku-bol characters. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
376 (setq failed t) |
111730
55d0f7023d7b
shr.el (shr-insert): Revert last change.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111711
diff
changeset
|
377 (let ((count 4)) |
55d0f7023d7b
shr.el (shr-insert): Revert last change.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111711
diff
changeset
|
378 (while (and (>= (setq count (1- count)) 0) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
379 (shr-char-kinsoku-bol-p (following-char)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
380 (shr-char-breakable-p (following-char))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
381 (forward-char 1)))))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
382 (when (eq (following-char) ? ) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
383 (forward-char 1)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111730
diff
changeset
|
384 (not failed))) |
110917
3243e7055d49
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
385 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
386 (defun shr-ensure-newline () |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
387 (unless (zerop (current-column)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
388 (insert "\n"))) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
389 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
390 (defun shr-ensure-paragraph () |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
391 (unless (bobp) |
110898
069deed4cdec
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110873
diff
changeset
|
392 (if (<= (current-column) shr-indentation) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
393 (unless (save-excursion |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
394 (forward-line -1) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
395 (looking-at " *$")) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
396 (insert "\n")) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
397 (if (save-excursion |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
398 (beginning-of-line) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
399 (looking-at " *$")) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
400 (insert "\n") |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
401 (insert "\n\n"))))) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
402 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
403 (defun shr-indent () |
110898
069deed4cdec
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110873
diff
changeset
|
404 (when (> shr-indentation 0) |
069deed4cdec
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110873
diff
changeset
|
405 (insert (make-string shr-indentation ? )))) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
406 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
407 (defun shr-fontize-cont (cont &rest types) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
408 (let (shr-start) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
409 (shr-generic cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
410 (dolist (type types) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
411 (shr-add-font (or shr-start (point)) (point) type)))) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
412 |
111072
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
413 ;; Add an overlay in the region, but avoid putting the font properties |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
414 ;; on blank text at the start of the line, and the newline at the end, |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
415 ;; to avoid ugliness. |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
416 (defun shr-add-font (start end type) |
111072
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
417 (save-excursion |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
418 (goto-char start) |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
419 (while (< (point) end) |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
420 (when (bolp) |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
421 (skip-chars-forward " ")) |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
422 (let ((overlay (make-overlay (point) (min (line-end-position) end)))) |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
423 (overlay-put overlay 'face type)) |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
424 (if (< (line-end-position) end) |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
425 (forward-line 1) |
a7fee19797df
message.el (message-fix-before-sending): Change options when sending non-printable characters.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111067
diff
changeset
|
426 (goto-char end))))) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
427 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
428 (defun shr-browse-url () |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
429 "Browse the URL under point." |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
430 (interactive) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
431 (let ((url (get-text-property (point) 'shr-url))) |
111401
733acab855e4
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111395
diff
changeset
|
432 (cond |
733acab855e4
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111395
diff
changeset
|
433 ((not url) |
733acab855e4
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111395
diff
changeset
|
434 (message "No link under point")) |
733acab855e4
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111395
diff
changeset
|
435 ((string-match "^mailto:" url) |
111450
eb9988805a37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111401
diff
changeset
|
436 (browse-url-mailto url)) |
111401
733acab855e4
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111395
diff
changeset
|
437 (t |
733acab855e4
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111395
diff
changeset
|
438 (browse-url url))))) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
439 |
111058
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
440 (defun shr-save-contents (directory) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
441 "Save the contents from URL in a file." |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
442 (interactive "DSave contents of URL to directory: ") |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
443 (let ((url (get-text-property (point) 'shr-url))) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
444 (if (not url) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
445 (message "No link under point") |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
446 (url-retrieve (shr-encode-url url) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
447 'shr-store-contents (list url directory))))) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
448 |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
449 (defun shr-store-contents (status url directory) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
450 (unless (plist-get status :error) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
451 (when (or (search-forward "\n\n" nil t) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
452 (search-forward "\r\n\r\n" nil t)) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
453 (write-region (point) (point-max) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
454 (expand-file-name (file-name-nondirectory url) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
455 directory))))) |
ea17726e9043
shr.el (shr-save-contents): New command and keystroke.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111057
diff
changeset
|
456 |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
457 (defun shr-image-fetched (status buffer start end) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
458 (when (and (buffer-name buffer) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
459 (not (plist-get status :error))) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
460 (url-store-in-cache (current-buffer)) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
461 (when (or (search-forward "\n\n" nil t) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
462 (search-forward "\r\n\r\n" nil t)) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
463 (let ((data (buffer-substring (point) (point-max)))) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
464 (with-current-buffer buffer |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
465 (let ((alt (buffer-substring start end)) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
466 (inhibit-read-only t)) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
467 (delete-region start end) |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
468 (goto-char start) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
469 (shr-put-image data alt)))))) |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
470 (kill-buffer (current-buffer))) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
471 |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
472 (defun shr-put-image (data alt) |
111218
b6601148b588
shr.el (shr-put-image): Use point even if only inserting text; save-excursion on alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111195
diff
changeset
|
473 (if (display-graphic-p) |
b6601148b588
shr.el (shr-put-image): Use point even if only inserting text; save-excursion on alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111195
diff
changeset
|
474 (let ((image (ignore-errors |
b6601148b588
shr.el (shr-put-image): Use point even if only inserting text; save-excursion on alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111195
diff
changeset
|
475 (shr-rescale-image data)))) |
b6601148b588
shr.el (shr-put-image): Use point even if only inserting text; save-excursion on alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111195
diff
changeset
|
476 (when image |
111584
4273d2312244
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111578
diff
changeset
|
477 ;; When inserting big-ish pictures, put them at the |
4273d2312244
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111578
diff
changeset
|
478 ;; beginning of the line. |
4273d2312244
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111578
diff
changeset
|
479 (when (and (> (current-column) 0) |
4273d2312244
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111578
diff
changeset
|
480 (> (car (image-size image t)) 400)) |
4273d2312244
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111578
diff
changeset
|
481 (insert "\n")) |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
482 (insert-image image (or alt "*")))) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
483 (insert alt))) |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
484 |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
485 (defun shr-rescale-image (data) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
486 (if (or (not (fboundp 'imagemagick-types)) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
487 (not (get-buffer-window (current-buffer)))) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
488 (create-image data nil t) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
489 (let* ((image (create-image data nil t)) |
110747
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
490 (size (image-size image t)) |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
491 (width (car size)) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
492 (height (cdr size)) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
493 (edges (window-inside-pixel-edges |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
494 (get-buffer-window (current-buffer)))) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
495 (window-width (truncate (* shr-max-image-proportion |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
496 (- (nth 2 edges) (nth 0 edges))))) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
497 (window-height (truncate (* shr-max-image-proportion |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
498 (- (nth 3 edges) (nth 1 edges))))) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
499 scaled-image) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
500 (when (> height window-height) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
501 (setq image (or (create-image data 'imagemagick t |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
502 :height window-height) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
503 image)) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
504 (setq size (image-size image t))) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
505 (when (> (car size) window-width) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
506 (setq image (or |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
507 (create-image data 'imagemagick t |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
508 :width window-width) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
509 image))) |
112101
f17e96101723
nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
112045
diff
changeset
|
510 (when (and (fboundp 'create-animated-image) |
f17e96101723
nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
112045
diff
changeset
|
511 (eq (image-type data nil t) 'gif)) |
f17e96101723
nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
112045
diff
changeset
|
512 (setq image (create-animated-image data 'gif t))) |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
513 image))) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
514 |
111285 | 515 ;; url-cache-extract autoloads url-cache. |
516 (declare-function url-cache-create-filename "url-cache" (url)) | |
517 (autoload 'mm-disable-multibyte "mm-util") | |
111450
eb9988805a37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111401
diff
changeset
|
518 (autoload 'browse-url-mailto "browse-url") |
111285 | 519 |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
520 (defun shr-get-image-data (url) |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
521 "Get image data for URL. |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
522 Return a string with image data." |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
523 (with-temp-buffer |
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
524 (mm-disable-multibyte) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
525 (when (ignore-errors |
110957
627742e646c4
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110917
diff
changeset
|
526 (url-cache-extract (url-cache-create-filename (shr-encode-url url))) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
527 t) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
528 (when (or (search-forward "\n\n" nil t) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
529 (search-forward "\r\n\r\n" nil t)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
530 (buffer-substring (point) (point-max)))))) |
110708
4c31586ca1ca
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110704
diff
changeset
|
531 |
111577
db20adbc4108
gnus-art.el (gnus-inhibit-images): New user option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111556
diff
changeset
|
532 (defun shr-image-displayer (content-function) |
db20adbc4108
gnus-art.el (gnus-inhibit-images): New user option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111556
diff
changeset
|
533 "Return a function to display an image. |
db20adbc4108
gnus-art.el (gnus-inhibit-images): New user option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111556
diff
changeset
|
534 CONTENT-FUNCTION is a function to retrieve an image for a cid url that |
db20adbc4108
gnus-art.el (gnus-inhibit-images): New user option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111556
diff
changeset
|
535 is an argument. The function to be returned takes three arguments URL, |
111857
b8a431283d07
shr.el (shr-image-displayer): Work for images lined side by side.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111846
diff
changeset
|
536 START, and END. Note that START and END should be merkers." |
111577
db20adbc4108
gnus-art.el (gnus-inhibit-images): New user option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111556
diff
changeset
|
537 `(lambda (url start end) |
111578
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
538 (when url |
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
539 (if (string-match "\\`cid:" url) |
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
540 ,(when content-function |
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
541 `(let ((image (funcall ,content-function |
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
542 (substring url (match-end 0))))) |
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
543 (when image |
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
544 (goto-char start) |
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
545 (shr-put-image image |
111857
b8a431283d07
shr.el (shr-image-displayer): Work for images lined side by side.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111846
diff
changeset
|
546 (buffer-substring-no-properties start end)) |
b8a431283d07
shr.el (shr-image-displayer): Work for images lined side by side.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111846
diff
changeset
|
547 (delete-region (point) end)))) |
111578
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
548 (url-retrieve url 'shr-image-fetched |
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
549 (list (current-buffer) start end) |
312237f41f80
shr.el (shr-image-displayer): Protect function against non-existent image source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111577
diff
changeset
|
550 t))))) |
111577
db20adbc4108
gnus-art.el (gnus-inhibit-images): New user option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111556
diff
changeset
|
551 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
552 (defun shr-heading (cont &rest types) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
553 (shr-ensure-paragraph) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
554 (apply #'shr-fontize-cont cont types) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
555 (shr-ensure-paragraph)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
556 |
111285 | 557 (autoload 'widget-convert-button "wid-edit") |
558 | |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
559 (defun shr-urlify (start url &optional title) |
111138
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
560 (widget-convert-button |
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
561 'url-link start (point) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
562 :help-echo (if title (format "%s (%s)" url title) url) |
111138
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
563 :keymap shr-map |
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
564 url) |
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
565 (put-text-property start (point) 'shr-url url)) |
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
566 |
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
567 (defun shr-encode-url (url) |
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
568 "Encode URL." |
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
569 (browse-url-url-encode-chars url "[)$ ]")) |
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
570 |
111682
2c6350617cc3
shr.el (shr-color->hexadecimal): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
571 (autoload 'shr-color-visible "shr-color") |
2c6350617cc3
shr.el (shr-color->hexadecimal): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
572 (autoload 'shr-color->hexadecimal "shr-color") |
111705
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
573 |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
574 (defun shr-color-check (fg bg) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
575 "Check that FG is visible on BG. |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
576 Returns (fg bg) with corrected values. |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
577 Returns nil if the colors that would be used are the default |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
578 ones, in case fg and bg are nil." |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
579 (when (or fg bg) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
580 (let ((fixed (cond ((null fg) 'fg) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
581 ((null bg) 'bg)))) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
582 ;; Convert colors to hexadecimal, or set them to default. |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
583 (let ((fg (or (shr-color->hexadecimal fg) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
584 (frame-parameter nil 'foreground-color))) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
585 (bg (or (shr-color->hexadecimal bg) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
586 (frame-parameter nil 'background-color)))) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
587 (cond ((eq fixed 'bg) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
588 ;; Only return the new fg |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
589 (list nil (cadr (shr-color-visible bg fg t)))) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
590 ((eq fixed 'fg) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
591 ;; Invert args and results and return only the new bg |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
592 (list (cadr (shr-color-visible fg bg t)) nil)) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
593 (t |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
594 (shr-color-visible bg fg))))))) |
111682
2c6350617cc3
shr.el (shr-color->hexadecimal): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
595 |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
596 (defun shr-colorize-region (start end fg &optional bg) |
111838
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
597 (when (or fg bg) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
598 (let ((new-colors (shr-color-check fg bg))) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
599 (when new-colors |
111846
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
600 (when fg |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
601 (shr-put-color start end :foreground (cadr new-colors))) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
602 (when bg |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
603 (shr-put-color start end :background (car new-colors))))))) |
111705
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
604 |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
605 ;; Put a color in the region, but avoid putting colors on on blank |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
606 ;; text at the start of the line, and the newline at the end, to avoid |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
607 ;; ugliness. Also, don't overwrite any existing color information, |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
608 ;; since this can be called recursively, and we want the "inner" color |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
609 ;; to win. |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
610 (defun shr-put-color (start end type color) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
611 (save-excursion |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
612 (goto-char start) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
613 (while (< (point) end) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
614 (when (bolp) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
615 (skip-chars-forward " ")) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
616 (when (> (line-end-position) (point)) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
617 (shr-put-color-1 (point) (min (line-end-position) end) type color)) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
618 (if (< (line-end-position) end) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
619 (forward-line 1) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
620 (goto-char end))))) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
621 |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
622 (defun shr-put-color-1 (start end type color) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
623 (let* ((old-props (get-text-property start 'face)) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
624 (do-put (not (memq type old-props))) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
625 change) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
626 (while (< start end) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
627 (setq change (next-single-property-change start 'face nil end)) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
628 (when do-put |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
629 (put-text-property start change 'face |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
630 (nconc (list type color) old-props))) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
631 (setq old-props (get-text-property change 'face)) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
632 (setq do-put (not (memq type old-props))) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
633 (setq start change)) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
634 (when (and do-put |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
635 (> end start)) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
636 (put-text-property start end 'face |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
637 (nconc (list type color old-props)))))) |
111682
2c6350617cc3
shr.el (shr-color->hexadecimal): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111678
diff
changeset
|
638 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
639 ;;; Tag-specific rendering rules. |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
640 |
111705
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
641 (defun shr-tag-body (cont) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
642 (let* ((start (point)) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
643 (fgcolor (cdr (assq :fgcolor cont))) |
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
644 (bgcolor (cdr (assq :bgcolor cont))) |
111838
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
645 (shr-stylesheet (list (cons 'color fgcolor) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
646 (cons 'background-color bgcolor)))) |
111705
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
647 (shr-generic cont) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
648 (shr-colorize-region start (point) fgcolor bgcolor))) |
111705
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
649 |
111838
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
650 (defun shr-tag-style (cont) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
651 ) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
652 |
111858
56410560bc86
shr.el (shr-tag-script): Ignore <script>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111857
diff
changeset
|
653 (defun shr-tag-script (cont) |
56410560bc86
shr.el (shr-tag-script): Ignore <script>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111857
diff
changeset
|
654 ) |
56410560bc86
shr.el (shr-tag-script): Ignore <script>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111857
diff
changeset
|
655 |
111862
6476ce7872ae
shr.el (shr-tag-label): Add <label> support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111858
diff
changeset
|
656 (defun shr-tag-label (cont) |
6476ce7872ae
shr.el (shr-tag-label): Add <label> support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111858
diff
changeset
|
657 (shr-generic cont) |
6476ce7872ae
shr.el (shr-tag-label): Add <label> support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111858
diff
changeset
|
658 (shr-ensure-paragraph)) |
6476ce7872ae
shr.el (shr-tag-label): Add <label> support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111858
diff
changeset
|
659 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
660 (defun shr-tag-p (cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
661 (shr-ensure-paragraph) |
110898
069deed4cdec
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110873
diff
changeset
|
662 (shr-indent) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
663 (shr-generic cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
664 (shr-ensure-paragraph)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
665 |
111195
bad8d0e56e0f
shr.el (shr-tag-div): Added.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111138
diff
changeset
|
666 (defun shr-tag-div (cont) |
bad8d0e56e0f
shr.el (shr-tag-div): Added.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111138
diff
changeset
|
667 (shr-ensure-newline) |
bad8d0e56e0f
shr.el (shr-tag-div): Added.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111138
diff
changeset
|
668 (shr-indent) |
bad8d0e56e0f
shr.el (shr-tag-div): Added.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111138
diff
changeset
|
669 (shr-generic cont) |
bad8d0e56e0f
shr.el (shr-tag-div): Added.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111138
diff
changeset
|
670 (shr-ensure-newline)) |
bad8d0e56e0f
shr.el (shr-tag-div): Added.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111138
diff
changeset
|
671 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
672 (defun shr-tag-b (cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
673 (shr-fontize-cont cont 'bold)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
674 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
675 (defun shr-tag-i (cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
676 (shr-fontize-cont cont 'italic)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
677 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
678 (defun shr-tag-em (cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
679 (shr-fontize-cont cont 'bold)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
680 |
111129
2d713b285a70
gnus-group.el (gnus-group-completing-read): Remove all newlines from group names. They mess up the group buffer badly.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111096
diff
changeset
|
681 (defun shr-tag-strong (cont) |
2d713b285a70
gnus-group.el (gnus-group-completing-read): Remove all newlines from group names. They mess up the group buffer badly.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111096
diff
changeset
|
682 (shr-fontize-cont cont 'bold)) |
2d713b285a70
gnus-group.el (gnus-group-completing-read): Remove all newlines from group names. They mess up the group buffer badly.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111096
diff
changeset
|
683 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
684 (defun shr-tag-u (cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
685 (shr-fontize-cont cont 'underline)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
686 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
687 (defun shr-tag-s (cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
688 (shr-fontize-cont cont 'strike-through)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
689 |
111054
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
690 (defun shr-parse-style (style) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
691 (when style |
111683
01aefe45207c
shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111682
diff
changeset
|
692 (save-match-data |
01aefe45207c
shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111682
diff
changeset
|
693 (when (string-match "\n" style) |
01aefe45207c
shr-color.el: fix several function calls.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111682
diff
changeset
|
694 (setq style (replace-match " " t t style)))) |
111054
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
695 (let ((plist nil)) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
696 (dolist (elem (split-string style ";")) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
697 (when elem |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
698 (setq elem (split-string elem ":")) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
699 (when (and (car elem) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
700 (cadr elem)) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
701 (let ((name (replace-regexp-in-string "^ +\\| +$" "" (car elem))) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
702 (value (replace-regexp-in-string "^ +\\| +$" "" (cadr elem)))) |
111705
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
703 (when (string-match " *!important\\'" value) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
704 (setq value (substring value 0 (match-beginning 0)))) |
111054
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
705 (push (cons (intern name obarray) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
706 value) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
707 plist))))) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
708 plist))) |
779cd575396a
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111033
diff
changeset
|
709 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
710 (defun shr-tag-a (cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
711 (let ((url (cdr (assq :href cont))) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
712 (title (cdr (assq :title cont))) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
713 (start (point)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
714 shr-start) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
715 (shr-generic cont) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
716 (shr-urlify (or shr-start start) url title))) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
717 |
111138
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
718 (defun shr-tag-object (cont) |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
719 (let ((start (point)) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
720 url) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
721 (dolist (elem cont) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
722 (when (eq (car elem) 'embed) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
723 (setq url (or url (cdr (assq :src (cdr elem)))))) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
724 (when (and (eq (car elem) 'param) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
725 (equal (cdr (assq :name (cdr elem))) "movie")) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
726 (setq url (or url (cdr (assq :value (cdr elem))))))) |
111138
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
727 (when url |
11259a64bfc0
gnus-sum.el (gnus-summary-select-article): Make sure we have the original article buffer live.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111129
diff
changeset
|
728 (shr-insert " [multimedia] ") |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
729 (shr-urlify start url)) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
730 (shr-generic cont))) |
110957
627742e646c4
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110917
diff
changeset
|
731 |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
732 (defun shr-tag-video (cont) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
733 (let ((image (cdr (assq :poster cont))) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
734 (url (cdr (assq :src cont))) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
735 (start (point))) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
736 (shr-tag-img nil image) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
737 (shr-urlify start url))) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
738 |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
739 (defun shr-tag-img (cont &optional url) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
740 (when (or url |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
741 (and cont |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
742 (cdr (assq :src cont)))) |
111005
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
743 (when (and (> (current-column) 0) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
744 (not (eq shr-state 'image))) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
745 (insert "\n")) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
746 (let ((alt (cdr (assq :alt cont))) |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
747 (url (or url (cdr (assq :src cont))))) |
111005
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
748 (let ((start (point-marker))) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
749 (when (zerop (length alt)) |
111245
dd1304e89176
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111240
diff
changeset
|
750 (setq alt "*")) |
111005
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
751 (cond |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
752 ((or (member (cdr (assq :height cont)) '("0" "1")) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
753 (member (cdr (assq :width cont)) '("0" "1"))) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
754 ;; Ignore zero-sized or single-pixel images. |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
755 ) |
111005
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
756 ((and (not shr-inhibit-images) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
757 (string-match "\\`cid:" url)) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
758 (let ((url (substring url (match-end 0))) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
759 image) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
760 (if (or (not shr-content-function) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
761 (not (setq image (funcall shr-content-function url)))) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
762 (insert alt) |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
763 (shr-put-image image alt)))) |
111005
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
764 ((or shr-inhibit-images |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
765 (and shr-blocked-images |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
766 (string-match shr-blocked-images url))) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
767 (setq shr-start (point)) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
768 (let ((shr-state 'space)) |
111395
969fb8574065
shr.el (shr-tag-img): Use string-width and truncate-string-to-width to measure the length and truncate alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111300
diff
changeset
|
769 (if (> (string-width alt) 8) |
969fb8574065
shr.el (shr-tag-img): Use string-width and truncate-string-to-width to measure the length and truncate alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111300
diff
changeset
|
770 (shr-insert (truncate-string-to-width alt 8)) |
111005
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
771 (shr-insert alt)))) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
772 ((url-is-cached (shr-encode-url url)) |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
773 (shr-put-image (shr-get-image-data url) alt)) |
111005
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
774 (t |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
775 (insert alt) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
776 (ignore-errors |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
777 (url-retrieve (shr-encode-url url) 'shr-image-fetched |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
778 (list (current-buffer) start (point-marker)) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
779 t)))) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
780 (put-text-property start (point) 'keymap shr-map) |
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
781 (put-text-property start (point) 'shr-alt alt) |
111556
ee13ba492319
Rework how Gnus is supposed to be able to display all the images in HTML.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111490
diff
changeset
|
782 (put-text-property start (point) 'image-url url) |
ee13ba492319
Rework how Gnus is supposed to be able to display all the images in HTML.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111490
diff
changeset
|
783 (put-text-property start (point) 'image-displayer |
111577
db20adbc4108
gnus-art.el (gnus-inhibit-images): New user option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111556
diff
changeset
|
784 (shr-image-displayer shr-content-function)) |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
785 (put-text-property start (point) 'help-echo alt) |
111005
e172bc1db402
shr.el (shr-tag-img): Ignore images with no data.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111002
diff
changeset
|
786 (setq shr-state 'image))))) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
787 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
788 (defun shr-tag-pre (cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
789 (let ((shr-folding-mode 'none)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
790 (shr-ensure-newline) |
110898
069deed4cdec
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110873
diff
changeset
|
791 (shr-indent) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
792 (shr-generic cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
793 (shr-ensure-newline))) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
794 |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
795 (defun shr-tag-blockquote (cont) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
796 (shr-ensure-paragraph) |
110898
069deed4cdec
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110873
diff
changeset
|
797 (shr-indent) |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
798 (let ((shr-indentation (+ shr-indentation 4))) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
799 (shr-generic cont)) |
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
800 (shr-ensure-paragraph)) |
110747
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
801 |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
802 (defun shr-tag-ul (cont) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
803 (shr-ensure-paragraph) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
804 (let ((shr-list-mode 'ul)) |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
805 (shr-generic cont)) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
806 (shr-ensure-paragraph)) |
110747
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
807 |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
808 (defun shr-tag-ol (cont) |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
809 (shr-ensure-paragraph) |
110747
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
810 (let ((shr-list-mode 1)) |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
811 (shr-generic cont)) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
812 (shr-ensure-paragraph)) |
110747
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
813 |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
814 (defun shr-tag-li (cont) |
110898
069deed4cdec
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110873
diff
changeset
|
815 (shr-ensure-paragraph) |
069deed4cdec
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110873
diff
changeset
|
816 (shr-indent) |
110757
d3001fd75795
shr.el (shr-tag-li): Get <li> indentation right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110756
diff
changeset
|
817 (let* ((bullet |
d3001fd75795
shr.el (shr-tag-li): Get <li> indentation right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110756
diff
changeset
|
818 (if (numberp shr-list-mode) |
d3001fd75795
shr.el (shr-tag-li): Get <li> indentation right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110756
diff
changeset
|
819 (prog1 |
d3001fd75795
shr.el (shr-tag-li): Get <li> indentation right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110756
diff
changeset
|
820 (format "%d " shr-list-mode) |
d3001fd75795
shr.el (shr-tag-li): Get <li> indentation right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110756
diff
changeset
|
821 (setq shr-list-mode (1+ shr-list-mode))) |
d3001fd75795
shr.el (shr-tag-li): Get <li> indentation right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110756
diff
changeset
|
822 "* ")) |
d3001fd75795
shr.el (shr-tag-li): Get <li> indentation right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110756
diff
changeset
|
823 (shr-indentation (+ shr-indentation (length bullet)))) |
d3001fd75795
shr.el (shr-tag-li): Get <li> indentation right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110756
diff
changeset
|
824 (insert bullet) |
d3001fd75795
shr.el (shr-tag-li): Get <li> indentation right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110756
diff
changeset
|
825 (shr-generic cont))) |
110747
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
826 |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
827 (defun shr-tag-br (cont) |
110756
9070b77b4a28
shr.el (shr-insert): Tweak line breaking.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110755
diff
changeset
|
828 (unless (bobp) |
110898
069deed4cdec
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110873
diff
changeset
|
829 (insert "\n") |
069deed4cdec
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110873
diff
changeset
|
830 (shr-indent)) |
110747
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
831 (shr-generic cont)) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
832 |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
833 (defun shr-tag-h1 (cont) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
834 (shr-heading cont 'bold 'underline)) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
835 |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
836 (defun shr-tag-h2 (cont) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
837 (shr-heading cont 'bold)) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
838 |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
839 (defun shr-tag-h3 (cont) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
840 (shr-heading cont 'italic)) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
841 |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
842 (defun shr-tag-h4 (cont) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
843 (shr-heading cont)) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
844 |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
845 (defun shr-tag-h5 (cont) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
846 (shr-heading cont)) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
847 |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
848 (defun shr-tag-h6 (cont) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
849 (shr-heading cont)) |
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
850 |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
851 (defun shr-tag-hr (cont) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
852 (shr-ensure-newline) |
110917
3243e7055d49
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110898
diff
changeset
|
853 (insert (make-string shr-width shr-hr-line) "\n")) |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
854 |
111705
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
855 (defun shr-tag-title (cont) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
856 (shr-heading cont 'bold 'underline)) |
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
857 |
111694
bef4f575201b
shr.el (shr-tag-font): Resurrect shr-tag-font again, since it's needed to parse <font color="red"> entries.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111693
diff
changeset
|
858 (defun shr-tag-font (cont) |
111838
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
859 (let* ((start (point)) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
860 (color (cdr (assq :color cont))) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
861 (shr-stylesheet (nconc (list (cons 'color color)) |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
862 shr-stylesheet))) |
111694
bef4f575201b
shr.el (shr-tag-font): Resurrect shr-tag-font again, since it's needed to parse <font color="red"> entries.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111693
diff
changeset
|
863 (shr-generic cont) |
111838
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
864 (when color |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
865 (shr-colorize-region start (point) color |
de6f9af48bfa
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111832
diff
changeset
|
866 (cdr (assq 'background-color shr-stylesheet)))))) |
111694
bef4f575201b
shr.el (shr-tag-font): Resurrect shr-tag-font again, since it's needed to parse <font color="red"> entries.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111693
diff
changeset
|
867 |
110790
1f25b03df4ad
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110778
diff
changeset
|
868 ;;; Table rendering algorithm. |
110747
0defef1647a5
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110740
diff
changeset
|
869 |
110778
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
870 ;; Table rendering is the only complicated thing here. We do this by |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
871 ;; first counting how many TDs there are in each TR, and registering |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
872 ;; how wide they think they should be ("width=45%", etc). Then we |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
873 ;; render each TD separately (this is done in temporary buffers, so |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
874 ;; that we can use all the rendering machinery as if we were in the |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
875 ;; main buffer). Now we know how much space each TD really takes, so |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
876 ;; we then render everything again with the new widths, and finally |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
877 ;; insert all these boxes into the main buffer. |
111063
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
878 (defun shr-tag-table-1 (cont) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
879 (setq cont (or (cdr (assq 'tbody cont)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
880 cont)) |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
881 (let* ((shr-inhibit-images t) |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
882 (shr-table-depth (1+ shr-table-depth)) |
111032
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
883 (shr-kinsoku-shorten t) |
110778
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
884 ;; Find all suggested widths. |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
885 (columns (shr-column-specs cont)) |
110778
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
886 ;; Compute how many characters wide each TD should be. |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
887 (suggested-widths (shr-pro-rate-columns columns)) |
110778
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
888 ;; Do a "test rendering" to see how big each TD is (this can |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
889 ;; be smaller (if there's little text) or bigger (if there's |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
890 ;; unbreakable text). |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
891 (sketch (shr-make-table cont suggested-widths)) |
110804
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
892 (sketch-widths (shr-table-widths sketch suggested-widths))) |
110999
9330a5183ae6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110996
diff
changeset
|
893 ;; This probably won't work very well. |
111032
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
894 (when (> (+ (loop for width across sketch-widths |
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
895 summing (1+ width)) |
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
896 shr-indentation 1) |
110999
9330a5183ae6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110996
diff
changeset
|
897 (frame-width)) |
9330a5183ae6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110996
diff
changeset
|
898 (setq truncate-lines t)) |
110778
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
899 ;; Then render the table again with these new "hard" widths. |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
900 (shr-insert-table (shr-make-table cont sketch-widths t) sketch-widths)) |
110778
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
901 ;; Finally, insert all the images after the table. The Emacs buffer |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
902 ;; model isn't strong enough to allow us to put the images actually |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
903 ;; into the tables. |
111240
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
904 (when (zerop shr-table-depth) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
905 (dolist (elem (shr-find-elements cont 'img)) |
ffb890b32d37
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111218
diff
changeset
|
906 (shr-tag-img (cdr elem))))) |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
907 |
111063
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
908 (defun shr-tag-table (cont) |
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
909 (shr-ensure-paragraph) |
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
910 (let* ((caption (cdr (assq 'caption cont))) |
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
911 (header (cdr (assq 'thead cont))) |
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
912 (body (or (cdr (assq 'tbody cont)) cont)) |
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
913 (footer (cdr (assq 'tfoot cont))) |
111705
cad125981c0f
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111701
diff
changeset
|
914 (bgcolor (cdr (assq :bgcolor cont))) |
111846
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
915 (start (point)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
916 (shr-stylesheet (nconc (list (cons 'background-color bgcolor)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
917 shr-stylesheet)) |
111063
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
918 (nheader (if header (shr-max-columns header))) |
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
919 (nbody (if body (shr-max-columns body))) |
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
920 (nfooter (if footer (shr-max-columns footer)))) |
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
921 (shr-tag-table-1 |
111078
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
922 (nconc |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
923 (if caption `((tr (td ,@caption)))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
924 (if header |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
925 (if footer |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
926 ;; hader + body + footer |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
927 (if (= nheader nbody) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
928 (if (= nbody nfooter) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
929 `((tr (td (table (tbody ,@header ,@body ,@footer))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
930 (nconc `((tr (td (table (tbody ,@header ,@body))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
931 (if (= nfooter 1) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
932 footer |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
933 `((tr (td (table (tbody ,@footer)))))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
934 (nconc `((tr (td (table (tbody ,@header))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
935 (if (= nbody nfooter) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
936 `((tr (td (table (tbody ,@body ,@footer))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
937 (nconc `((tr (td (table (tbody ,@body))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
938 (if (= nfooter 1) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
939 footer |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
940 `((tr (td (table (tbody ,@footer)))))))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
941 ;; header + body |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
942 (if (= nheader nbody) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
943 `((tr (td (table (tbody ,@header ,@body))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
944 (if (= nheader 1) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
945 `(,@header (tr (td (table (tbody ,@body))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
946 `((tr (td (table (tbody ,@header)))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
947 (tr (td (table (tbody ,@body)))))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
948 (if footer |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
949 ;; body + footer |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
950 (if (= nbody nfooter) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
951 `((tr (td (table (tbody ,@body ,@footer))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
952 (nconc `((tr (td (table (tbody ,@body))))) |
111067
e36c65ac23bf
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111066
diff
changeset
|
953 (if (= nfooter 1) |
111078
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
954 footer |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
955 `((tr (td (table (tbody ,@footer)))))))) |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
956 (if caption |
647c0a15da32
shr.el (shr-tag-table): Simplify.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111072
diff
changeset
|
957 `((tr (td (table (tbody ,@body))))) |
111846
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
958 body))))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
959 (when bgcolor |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
960 (shr-colorize-region start (point) (cdr (assq 'color shr-stylesheet)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
961 bgcolor)))) |
111063
4430b518c7c5
shr.el: (shr-tag-table): Support caption, thead, and tfoot.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111059
diff
changeset
|
962 |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
963 (defun shr-find-elements (cont type) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
964 (let (result) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
965 (dolist (elem cont) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
966 (cond ((eq (car elem) type) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
967 (push elem result)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
968 ((consp (cdr elem)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
969 (setq result (nconc (shr-find-elements (cdr elem) type) result))))) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
970 (nreverse result))) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
971 |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
972 (defun shr-insert-table (table widths) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
973 (shr-insert-table-ruler widths) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
974 (dolist (row table) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
975 (let ((start (point)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
976 (height (let ((max 0)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
977 (dolist (column row) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
978 (setq max (max max (cadr column)))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
979 max))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
980 (dotimes (i height) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
981 (shr-indent) |
111627
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
982 (insert shr-table-vertical-line "\n")) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
983 (dolist (column row) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
984 (goto-char start) |
110804
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
985 (let ((lines (nth 2 column)) |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
986 (overlay-lines (nth 3 column)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
987 overlay overlay-line) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
988 (dolist (line lines) |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
989 (setq overlay-line (pop overlay-lines)) |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
990 (end-of-line) |
111627
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
991 (insert line shr-table-vertical-line) |
110810
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
992 (dolist (overlay overlay-line) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
993 (let ((o (make-overlay (- (point) (nth 0 overlay) 1) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
994 (- (point) (nth 1 overlay) 1))) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
995 (properties (nth 2 overlay))) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
996 (while properties |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
997 (overlay-put o (pop properties) (pop properties))))) |
07053df95af6
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110804
diff
changeset
|
998 (forward-line 1)) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
999 ;; Add blank lines at padding at the bottom of the TD, |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1000 ;; possibly. |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1001 (dotimes (i (- height (length lines))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1002 (end-of-line) |
111627
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
1003 (insert (make-string (string-width (car lines)) ? ) |
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
1004 shr-table-vertical-line) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1005 (forward-line 1))))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1006 (shr-insert-table-ruler widths))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1007 |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1008 (defun shr-insert-table-ruler (widths) |
111032
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
1009 (when (and (bolp) |
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
1010 (> shr-indentation 0)) |
1ed05f12a0bc
shr.el: Improve kinsoku and table rendering.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111022
diff
changeset
|
1011 (shr-indent)) |
110873
d98a67277730
shr,el: Allow shr table char to be customized.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110859
diff
changeset
|
1012 (insert shr-table-corner) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1013 (dotimes (i (length widths)) |
111627
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
1014 (insert (make-string (aref widths i) shr-table-horizontal-line) |
f61ceeffc5da
shr.el: Allow customizing the vertical table lines.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111584
diff
changeset
|
1015 shr-table-corner)) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1016 (insert "\n")) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1017 |
110804
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1018 (defun shr-table-widths (table suggested-widths) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1019 (let* ((length (length suggested-widths)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1020 (widths (make-vector length 0)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1021 (natural-widths (make-vector length 0))) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1022 (dolist (row table) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1023 (let ((i 0)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1024 (dolist (column row) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1025 (aset widths i (max (aref widths i) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1026 (car column))) |
110804
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1027 (aset natural-widths i (max (aref natural-widths i) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1028 (cadr column))) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1029 (setq i (1+ i))))) |
110812
3d3d15223058
shr.el (shr-table-widths): Don't use cl function `reduce'.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110810
diff
changeset
|
1030 (let ((extra (- (apply '+ (append suggested-widths nil)) |
3d3d15223058
shr.el (shr-table-widths): Don't use cl function `reduce'.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110810
diff
changeset
|
1031 (apply '+ (append widths nil)))) |
110804
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1032 (expanded-columns 0)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1033 (when (> extra 0) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1034 (dotimes (i length) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1035 ;; If the natural width is wider than the rendered width, we |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1036 ;; want to allow the column to expand. |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1037 (when (> (aref natural-widths i) (aref widths i)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1038 (setq expanded-columns (1+ expanded-columns)))) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1039 (dotimes (i length) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1040 (when (> (aref natural-widths i) (aref widths i)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1041 (aset widths i (min |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1042 (1+ (aref natural-widths i)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1043 (+ (/ extra expanded-columns) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1044 (aref widths i)))))))) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1045 widths)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1046 |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1047 (defun shr-make-table (cont widths &optional fill) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1048 (let ((trs nil)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1049 (dolist (row cont) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1050 (when (eq (car row) 'tr) |
110778
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
1051 (let ((tds nil) |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
1052 (columns (cdr row)) |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
1053 (i 0) |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
1054 column) |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
1055 (while (< i (length widths)) |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
1056 (setq column (pop columns)) |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
1057 (when (or (memq (car column) '(td th)) |
5a595f515d1c
shr.el (shr-render-td): Allow blank/missing <TD>s.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110777
diff
changeset
|
1058 (null column)) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1059 (push (shr-render-td (cdr column) (aref widths i) fill) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1060 tds) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1061 (setq i (1+ i)))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1062 (push (nreverse tds) trs)))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1063 (nreverse trs))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1064 |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1065 (defun shr-render-td (cont width fill) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
1066 (with-temp-buffer |
111846
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1067 (let ((bgcolor (cdr (assq :bgcolor cont))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1068 (fgcolor (cdr (assq :fgcolor cont))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1069 (style (cdr (assq :style cont))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1070 (shr-stylesheet shr-stylesheet) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1071 overlays) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1072 (when style |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1073 (setq style (and (string-match "color" style) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1074 (shr-parse-style style)))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1075 (when bgcolor |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1076 (setq style (nconc (list (cons 'background-color bgcolor)) style))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1077 (when fgcolor |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1078 (setq style (nconc (list (cons 'color fgcolor)) style))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1079 (when style |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1080 (setq shr-stylesheet (append style shr-stylesheet))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1081 (let ((cache (cdr (assoc (cons width cont) shr-content-cache)))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1082 (if cache |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1083 (progn |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1084 (insert (car cache)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1085 (let ((end (length (car cache)))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1086 (dolist (overlay (cadr cache)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1087 (let ((new-overlay |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1088 (make-overlay (1+ (- end (nth 0 overlay))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1089 (1+ (- end (nth 1 overlay))))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1090 (properties (nth 2 overlay))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1091 (while properties |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1092 (overlay-put new-overlay |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1093 (pop properties) (pop properties))))))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1094 (let ((shr-width width) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1095 (shr-indentation 0)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1096 (shr-descend (cons 'td cont))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1097 (delete-region |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1098 (point) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1099 (+ (point) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1100 (skip-chars-backward " \t\n"))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1101 (push (list (cons width cont) (buffer-string) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1102 (shr-overlays-in-region (point-min) (point-max))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1103 shr-content-cache))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1104 (goto-char (point-min)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1105 (let ((max 0)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1106 (while (not (eobp)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1107 (end-of-line) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1108 (setq max (max max (current-column))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1109 (forward-line 1)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1110 (when fill |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1111 (goto-char (point-min)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1112 ;; If the buffer is totally empty, then put a single blank |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1113 ;; line here. |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1114 (if (zerop (buffer-size)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1115 (insert (make-string width ? )) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1116 ;; Otherwise, fill the buffer. |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1117 (while (not (eobp)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1118 (end-of-line) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1119 (when (> (- width (current-column)) 0) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1120 (insert (make-string (- width (current-column)) ? ))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1121 (forward-line 1)))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1122 (when style |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1123 (shr-colorize-region |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1124 (point-min) (point-max) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1125 (cdr (assq 'color shr-stylesheet)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1126 (cdr (assq 'background-color shr-stylesheet)))) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1127 (if fill |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1128 (list max |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1129 (count-lines (point-min) (point-max)) |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1130 (split-string (buffer-string) "\n") |
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1131 (shr-collect-overlays)) |
111830
79219ca01c7b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111789
diff
changeset
|
1132 (list max |
111846
076a5b56d8c9
shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111840
diff
changeset
|
1133 (shr-natural-width))))))) |
110804
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1134 |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1135 (defun shr-natural-width () |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1136 (goto-char (point-min)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1137 (let ((current 0) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1138 (max 0)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1139 (while (not (eobp)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1140 (end-of-line) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1141 (setq current (+ current (current-column))) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1142 (unless (get-text-property (point) 'shr-break) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1143 (setq max (max max current) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1144 current 0)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1145 (forward-line 1)) |
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1146 max)) |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1147 |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1148 (defun shr-collect-overlays () |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1149 (save-excursion |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1150 (goto-char (point-min)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1151 (let ((overlays nil)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1152 (while (not (eobp)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1153 (push (shr-overlays-in-region (point) (line-end-position)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1154 overlays) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1155 (forward-line 1)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1156 (nreverse overlays)))) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1157 |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1158 (defun shr-overlays-in-region (start end) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1159 (let (result) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1160 (dolist (overlay (overlays-in start end)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1161 (push (list (if (> start (overlay-start overlay)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1162 (- end start) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1163 (- end (overlay-start overlay))) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1164 (if (< end (overlay-end overlay)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1165 0 |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1166 (- end (overlay-end overlay))) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1167 (overlay-properties overlay)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1168 result)) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1169 (nreverse result))) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1170 |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1171 (defun shr-pro-rate-columns (columns) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1172 (let ((total-percentage 0) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1173 (widths (make-vector (length columns) 0))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1174 (dotimes (i (length columns)) |
110804
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1175 (setq total-percentage (+ total-percentage (aref columns i)))) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1176 (setq total-percentage (/ 1.0 total-percentage)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1177 (dotimes (i (length columns)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1178 (aset widths i (max (truncate (* (aref columns i) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1179 total-percentage |
110804
30fed27e97bc
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110792
diff
changeset
|
1180 (- shr-width (1+ (length columns))))) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1181 10))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1182 widths)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1183 |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1184 ;; Return a summary of the number and shape of the TDs in the table. |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1185 (defun shr-column-specs (cont) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1186 (let ((columns (make-vector (shr-max-columns cont) 1))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1187 (dolist (row cont) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1188 (when (eq (car row) 'tr) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1189 (let ((i 0)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1190 (dolist (column (cdr row)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1191 (when (memq (car column) '(td th)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1192 (let ((width (cdr (assq :width (cdr column))))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1193 (when (and width |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1194 (string-match "\\([0-9]+\\)%" width)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1195 (aset columns i |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1196 (/ (string-to-number (match-string 1 width)) |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1197 100.0)))) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1198 (setq i (1+ i))))))) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1199 columns)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1200 |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1201 (defun shr-count (cont elem) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1202 (let ((i 0)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1203 (dolist (sub cont) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1204 (when (eq (car sub) elem) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1205 (setq i (1+ i)))) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1206 i)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1207 |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1208 (defun shr-max-columns (cont) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1209 (let ((max 0)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1210 (dolist (row cont) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1211 (when (eq (car row) 'tr) |
110777
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1212 (setq max (max max (+ (shr-count (cdr row) 'td) |
895607aec71e
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
1213 (shr-count (cdr row) 'th)))))) |
110763
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1214 max)) |
0fe64d68a522
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110757
diff
changeset
|
1215 |
110704
016990bf37ad
lisp/gnus/shr.el (shr): Fix typo in provide call.
Juanma Barranquero <lekktu@gmail.com>
parents:
110698
diff
changeset
|
1216 (provide 'shr) |
110698
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
1217 |
74bad2d7bddd
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
1218 ;;; shr.el ends here |