Mercurial > emacs
annotate lisp/gnus/rfc1843.el @ 68129:6f5da26b0df1
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-690
Merge from gnus--rel--5.10
Patches applied:
* gnus--rel--5.10 (patch 174-181)
- Update from CVS
- Update from CVS: texi/gnus.texi (RSS): Addition.
2006-01-10 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/nnrss.el (nnrss-wash-html-in-text-plain-parts): New variable.
(nnrss-request-article): Render text/plain parts as HTML.
* lisp/gnus/gnus-art.el (gnus-article-wash-html-with-w3m): No need to narrow
the buffer.
2006-01-08 Reiner Steib <Reiner.Steib@gmx.de>
* lisp/gnus/gnus-cus.el (gnus-group-parameters): Sync posting-style with
custom definition of `gnus-posting-styles'.
* lisp/gnus/gnus-start.el (gnus-gnus-to-quick-newsrc-format): Bind
print-circle. Suggested by Kalle Olavi Niemitalo <kon@iki.fi>.
2006-01-05 Reiner Steib <Reiner.Steib@gmx.de>
* lisp/gnus/gnus-group.el (gnus-useful-groups): Use Gmane for ding. Use
nntp for bug archive.
2006-01-05 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/nnrss.el (nnrss-request-article): Fix the way to fill text/plain
parts.
(nnrss-normalize-date): New function converts ISO 8601 date into
RFC822 style. Suggested by Mark Plaksin <happy@mcplaksin.org>.
(nnrss-check-group): Use it.
2006-01-03 Rodrigo Ventura <yoda@isr.ist.utl.pt> (tiny change)
* lisp/gnus/gnus-xmas.el (gnus-xmas-group-startup-message): Typo
gnus-splash-face -> gnus-splash. Fixes starting from a TTY in
XEmacs.
2006-01-01 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/gnus-sum.el (gnus-summary-work-articles): Remove useless `min'.
* lisp/gnus/nnrss.el (nnrss-fetch): Make it fail gracefully when it can't
fetch a feed. Suggested by Mark Plaksin <happy@mcplaksin.org>.
(nnrss-insert-w3): Ditto.
2005-12-21 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/nnrss.el (nnrss-request-article): Fix last change; fill
text/plain parts.
2005-12-20 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/nnrss.el (nnrss-request-article): Replace <br />s with newlines
in text/plain part.
(nnrss-check-group): Don't add excessive newline to dc:subject.
2005-12-19 Katsumi Yamaoka <yamaoka@jpl.org>
* lisp/gnus/gnus-art.el (gnus-article-delete-text-of-type): Enable it to
remove MIME buttons associated with multipart/alternative parts.
(gnus-mime-display-alternative): Tag buttons using `article-type'
text property.
* lisp/gnus/gnus-msg.el (gnus-copy-article-buffer): Remove MIME buttons
associated with multipart/alternative parts.
2005-12-19 Mark Plaksin <happy@mcplaksin.org> (tiny change)
* lisp/gnus/nnrss.el (nnrss-check-group): Put the RSS dc:subject in the
article.
2005-12-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* lisp/gnus/dns.el (query-dns): Make sure we check the buffer size before
removing tcp headers.
2006-01-10 Katsumi Yamaoka <yamaoka@jpl.org>
* man/gnus.texi (RSS): Document nnrss-wash-html-in-text-plain-parts.
2006-01-06 Katsumi Yamaoka <yamaoka@jpl.org>
* man/gnus.texi (RSS): Addition.
2005-12-22 Katsumi Yamaoka <yamaoka@jpl.org>
* man/gnus.texi (Summary Post Commands): Fix function bound to `S O p'.
2005-12-19 Katsumi Yamaoka <yamaoka@jpl.org>
* man/emacs-mime.texi (Display Customization): Add setting example to
mm-discouraged-alternatives.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 11 Jan 2006 02:03:24 +0000 |
parents | 48de3c91b9bc |
children | 1077b8039c32 a3716f7538f2 |
rev | line source |
---|---|
31717 | 1 ;;; rfc1843.el --- HZ (rfc1843) decoding |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
4 ;; 2005 Free Software Foundation, Inc. |
31717 | 5 |
6 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu> | |
7 ;; Keywords: news HZ HZ+ mail i18n | |
8 | |
38413
a26d9b55abb6
Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents:
32178
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
31717 | 10 |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published | |
13 ;; by the Free Software Foundation; either version 2, or (at your | |
14 ;; option) any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, but | |
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 ;; General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
31717 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; Usage: | |
29 ;; (require 'rfc1843) | |
30 ;; (rfc1843-gnus-setup) | |
31 ;; | |
32 ;; Test: | |
33 ;; (rfc1843-decode-string "~{<:Ky2;S{#,NpJ)l6HK!#~}") | |
34 | |
35 ;;; Code: | |
36 | |
32178 | 37 (eval-when-compile (require 'cl)) |
31717 | 38 (require 'mm-util) |
39 | |
65283
48de3c91b9bc
(gnus-decode-encoded-word-function, gnus-decode-header-function,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
40 (defvar gnus-decode-encoded-word-function) |
48de3c91b9bc
(gnus-decode-encoded-word-function, gnus-decode-header-function,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
41 (defvar gnus-decode-header-function) |
48de3c91b9bc
(gnus-decode-encoded-word-function, gnus-decode-header-function,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
42 (defvar gnus-newsgroup-name) |
48de3c91b9bc
(gnus-decode-encoded-word-function, gnus-decode-header-function,
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
43 |
31717 | 44 (defvar rfc1843-word-regexp |
45 "~\\({\\([\041-\167][\041-\176]\\| \\)+\\)\\(~}\\|$\\)") | |
46 | |
47 (defvar rfc1843-word-regexp-strictly | |
48 "~\\({\\([\041-\167][\041-\176]\\)+\\)\\(~}\\|$\\)") | |
49 | |
50 (defvar rfc1843-hzp-word-regexp | |
51 "~\\({\\([\041-\167][\041-\176]\\| \\)+\\|\ | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
52 \[<>]\\([\041-\175][\041-\176]\\| \\)+\\)\\(~}\\|$\\)") |
31717 | 53 |
54 (defvar rfc1843-hzp-word-regexp-strictly | |
55 "~\\({\\([\041-\167][\041-\176]\\)+\\|\ | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
56 \[<>]\\([\041-\175][\041-\176]\\)+\\)\\(~}\\|$\\)") |
31717 | 57 |
58 (defcustom rfc1843-decode-loosely nil | |
59 "Loosely check HZ encoding if non-nil. | |
60 When it is set non-nil, only buffers or strings with strictly | |
61 HZ-encoded are decoded." | |
62 :type 'boolean | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
63 :group 'mime) |
31717 | 64 |
65 (defcustom rfc1843-decode-hzp t | |
66 "HZ+ decoding support if non-nil. | |
67 HZ+ specification (also known as HZP) is to provide a standardized | |
68 7-bit representation of mixed Big5, GB, and ASCII text for convenient | |
69 e-mail transmission, news posting, etc. | |
70 The document of HZ+ 0.78 specification can be found at | |
71 ftp://ftp.math.psu.edu/pub/simpson/chinese/hzp/hzp.doc" | |
72 :type 'boolean | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
73 :group 'mime) |
31717 | 74 |
75 (defcustom rfc1843-newsgroups-regexp "chinese\\|hz" | |
76 "Regexp of newsgroups in which might be HZ encoded." | |
77 :type 'string | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
78 :group 'mime) |
31717 | 79 |
80 (defun rfc1843-decode-region (from to) | |
81 "Decode HZ in the region between FROM and TO." | |
82 (interactive "r") | |
83 (let (str firstc) | |
84 (save-excursion | |
85 (goto-char from) | |
86 (if (or rfc1843-decode-loosely | |
87 (re-search-forward (if rfc1843-decode-hzp | |
88 rfc1843-hzp-word-regexp-strictly | |
89 rfc1843-word-regexp-strictly) to t)) | |
90 (save-restriction | |
91 (narrow-to-region from to) | |
92 (goto-char (point-min)) | |
93 (while (re-search-forward (if rfc1843-decode-hzp | |
94 rfc1843-hzp-word-regexp | |
95 rfc1843-word-regexp) (point-max) t) | |
96 ;;; Text with extents may cause XEmacs crash | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
97 (setq str (buffer-substring-no-properties |
31717 | 98 (match-beginning 1) |
99 (match-end 1))) | |
100 (setq firstc (aref str 0)) | |
101 (insert (mm-decode-coding-string | |
102 (rfc1843-decode | |
103 (prog1 | |
104 (substring str 1) | |
105 (delete-region (match-beginning 0) (match-end 0))) | |
106 firstc) | |
107 (if (eq firstc ?{) 'cn-gb-2312 'cn-big5)))) | |
108 (goto-char (point-min)) | |
109 (while (search-forward "~" (point-max) t) | |
110 (cond ((eq (char-after) ?\n) | |
111 (delete-char -1) | |
112 (delete-char 1)) | |
113 ((eq (char-after) ?~) | |
114 (delete-char 1))))))))) | |
115 | |
116 (defun rfc1843-decode-string (string) | |
117 "Decode HZ STRING and return the results." | |
118 (let ((m (mm-multibyte-p))) | |
119 (with-temp-buffer | |
120 (when m | |
121 (mm-enable-multibyte)) | |
122 (insert string) | |
123 (inline | |
124 (rfc1843-decode-region (point-min) (point-max))) | |
125 (buffer-string)))) | |
126 | |
127 (defun rfc1843-decode (word &optional firstc) | |
128 "Decode HZ WORD and return it." | |
129 (let ((i -1) (s (substring word 0)) v) | |
130 (if (or (not firstc) (eq firstc ?{)) | |
131 (while (< (incf i) (length s)) | |
132 (if (eq (setq v (aref s i)) ? ) nil | |
133 (aset s i (+ 128 v)))) | |
134 (while (< (incf i) (length s)) | |
135 (if (eq (setq v (aref s i)) ? ) nil | |
136 (setq v (+ (* 94 v) (aref s (1+ i)) -3135)) | |
137 (aset s i (+ (/ v 157) (if (eq firstc ?<) 201 161))) | |
138 (setq v (% v 157)) | |
139 (aset s (incf i) (+ v (if (< v 63) 64 98)))))) | |
140 s)) | |
141 | |
142 (defun rfc1843-decode-article-body () | |
143 "Decode HZ encoded text in the article body." | |
144 (if (string-match (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | |
145 (or gnus-newsgroup-name "")) | |
146 (save-excursion | |
147 (save-restriction | |
148 (message-narrow-to-head) | |
149 (let* ((inhibit-point-motion-hooks t) | |
150 (case-fold-search t) | |
151 (ct (message-fetch-field "Content-Type" t)) | |
152 (ctl (and ct (ignore-errors | |
153 (mail-header-parse-content-type ct))))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
154 (if (and ctl (not (string-match "/" (car ctl)))) |
31717 | 155 (setq ctl nil)) |
156 (goto-char (point-max)) | |
157 (widen) | |
158 (forward-line 1) | |
159 (narrow-to-region (point) (point-max)) | |
160 (when (or (not ctl) | |
161 (equal (car ctl) "text/plain")) | |
162 (rfc1843-decode-region (point) (point-max)))))))) | |
163 | |
164 (defvar rfc1843-old-gnus-decode-header-function nil) | |
165 (defvar gnus-decode-header-methods) | |
166 (defvar gnus-decode-encoded-word-methods) | |
167 | |
168 (defun rfc1843-gnus-setup () | |
169 "Setup HZ decoding for Gnus." | |
170 (require 'gnus-art) | |
171 (require 'gnus-sum) | |
172 (add-hook 'gnus-article-decode-hook 'rfc1843-decode-article-body t) | |
173 (setq gnus-decode-encoded-word-function | |
174 'gnus-multi-decode-encoded-word-string | |
175 gnus-decode-header-function | |
176 'gnus-multi-decode-header | |
177 gnus-decode-encoded-word-methods | |
178 (nconc gnus-decode-encoded-word-methods | |
179 (list | |
180 (cons (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | |
181 'rfc1843-decode-string))) | |
182 gnus-decode-header-methods | |
183 (nconc gnus-decode-header-methods | |
184 (list | |
185 (cons (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | |
186 'rfc1843-decode-region))))) | |
187 | |
188 (provide 'rfc1843) | |
189 | |
52401 | 190 ;;; arch-tag: 5149c301-a6ca-4731-9c9d-ba616e2cb687 |
31717 | 191 ;;; rfc1843.el ends here |