aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGnus developers2010-11-23 22:24:15 +0000
committerKatsumi Yamaoka2010-11-23 22:24:15 +0000
commit094ae2abf32ae1bab203c181d42a777c773d65bc (patch)
treec31c9a6645b55766537888ceab8ee6b618f4d2c5
parentf8ab8c1f816bac2eebb86581bc50cd1434effe50 (diff)
downloademacs-094ae2abf32ae1bab203c181d42a777c773d65bc.tar.gz
emacs-094ae2abf32ae1bab203c181d42a777c773d65bc.zip
Merge changes made in Gnus trunk.
nnheader.el (nnheader-parse-head): Bug fix. Properly position point when parsing headers. nnspool.el (nnspool-insert-nov-head): Bug fix. Make sure point is positioned properly when parsing headers. shr-color.el (shr-color->hexadecimal): Add support for color names. color-lab.el (boundp): Bind float-pi for Emacs < 23.3. shr.el (shr-insert-color-overlay): Split stuff like "#444444 !important" to find the real colour.
-rw-r--r--lisp/gnus/ChangeLog17
-rw-r--r--lisp/gnus/color-lab.el4
-rw-r--r--lisp/gnus/nnheader.el4
-rw-r--r--lisp/gnus/nnspool.el15
-rw-r--r--lisp/gnus/shr-color.el211
-rw-r--r--lisp/gnus/shr.el2
6 files changed, 219 insertions, 34 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index b501b5ec55c..3717191ba32 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,5 +1,22 @@
12010-11-23 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * shr.el (shr-insert-color-overlay): Split stuff like
4 "#444444 !important" to find the real colour.
5
62010-11-23 Andrew Cohen <cohen@andy.bu.edu>
7
8 * nnheader.el (nnheader-parse-head): Bug fix. Properly position
9 point when parsing headers.
10
11 * nnspool.el (nnspool-insert-nov-head): Bug fix. Make sure point
12 is positioned properly when parsing headers.
13
12010-11-23 Julien Danjou <julien@danjou.info> 142010-11-23 Julien Danjou <julien@danjou.info>
2 15
16 * color-lab.el (boundp): Bind float-pi for Emacs < 23.3.
17
18 * shr-color.el (shr-color->hexadecimal): Add support for color names.
19
3 * shr.el (shr-parse-style): Replace \n with space in style parsing. 20 * shr.el (shr-parse-style): Replace \n with space in style parsing.
4 21
5 * shr-color.el (shr-color-hsl-to-rgb-fractions): Use shr-color-hue-to-rgb. 22 * shr-color.el (shr-color-hsl-to-rgb-fractions): Use shr-color-hue-to-rgb.
diff --git a/lisp/gnus/color-lab.el b/lisp/gnus/color-lab.el
index 997bdbfc145..16f711a3c9a 100644
--- a/lisp/gnus/color-lab.el
+++ b/lisp/gnus/color-lab.el
@@ -26,6 +26,10 @@
26 26
27;;; Code: 27;;; Code:
28 28
29;; Emacs < 23.3
30(unless (boundp 'float-pi)
31 (defconst float-pi (* 4 (atan 1)) "The value of Pi (3.1415926...)."))
32
29(defun rgb->hsv (red green blue) 33(defun rgb->hsv (red green blue)
30 "Convert RED GREEN BLUE values to HSV representation. 34 "Convert RED GREEN BLUE values to HSV representation.
31Hue is in radian. Saturation and values are between 0 and 1." 35Hue is in radian. Saturation and values are between 0 and 1."
diff --git a/lisp/gnus/nnheader.el b/lisp/gnus/nnheader.el
index 4bf4588687e..08dc96d945b 100644
--- a/lisp/gnus/nnheader.el
+++ b/lisp/gnus/nnheader.el
@@ -366,15 +366,13 @@ on your system, you could say something like:
366 (setq num 0 366 (setq num 0
367 beg (point-min) 367 beg (point-min)
368 end (point-max)) 368 end (point-max))
369 (goto-char (point-min))
370 ;; Search to the beginning of the next header. Error 369 ;; Search to the beginning of the next header. Error
371 ;; messages do not begin with 2 or 3. 370 ;; messages do not begin with 2 or 3.
372 (when (re-search-forward "^[23][0-9]+ " nil t) 371 (when (re-search-forward "^[23][0-9]+ " nil t)
373 (end-of-line)
374 (setq num (read cur) 372 (setq num (read cur)
375 beg (point) 373 beg (point)
376 end (if (search-forward "\n.\n" nil t) 374 end (if (search-forward "\n.\n" nil t)
377 (- (point) 2) 375 (goto-char (- (point) 2))
378 (point))))) 376 (point)))))
379 (with-temp-buffer 377 (with-temp-buffer
380 (insert-buffer-substring cur beg end) 378 (insert-buffer-substring cur beg end)
diff --git a/lisp/gnus/nnspool.el b/lisp/gnus/nnspool.el
index 35987277b3d..1916c1ac9ad 100644
--- a/lisp/gnus/nnspool.el
+++ b/lisp/gnus/nnspool.el
@@ -399,15 +399,16 @@ there.")
399 "Read the head of ARTICLE, convert to NOV headers, and insert." 399 "Read the head of ARTICLE, convert to NOV headers, and insert."
400 (save-excursion 400 (save-excursion
401 (let ((cur (current-buffer)) 401 (let ((cur (current-buffer))
402 buf) 402 buf)
403 (setq buf (nnheader-set-temp-buffer " *nnspool head*")) 403 (setq buf (nnheader-set-temp-buffer " *nnspool head*"))
404 (when (nnheader-insert-head 404 (when (nnheader-insert-head
405 (nnspool-article-pathname nnspool-current-group article)) 405 (nnspool-article-pathname nnspool-current-group article))
406 (nnheader-insert-article-line article) 406 (nnheader-insert-article-line article)
407 (let ((headers (nnheader-parse-head))) 407 (goto-char (point-min))
408 (set-buffer cur) 408 (let ((headers (nnheader-parse-head)))
409 (goto-char (point-max)) 409 (set-buffer cur)
410 (nnheader-insert-nov headers))) 410 (goto-char (point-max))
411 (nnheader-insert-nov headers)))
411 (kill-buffer buf)))) 412 (kill-buffer buf))))
412 413
413(defun nnspool-sift-nov-with-sed (articles file) 414(defun nnspool-sift-nov-with-sed (articles file)
diff --git a/lisp/gnus/shr-color.el b/lisp/gnus/shr-color.el
index 5a9aff9416d..d611609e39c 100644
--- a/lisp/gnus/shr-color.el
+++ b/lisp/gnus/shr-color.el
@@ -45,6 +45,157 @@ absolute value without any unit."
45 :group 'shr 45 :group 'shr
46 :type 'integer) 46 :type 'integer)
47 47
48(defconst shr-color-html-colors-alist
49 '(("AliceBlue" . "#F0F8FF")
50 ("AntiqueWhite" . "#FAEBD7")
51 ("Aqua" . "#00FFFF")
52 ("Aquamarine" . "#7FFFD4")
53 ("Azure" . "#F0FFFF")
54 ("Beige" . "#F5F5DC")
55 ("Bisque" . "#FFE4C4")
56 ("Black" . "#000000")
57 ("BlanchedAlmond" . "#FFEBCD")
58 ("Blue" . "#0000FF")
59 ("BlueViolet" . "#8A2BE2")
60 ("Brown" . "#A52A2A")
61 ("BurlyWood" . "#DEB887")
62 ("CadetBlue" . "#5F9EA0")
63 ("Chartreuse" . "#7FFF00")
64 ("Chocolate" . "#D2691E")
65 ("Coral" . "#FF7F50")
66 ("CornflowerBlue" . "#6495ED")
67 ("Cornsilk" . "#FFF8DC")
68 ("Crimson" . "#DC143C")
69 ("Cyan" . "#00FFFF")
70 ("DarkBlue" . "#00008B")
71 ("DarkCyan" . "#008B8B")
72 ("DarkGoldenRod" . "#B8860B")
73 ("DarkGray" . "#A9A9A9")
74 ("DarkGrey" . "#A9A9A9")
75 ("DarkGreen" . "#006400")
76 ("DarkKhaki" . "#BDB76B")
77 ("DarkMagenta" . "#8B008B")
78 ("DarkOliveGreen" . "#556B2F")
79 ("Darkorange" . "#FF8C00")
80 ("DarkOrchid" . "#9932CC")
81 ("DarkRed" . "#8B0000")
82 ("DarkSalmon" . "#E9967A")
83 ("DarkSeaGreen" . "#8FBC8F")
84 ("DarkSlateBlue" . "#483D8B")
85 ("DarkSlateGray" . "#2F4F4F")
86 ("DarkSlateGrey" . "#2F4F4F")
87 ("DarkTurquoise" . "#00CED1")
88 ("DarkViolet" . "#9400D3")
89 ("DeepPink" . "#FF1493")
90 ("DeepSkyBlue" . "#00BFFF")
91 ("DimGray" . "#696969")
92 ("DimGrey" . "#696969")
93 ("DodgerBlue" . "#1E90FF")
94 ("FireBrick" . "#B22222")
95 ("FloralWhite" . "#FFFAF0")
96 ("ForestGreen" . "#228B22")
97 ("Fuchsia" . "#FF00FF")
98 ("Gainsboro" . "#DCDCDC")
99 ("GhostWhite" . "#F8F8FF")
100 ("Gold" . "#FFD700")
101 ("GoldenRod" . "#DAA520")
102 ("Gray" . "#808080")
103 ("Grey" . "#808080")
104 ("Green" . "#008000")
105 ("GreenYellow" . "#ADFF2F")
106 ("HoneyDew" . "#F0FFF0")
107 ("HotPink" . "#FF69B4")
108 ("IndianRed" . "#CD5C5C")
109 ("Indigo" . "#4B0082")
110 ("Ivory" . "#FFFFF0")
111 ("Khaki" . "#F0E68C")
112 ("Lavender" . "#E6E6FA")
113 ("LavenderBlush" . "#FFF0F5")
114 ("LawnGreen" . "#7CFC00")
115 ("LemonChiffon" . "#FFFACD")
116 ("LightBlue" . "#ADD8E6")
117 ("LightCoral" . "#F08080")
118 ("LightCyan" . "#E0FFFF")
119 ("LightGoldenRodYellow" . "#FAFAD2")
120 ("LightGray" . "#D3D3D3")
121 ("LightGrey" . "#D3D3D3")
122 ("LightGreen" . "#90EE90")
123 ("LightPink" . "#FFB6C1")
124 ("LightSalmon" . "#FFA07A")
125 ("LightSeaGreen" . "#20B2AA")
126 ("LightSkyBlue" . "#87CEFA")
127 ("LightSlateGray" . "#778899")
128 ("LightSlateGrey" . "#778899")
129 ("LightSteelBlue" . "#B0C4DE")
130 ("LightYellow" . "#FFFFE0")
131 ("Lime" . "#00FF00")
132 ("LimeGreen" . "#32CD32")
133 ("Linen" . "#FAF0E6")
134 ("Magenta" . "#FF00FF")
135 ("Maroon" . "#800000")
136 ("MediumAquaMarine" . "#66CDAA")
137 ("MediumBlue" . "#0000CD")
138 ("MediumOrchid" . "#BA55D3")
139 ("MediumPurple" . "#9370D8")
140 ("MediumSeaGreen" . "#3CB371")
141 ("MediumSlateBlue" . "#7B68EE")
142 ("MediumSpringGreen" . "#00FA9A")
143 ("MediumTurquoise" . "#48D1CC")
144 ("MediumVioletRed" . "#C71585")
145 ("MidnightBlue" . "#191970")
146 ("MintCream" . "#F5FFFA")
147 ("MistyRose" . "#FFE4E1")
148 ("Moccasin" . "#FFE4B5")
149 ("NavajoWhite" . "#FFDEAD")
150 ("Navy" . "#000080")
151 ("OldLace" . "#FDF5E6")
152 ("Olive" . "#808000")
153 ("OliveDrab" . "#6B8E23")
154 ("Orange" . "#FFA500")
155 ("OrangeRed" . "#FF4500")
156 ("Orchid" . "#DA70D6")
157 ("PaleGoldenRod" . "#EEE8AA")
158 ("PaleGreen" . "#98FB98")
159 ("PaleTurquoise" . "#AFEEEE")
160 ("PaleVioletRed" . "#D87093")
161 ("PapayaWhip" . "#FFEFD5")
162 ("PeachPuff" . "#FFDAB9")
163 ("Peru" . "#CD853F")
164 ("Pink" . "#FFC0CB")
165 ("Plum" . "#DDA0DD")
166 ("PowderBlue" . "#B0E0E6")
167 ("Purple" . "#800080")
168 ("Red" . "#FF0000")
169 ("RosyBrown" . "#BC8F8F")
170 ("RoyalBlue" . "#4169E1")
171 ("SaddleBrown" . "#8B4513")
172 ("Salmon" . "#FA8072")
173 ("SandyBrown" . "#F4A460")
174 ("SeaGreen" . "#2E8B57")
175 ("SeaShell" . "#FFF5EE")
176 ("Sienna" . "#A0522D")
177 ("Silver" . "#C0C0C0")
178 ("SkyBlue" . "#87CEEB")
179 ("SlateBlue" . "#6A5ACD")
180 ("SlateGray" . "#708090")
181 ("SlateGrey" . "#708090")
182 ("Snow" . "#FFFAFA")
183 ("SpringGreen" . "#00FF7F")
184 ("SteelBlue" . "#4682B4")
185 ("Tan" . "#D2B48C")
186 ("Teal" . "#008080")
187 ("Thistle" . "#D8BFD8")
188 ("Tomato" . "#FF6347")
189 ("Turquoise" . "#40E0D0")
190 ("Violet" . "#EE82EE")
191 ("Wheat" . "#F5DEB3")
192 ("White" . "#FFFFFF")
193 ("WhiteSmoke" . "#F5F5F5")
194 ("Yellow" . "#FFFF00")
195 ("YellowGreen" . "#9ACD32"))
196 "Alist of HTML colors.
197Each entry should have the form (COLOR-NAME . HEXADECIMAL-COLOR).")
198
48(defun shr-color-relative-to-absolute (number) 199(defun shr-color-relative-to-absolute (number)
49 "Convert a relative NUMBER to absolute. If NUMBER is absolute, return NUMBER. 200 "Convert a relative NUMBER to absolute. If NUMBER is absolute, return NUMBER.
50This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"." 201This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"."
@@ -78,30 +229,42 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but \"123\" to \"123\"."
78 "Convert any color format to hexadecimal representation. 229 "Convert any color format to hexadecimal representation.
79Like rgb() or hsl()." 230Like rgb() or hsl()."
80 (when color 231 (when color
81 (cond ((or (string-match 232 (cond
82 "rgb(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*)" 233 ;; Hexadecimal color: #abc or #aabbcc
83 color) 234 ((string-match-p
84 (string-match 235 "#[0-9a-fA-F]\\{3\\}[0-9a-fA-F]\\{3\\}?"
85 "rgba(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)" 236 color)
86 color)) 237 color)
87 (format "#%02X%02X%02X" 238 ;; rgb() or rgba() colors
88 (shr-color-relative-to-absolute (match-string-no-properties 1 color)) 239 ((or (string-match
89 (shr-color-relative-to-absolute (match-string-no-properties 2 color)) 240 "rgb(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*)"
90 (shr-color-relative-to-absolute (match-string-no-properties 3 color)))) 241 color)
91 ((or (string-match 242 (string-match
92 "hsl(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*)" 243 "rgba(\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*\\([0-9]\\{1,3\\}\\(?:\s*%\\)?\\)\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)"
93 color) 244 color))
94 (string-match 245 (format "#%02X%02X%02X"
95 "hsla(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)" 246 (shr-color-relative-to-absolute (match-string-no-properties 1 color))
96 color)) 247 (shr-color-relative-to-absolute (match-string-no-properties 2 color))
97 (let ((h (/ (string-to-number (match-string-no-properties 1 color)) 360.0)) 248 (shr-color-relative-to-absolute (match-string-no-properties 3 color))))
98 (s (/ (string-to-number (match-string-no-properties 2 color)) 100.0)) 249 ;; hsl() or hsla() colors
99 (l (/ (string-to-number (match-string-no-properties 3 color)) 100.0))) 250 ((or (string-match
100 (destructuring-bind (r g b) 251 "hsl(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*)"
101 (shr-color-hsl-to-rgb-fractions h s l) 252 color)
102 (format "#%02X%02X%02X" (* r 255) (* g 255) (* b 255))))) 253 (string-match
103 (t 254 "hsla(\s*\\([0-9]\\{1,3\\}\\)\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*\\([0-9]\\{1,3\\}\\)\s*%\s*,\s*[0-9]*\.?[0-9]+\s*%?\s*)"
104 color)))) 255 color))
256 (let ((h (/ (string-to-number (match-string-no-properties 1 color)) 360.0))
257 (s (/ (string-to-number (match-string-no-properties 2 color)) 100.0))
258 (l (/ (string-to-number (match-string-no-properties 3 color)) 100.0)))
259 (destructuring-bind (r g b)
260 (shr-color-hsl-to-rgb-fractions h s l)
261 (format "#%02X%02X%02X" (* r 255) (* g 255) (* b 255)))))
262 ;; Color names
263 ((assoc color shr-color-html-colors-alist)
264 (cdr (assoc-string color shr-color-html-colors-alist t)))
265 ;; Unrecognized color :(
266 (t
267 nil))))
105 268
106(defun set-minimum-interval (val1 val2 min max interval &optional fixed) 269(defun set-minimum-interval (val1 val2 min max interval &optional fixed)
107 "Set minimum interval between VAL1 and VAL2 to INTERVAL. 270 "Set minimum interval between VAL1 and VAL2 to INTERVAL.
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index 1efa31ad176..8398e8a6114 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -502,6 +502,8 @@ START, and END."
502 502
503(defun shr-insert-color-overlay (color start end) 503(defun shr-insert-color-overlay (color start end)
504 (when color 504 (when color
505 (when (string-match " " color)
506 (setq color (car (split-string color))))
505 (let ((overlay (make-overlay start end))) 507 (let ((overlay (make-overlay start end)))
506 (overlay-put overlay 'face (cons 'foreground-color 508 (overlay-put overlay 'face (cons 'foreground-color
507 (cadr (shr-color-check color))))))) 509 (cadr (shr-color-check color)))))))