aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatsumi Yamaoka2013-06-18 09:29:20 +0000
committerKatsumi Yamaoka2013-06-18 09:29:20 +0000
commitdb5a34cae7ead2df3515f939b6cd6f1c1f889c2e (patch)
tree30dc0261fe5af8b9de3a639d1ab326addfe69eb9
parent9a08a6173c251e20bb8aeb7482ec7e429e863a4d (diff)
downloademacs-db5a34cae7ead2df3515f939b6cd6f1c1f889c2e.tar.gz
emacs-db5a34cae7ead2df3515f939b6cd6f1c1f889c2e.zip
lisp/gnus/eww.el (eww-detect-charset): Improve regexp; move backward
-rw-r--r--lisp/gnus/ChangeLog4
-rw-r--r--lisp/gnus/eww.el24
2 files changed, 16 insertions, 12 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 06c5a98c6bc..c96702260fc 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,7 @@
12013-06-18 Katsumi Yamaoka <yamaoka@jpl.org>
2
3 * eww.el (eww-detect-charset): Improve regexp; move backward.
4
12013-06-18 Glenn Morris <rgm@gnu.org> 52013-06-18 Glenn Morris <rgm@gnu.org>
2 6
3 * mm-decode.el (widget-convert-button): Autoload. 7 * mm-decode.el (widget-convert-button): Autoload.
diff --git a/lisp/gnus/eww.el b/lisp/gnus/eww.el
index 36baf354100..3914f067185 100644
--- a/lisp/gnus/eww.el
+++ b/lisp/gnus/eww.el
@@ -64,18 +64,6 @@
64 (setq url (concat "http://" url))) 64 (setq url (concat "http://" url)))
65 (url-retrieve url 'eww-render (list url))) 65 (url-retrieve url 'eww-render (list url)))
66 66
67(defun eww-detect-charset (html-p)
68 (let ((case-fold-search t)
69 (pt (point)))
70 (or (and html-p
71 (re-search-forward
72 "<meta[\t\n\r ]+[^>]*charset=\\([^\t\n\r \"/>]+\\)" nil t)
73 (goto-char pt)
74 (match-string 1))
75 (and (looking-at
76 "[\t\n\r ]*<\\?xml[\t\n\r ]+[^>]*encoding=\"\\([^\"]+\\)")
77 (match-string 1)))))
78
79(defun eww-render (status url &optional point) 67(defun eww-render (status url &optional point)
80 (let ((redirect (plist-get status :redirect))) 68 (let ((redirect (plist-get status :redirect)))
81 (when redirect 69 (when redirect
@@ -128,6 +116,18 @@
128 (forward-line 1)) 116 (forward-line 1))
129 headers)) 117 headers))
130 118
119(defun eww-detect-charset (html-p)
120 (let ((case-fold-search t)
121 (pt (point)))
122 (or (and html-p
123 (re-search-forward
124 "<meta[\t\n\r ]+[^>]*charset=\"?\\([^\t\n\r \"/>]+\\)" nil t)
125 (goto-char pt)
126 (match-string 1))
127 (and (looking-at
128 "[\t\n\r ]*<\\?xml[\t\n\r ]+[^>]*encoding=\"\\([^\"]+\\)")
129 (match-string 1)))))
130
131(defun eww-display-html (charset url) 131(defun eww-display-html (charset url)
132 (unless (eq charset 'utf8) 132 (unless (eq charset 'utf8)
133 (decode-coding-region (point) (point-max) charset)) 133 (decode-coding-region (point) (point-max) charset))