Mercurial > emacs
annotate lisp/gnus/rfc1843.el @ 82975:590114f9753d gnus-5_10-pre-merge-josefsson
2004-08-31 Katsumi Yamaoka <yamaoka@jpl.org>
* gnus-agent.el (gnus-agent-restore-gcc): Use ^ and regexp-quote.
* gnus-sum.el (gnus-newsgroup-variables): Doc fix (tiny change).
From Helmut Waitzmann <Helmut.Waitzmann@web.de>.
* gnus-agent.el (gnus-agent-regenerate-group): Activate the group
when the group's active is not available.
* gnus-art.el (article-hide-headers): Refer to the values for
gnus-ignored-headers and gnus-visible-headers in the summary
buffer since a user may have set them as group parameters.
(gnus-article-next-page): Fix the way to find a real end-of-buffer
(tiny change). From YAGI Tatsuya <ynyaaa@ybb.ne.jp>.
(gnus-article-read-summary-keys): Restore new window-start and
hscroll to summary window.
(gnus-prev-page-map): Remove duplicated one.
* gnus-cite.el (gnus-cite-ignore-quoted-from): New user option.
(gnus-cite-parse): Ignore quoted envelope From_. Suggested by
Karl Chen <quarl@nospam.quarl.org> and Reiner Steib
<Reiner.Steib@gmx.de>.
* gnus-cus.el (gnus-agent-cat-prepare-category-field): Replace
pp-to-string with gnus-pp-to-string.
* gnus-eform.el (gnus-edit-form): Replace pp with gnus-pp.
* gnus-group.el (gnus-group-make-kiboze-group): Replace pp with
gnus-pp.
* gnus-msg.el (gnus-setup-message): Ignore an article copy while
parsing gnus-posting-styles when the message is not for replying.
(gnus-summary-resend-message-edit): Call mime-to-mml. Suggested
by Hiroshi Fujishima <pooh@nature.tsukuba.ac.jp>.
(gnus-debug): Replace pp with gnus-pp.
* gnus-score.el (gnus-score-save): Replace pp with gnus-pp.
* gnus-spec.el (gnus-update-format): Replace pp-to-string with
gnus-pp-to-string.
* gnus-sum.el (gnus-read-header): Don't remove a header for the
parent article of a sparse article in the thread hashtb. From
Stefan Wiens <s.wi@gmx.net>.
* gnus-util.el (gnus-bind-print-variables): New macro.
(gnus-prin1): Use it.
(gnus-prin1-to-string): Use it.
(gnus-pp): New function.
(gnus-pp-to-string): New function.
* gnus.el: Don't make unnecessary *Group* buffer when loading.
* mail-source.el (mail-source-touch-pop): Doc fix.
* message.el (message-mode): Don't modify paragraph-separate there.
(message-setup-fill-variables): Add mml tags to paragraph-start
and paragraph-separate. Suggested by Andrew Korty <ajk@iu.edu>.
(message-smtpmail-send-it): Doc fix.
(message-exchange-point-and-mark): Don't activate region if it was
inactive. Suggested by Hiroshi Fujishima
<pooh@nature.tsukuba.ac.jp> and Jesper Harder <harder@ifa.au.dk>.
* mm-decode.el (mm-save-part): Bind enable-multibyte-characters to
t while entering a file name using the mm-with-multibyte macro.
Suggested by Hiroshi Fujishima <pooh@nature.tsukuba.ac.jp>.
* mm-encode.el (mm-content-transfer-encoding-defaults): Use
qp-or-base64 for the application/* types.
(mm-safer-encoding): Consider 7bit is safe.
* mm-util.el (mm-with-multibyte-buffer): New macro.
(mm-with-multibyte): New macro.
* mm-view.el (mm-inline-render-with-function): Use multibyte
buffer; decode html source by charset.
* nndoc.el (nndoc-type-alist): Improve regexp for article-begin,
add generate-head-function and generate-article-function to the
rfc822-forward entry.
(nndoc-forward-type-p): Recognize envelope From_.
(nndoc-rfc822-forward-generate-article): New function.
(nndoc-rfc822-forward-generate-head): New function.
From David Hedbor <dhedbor@real.com>.
* nnmail.el (nnmail-split-lowercase-expanded): New user option.
(nnmail-expand-newtext): Lowercase expanded entries if
nnmail-split-lowercase-expanded is non-nil.
* score-mode.el (gnus-score-pretty-print): Replace pp with gnus-pp.
* webmail.el (webmail-debug): Replace pp with gnus-pp.
* gnus-art.el (gnus-article-wash-html-with-w3m): Bind
w3m-safe-url-regexp as the value for mm-w3m-safe-url-regexp; use
w3m-minor-mode-map instead of mm-w3m-local-map-property.
(gnus-mime-save-part-and-strip): Use mm-complicated-handles
instead of mm-multiple-handles.
(gnus-mime-delete-part): Ditto.
* mm-decode.el (mm-multiple-handles): Recognize a string as a mime
handle, as well as a list.
(mm-complicated-handles): Former definition of mm-multiple-handles.
* mm-view.el (mm-w3m-mode-map): Remove.
(mm-w3m-local-map-property): Remove.
(mm-w3m-cid-retrieve-1): Call itself recursively. Suggested by
ARISAWA Akihiro <ari@mbf.sphere.ne.jp>.
(mm-w3m-cid-retrieve): Simplify.
(mm-inline-text-html-render-with-w3m): Decode html source by
charset; check META tags only when charsets are not specified in
headers; specify charset to w3m-region; use w3m-minor-mode-map
instead of mm-w3m-local-map-property.
author | Reiner Steib <Reiner.Steib@gmx.de> |
---|---|
date | Tue, 31 Aug 2004 14:47:59 +0000 |
parents | 0fde48feb604 |
children | 18a818a2ee7c cce1c0ee76ee |
rev | line source |
---|---|
31717 | 1 ;;; rfc1843.el --- HZ (rfc1843) decoding |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
2 ;; Copyright (c) 1998, 1999, 2000, 2003 Free Software Foundation, Inc. |
31717 | 3 |
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu> | |
5 ;; Keywords: news HZ HZ+ mail i18n | |
6 | |
38413
a26d9b55abb6
Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents:
32178
diff
changeset
|
7 ;; This file is part of GNU Emacs. |
31717 | 8 |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published | |
11 ;; by the Free Software Foundation; either version 2, or (at your | |
12 ;; option) any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, but | |
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 ;; General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;; Usage: | |
27 ;; (require 'rfc1843) | |
28 ;; (rfc1843-gnus-setup) | |
29 ;; | |
30 ;; Test: | |
31 ;; (rfc1843-decode-string "~{<:Ky2;S{#,NpJ)l6HK!#~}") | |
32 | |
33 ;;; Code: | |
34 | |
32178 | 35 (eval-when-compile (require 'cl)) |
31717 | 36 (require 'mm-util) |
37 | |
38 (defvar rfc1843-word-regexp | |
39 "~\\({\\([\041-\167][\041-\176]\\| \\)+\\)\\(~}\\|$\\)") | |
40 | |
41 (defvar rfc1843-word-regexp-strictly | |
42 "~\\({\\([\041-\167][\041-\176]\\)+\\)\\(~}\\|$\\)") | |
43 | |
44 (defvar rfc1843-hzp-word-regexp | |
45 "~\\({\\([\041-\167][\041-\176]\\| \\)+\\|\ | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
46 \[<>]\\([\041-\175][\041-\176]\\| \\)+\\)\\(~}\\|$\\)") |
31717 | 47 |
48 (defvar rfc1843-hzp-word-regexp-strictly | |
49 "~\\({\\([\041-\167][\041-\176]\\)+\\|\ | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
50 \[<>]\\([\041-\175][\041-\176]\\)+\\)\\(~}\\|$\\)") |
31717 | 51 |
52 (defcustom rfc1843-decode-loosely nil | |
53 "Loosely check HZ encoding if non-nil. | |
54 When it is set non-nil, only buffers or strings with strictly | |
55 HZ-encoded are decoded." | |
56 :type 'boolean | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
57 :group 'mime) |
31717 | 58 |
59 (defcustom rfc1843-decode-hzp t | |
60 "HZ+ decoding support if non-nil. | |
61 HZ+ specification (also known as HZP) is to provide a standardized | |
62 7-bit representation of mixed Big5, GB, and ASCII text for convenient | |
63 e-mail transmission, news posting, etc. | |
64 The document of HZ+ 0.78 specification can be found at | |
65 ftp://ftp.math.psu.edu/pub/simpson/chinese/hzp/hzp.doc" | |
66 :type 'boolean | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
67 :group 'mime) |
31717 | 68 |
69 (defcustom rfc1843-newsgroups-regexp "chinese\\|hz" | |
70 "Regexp of newsgroups in which might be HZ encoded." | |
71 :type 'string | |
82951
0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
72 :group 'mime) |
31717 | 73 |
74 (defun rfc1843-decode-region (from to) | |
75 "Decode HZ in the region between FROM and TO." | |
76 (interactive "r") | |
77 (let (str firstc) | |
78 (save-excursion | |
79 (goto-char from) | |
80 (if (or rfc1843-decode-loosely | |
81 (re-search-forward (if rfc1843-decode-hzp | |
82 rfc1843-hzp-word-regexp-strictly | |
83 rfc1843-word-regexp-strictly) to t)) | |
84 (save-restriction | |
85 (narrow-to-region from to) | |
86 (goto-char (point-min)) | |
87 (while (re-search-forward (if rfc1843-decode-hzp | |
88 rfc1843-hzp-word-regexp | |
89 rfc1843-word-regexp) (point-max) t) | |
90 ;;; Text with extents may cause XEmacs crash | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
91 (setq str (buffer-substring-no-properties |
31717 | 92 (match-beginning 1) |
93 (match-end 1))) | |
94 (setq firstc (aref str 0)) | |
95 (insert (mm-decode-coding-string | |
96 (rfc1843-decode | |
97 (prog1 | |
98 (substring str 1) | |
99 (delete-region (match-beginning 0) (match-end 0))) | |
100 firstc) | |
101 (if (eq firstc ?{) 'cn-gb-2312 'cn-big5)))) | |
102 (goto-char (point-min)) | |
103 (while (search-forward "~" (point-max) t) | |
104 (cond ((eq (char-after) ?\n) | |
105 (delete-char -1) | |
106 (delete-char 1)) | |
107 ((eq (char-after) ?~) | |
108 (delete-char 1))))))))) | |
109 | |
110 (defun rfc1843-decode-string (string) | |
111 "Decode HZ STRING and return the results." | |
112 (let ((m (mm-multibyte-p))) | |
113 (with-temp-buffer | |
114 (when m | |
115 (mm-enable-multibyte)) | |
116 (insert string) | |
117 (inline | |
118 (rfc1843-decode-region (point-min) (point-max))) | |
119 (buffer-string)))) | |
120 | |
121 (defun rfc1843-decode (word &optional firstc) | |
122 "Decode HZ WORD and return it." | |
123 (let ((i -1) (s (substring word 0)) v) | |
124 (if (or (not firstc) (eq firstc ?{)) | |
125 (while (< (incf i) (length s)) | |
126 (if (eq (setq v (aref s i)) ? ) nil | |
127 (aset s i (+ 128 v)))) | |
128 (while (< (incf i) (length s)) | |
129 (if (eq (setq v (aref s i)) ? ) nil | |
130 (setq v (+ (* 94 v) (aref s (1+ i)) -3135)) | |
131 (aset s i (+ (/ v 157) (if (eq firstc ?<) 201 161))) | |
132 (setq v (% v 157)) | |
133 (aset s (incf i) (+ v (if (< v 63) 64 98)))))) | |
134 s)) | |
135 | |
136 (defun rfc1843-decode-article-body () | |
137 "Decode HZ encoded text in the article body." | |
138 (if (string-match (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | |
139 (or gnus-newsgroup-name "")) | |
140 (save-excursion | |
141 (save-restriction | |
142 (message-narrow-to-head) | |
143 (let* ((inhibit-point-motion-hooks t) | |
144 (case-fold-search t) | |
145 (ct (message-fetch-field "Content-Type" t)) | |
146 (ctl (and ct (ignore-errors | |
147 (mail-header-parse-content-type ct))))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38413
diff
changeset
|
148 (if (and ctl (not (string-match "/" (car ctl)))) |
31717 | 149 (setq ctl nil)) |
150 (goto-char (point-max)) | |
151 (widen) | |
152 (forward-line 1) | |
153 (narrow-to-region (point) (point-max)) | |
154 (when (or (not ctl) | |
155 (equal (car ctl) "text/plain")) | |
156 (rfc1843-decode-region (point) (point-max)))))))) | |
157 | |
158 (defvar rfc1843-old-gnus-decode-header-function nil) | |
159 (defvar gnus-decode-header-methods) | |
160 (defvar gnus-decode-encoded-word-methods) | |
161 | |
162 (defun rfc1843-gnus-setup () | |
163 "Setup HZ decoding for Gnus." | |
164 (require 'gnus-art) | |
165 (require 'gnus-sum) | |
166 (add-hook 'gnus-article-decode-hook 'rfc1843-decode-article-body t) | |
167 (setq gnus-decode-encoded-word-function | |
168 'gnus-multi-decode-encoded-word-string | |
169 gnus-decode-header-function | |
170 'gnus-multi-decode-header | |
171 gnus-decode-encoded-word-methods | |
172 (nconc gnus-decode-encoded-word-methods | |
173 (list | |
174 (cons (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | |
175 'rfc1843-decode-string))) | |
176 gnus-decode-header-methods | |
177 (nconc gnus-decode-header-methods | |
178 (list | |
179 (cons (concat "\\<\\(" rfc1843-newsgroups-regexp "\\)\\>") | |
180 'rfc1843-decode-region))))) | |
181 | |
182 (provide 'rfc1843) | |
183 | |
52401 | 184 ;;; arch-tag: 5149c301-a6ca-4731-9c9d-ba616e2cb687 |
31717 | 185 ;;; rfc1843.el ends here |