annotate lisp/gnus/rfc2047.el @ 57876:eb20070961bb

(USAGE3): Delete --horizontal-scroll-bars, -hb.
author Richard M. Stallman <rms@gnu.org>
date Tue, 02 Nov 2004 09:10:13 +0000
parents c5e16264557d
children 9bdd97960431 e23928ac5a97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38413
a26d9b55abb6 Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents: 35985
diff changeset
1 ;;; rfc2047.el --- functions for encoding and decoding rfc2047 messages
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
2 ;; Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; This file is part of GNU Emacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; any later version.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; GNU Emacs is distributed in the hope that it will be useful,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; GNU General Public License for more details.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; Boston, MA 02111-1307, USA.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;;; Commentary:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
34674
79dde983f45b Add some commentary.
Dave Love <fx@gnu.org>
parents: 33815
diff changeset
25 ;; RFC 2047 is "MIME (Multipurpose Internet Mail Extensions) Part
79dde983f45b Add some commentary.
Dave Love <fx@gnu.org>
parents: 33815
diff changeset
26 ;; Three: Message Header Extensions for Non-ASCII Text".
79dde983f45b Add some commentary.
Dave Love <fx@gnu.org>
parents: 33815
diff changeset
27
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;;; Code:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
30 (eval-when-compile
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
31 (require 'cl)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
32 (defvar message-posting-charset)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
33 (unless (fboundp 'with-syntax-table) ; not in Emacs 20
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
34 (defmacro with-syntax-table (table &rest body)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
35 "Evaluate BODY with syntax table of current buffer set to TABLE.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
36 The syntax table of the current buffer is saved, BODY is evaluated, and the
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
37 saved table is restored, even in case of an abnormal exit.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
38 Value is what BODY returns."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
39 (let ((old-table (make-symbol "table"))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
40 (old-buffer (make-symbol "buffer")))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
41 `(let ((,old-table (syntax-table))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
42 (,old-buffer (current-buffer)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
43 (unwind-protect
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
44 (progn
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
45 (set-syntax-table ,table)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
46 ,@body)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
47 (save-current-buffer
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
48 (set-buffer ,old-buffer)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
49 (set-syntax-table ,old-table))))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 (require 'qp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 (require 'mm-util)
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
53 ;; Fixme: Avoid this (used for mail-parse-charset) mm dependence on gnus.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 (require 'mail-prsvr)
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
55 (require 'base64)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
56 (autoload 'mm-body-7-or-8 "mm-bodies")
33127
eca95f9d7f05 (base64): Require unconditionally.
Dave Love <fx@gnu.org>
parents: 31764
diff changeset
57
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
58 (eval-and-compile
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
59 ;; Avoid gnus-util for mm- code.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
60 (defalias 'rfc2047-point-at-bol
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
61 (if (fboundp 'point-at-bol)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
62 'point-at-bol
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
63 'line-beginning-position))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
64
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
65 (defalias 'rfc2047-point-at-eol
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
66 (if (fboundp 'point-at-eol)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
67 'point-at-eol
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
68 'line-end-position)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
69
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 (defvar rfc2047-header-encoding-alist
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
71 '(("Newsgroups" . nil)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
72 ("Followup-To" . nil)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ("Message-ID" . nil)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
74 ("\\(Resent-\\)?\\(From\\|Cc\\|To\\|Bcc\\|Reply-To\\|Sender\
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
75 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\)" . address-mime)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (t . mime))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 "*Header/encoding method alist.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 The list is traversed sequentially. The keys can either be
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
79 header regexps or t.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 The values can be:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 1) nil, in which case no encoding is done;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 2) `mime', in which case the header will be encoded according to RFC2047;
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
85 3) `address-mime', like `mime', but takes account of the rules for address
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
86 fields (where quoted strings and comments must be treated separately);
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
87 4) a charset, in which case it will be encoded as that charset;
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
88 5) `default', in which case the field will be encoded as the rest
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 of the article.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 (defvar rfc2047-charset-encoding-alist
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 '((us-ascii . nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 (iso-8859-1 . Q)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 (iso-8859-2 . Q)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 (iso-8859-3 . Q)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 (iso-8859-4 . Q)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 (iso-8859-5 . B)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 (koi8-r . B)
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
99 (iso-8859-7 . B)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
100 (iso-8859-8 . B)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 (iso-8859-9 . Q)
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
102 (iso-8859-14 . Q)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
103 (iso-8859-15 . Q)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (iso-2022-jp . B)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 (iso-2022-kr . B)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 (gb2312 . B)
35838
53eebdb81828 2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 35453
diff changeset
107 (big5 . B)
53eebdb81828 2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 35453
diff changeset
108 (cn-big5 . B)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 (cn-gb . B)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 (cn-gb-2312 . B)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 (euc-kr . B)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 (iso-2022-jp-2 . B)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
113 (iso-2022-int-1 . B)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
114 (viscii . Q))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 "Alist of MIME charsets to RFC2047 encodings.
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
116 Valid encodings are nil, `Q' and `B'. These indicate binary (no) encoding,
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
117 quoted-printable and base64 respectively.")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 (defvar rfc2047-encoding-function-alist
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 '((Q . rfc2047-q-encode-region)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 (B . rfc2047-b-encode-region)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 (nil . ignore))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 "Alist of RFC2047 encodings to encoding functions.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 ;;; Functions for encoding RFC2047 messages
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128
57243
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
129 (defun rfc2047-qp-or-base64 ()
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
130 "Return the type with which to encode the buffer.
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
131 This is either `base64' or `quoted-printable'."
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
132 (save-excursion
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
133 (let ((limit (min (point-max) (+ 2000 (point-min))))
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
134 (n8bit 0))
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
135 (goto-char (point-min))
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
136 (skip-chars-forward "\x20-\x7f\r\n\t" limit)
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
137 (while (< (point) limit)
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
138 (incf n8bit)
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
139 (forward-char 1)
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
140 (skip-chars-forward "\x20-\x7f\r\n\t" limit))
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
141 (if (or (< (* 6 n8bit) (- limit (point-min)))
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
142 ;; Don't base64, say, a short line with a single
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
143 ;; non-ASCII char when splitting parts by charset.
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
144 (= n8bit 1))
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
145 'quoted-printable
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
146 'base64))))
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
147
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 (defun rfc2047-narrow-to-field ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 "Narrow the buffer to the header on the current line."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (beginning-of-line)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 (narrow-to-region
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 (point)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 (forward-line 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 (if (re-search-forward "^[^ \n\t]" nil t)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
156 (rfc2047-point-at-bol)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 (point-max))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 (goto-char (point-min)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
160 (defun rfc2047-field-value ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
161 "Return the value of the field at point."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
162 (save-excursion
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
163 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
164 (rfc2047-narrow-to-field)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
165 (re-search-forward ":[ \t\n]*" nil t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
166 (buffer-substring (point) (point-max)))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
167
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
168 (defvar rfc2047-encoding-type 'address-mime
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
169 "The type of encoding done by `rfc2047-encode-region'.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
170 This should be dynamically bound around calls to
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
171 `rfc2047-encode-region' to either `mime' or `address-mime'. See
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
172 `rfc2047-header-encoding-alist', for definitions.")
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
173
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 (defun rfc2047-encode-message-header ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 "Encode the message header according to `rfc2047-header-encoding-alist'.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 Should be called narrowed to the head of the message."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 (interactive "*")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 (let (alist elem method)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 (while (not (eobp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 (rfc2047-narrow-to-field)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 (if (not (rfc2047-encodable-p))
50881
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
185 (prog1
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
186 (if (and (eq (mm-body-7-or-8) '8bit)
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
187 (mm-multibyte-p)
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
188 (mm-coding-system-p
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
189 (car message-posting-charset)))
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
190 ;; 8 bit must be decoded.
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
191 (mm-encode-coding-region
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
192 (point-min) (point-max)
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
193 (mm-charset-to-coding-system
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
194 (car message-posting-charset))))
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
195 ;; No encoding necessary, but folding is nice
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
196 (rfc2047-fold-region
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
197 (save-excursion
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
198 (goto-char (point-min))
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
199 (skip-chars-forward "^:")
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
200 (when (looking-at ": ")
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
201 (forward-char 2))
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
202 (point))
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
203 (point-max)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 ;; We found something that may perhaps be encoded.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 (setq method nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 alist rfc2047-header-encoding-alist)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 (while (setq elem (pop alist))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (when (or (and (stringp (car elem))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (looking-at (car elem)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 (eq (car elem) t))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 (setq alist nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 method (cdr elem))))
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
213 (goto-char (point-min))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
214 (re-search-forward "^[^:]+: *" nil t)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 (cond
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
216 ((eq method 'address-mime)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
217 (rfc2047-encode-region (point) (point-max)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 ((eq method 'mime)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
219 (let ((rfc2047-encoding-type 'mime))
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
220 (rfc2047-encode-region (point) (point-max))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 ((eq method 'default)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 (if (and (featurep 'mule)
33815
61c7f3065929 (rfc2047-encode-message-header): Don't encode if
Dave Love <fx@gnu.org>
parents: 33304
diff changeset
223 (if (boundp 'default-enable-multibyte-characters)
61c7f3065929 (rfc2047-encode-message-header): Don't encode if
Dave Love <fx@gnu.org>
parents: 33304
diff changeset
224 default-enable-multibyte-characters)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 mail-parse-charset)
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
226 (mm-encode-coding-region (point) (point-max)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 mail-parse-charset)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
228 ;; We get this when CC'ing messsages to newsgroups with
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
229 ;; 8-bit names. The group name mail copy just got
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
230 ;; unconditionally encoded. Previously, it would ask
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
231 ;; whether to encode, which was quite confusing for the
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
232 ;; user. If the new behaviour is wrong, tell me. I have
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
233 ;; left the old code commented out below.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
234 ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-07.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
235 ;; Modified by Dave Love, with the commented-out code changed
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
236 ;; in accordance with changes elsewhere.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
237 ((null method)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
238 (rfc2047-encode-region (point) (point-max)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
239 ;;; ((null method)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
240 ;;; (if (or (message-options-get
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
241 ;;; 'rfc2047-encode-message-header-encode-any)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
242 ;;; (message-options-set
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
243 ;;; 'rfc2047-encode-message-header-encode-any
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
244 ;;; (y-or-n-p
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
245 ;;; "Some texts are not encoded. Encode anyway?")))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
246 ;;; (rfc2047-encode-region (point-min) (point-max))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
247 ;;; (error "Cannot send unencoded text")))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 ((mm-coding-system-p method)
33815
61c7f3065929 (rfc2047-encode-message-header): Don't encode if
Dave Love <fx@gnu.org>
parents: 33304
diff changeset
249 (if (and (featurep 'mule)
61c7f3065929 (rfc2047-encode-message-header): Don't encode if
Dave Love <fx@gnu.org>
parents: 33304
diff changeset
250 (if (boundp 'default-enable-multibyte-characters)
61c7f3065929 (rfc2047-encode-message-header): Don't encode if
Dave Love <fx@gnu.org>
parents: 33304
diff changeset
251 default-enable-multibyte-characters))
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
252 (mm-encode-coding-region (point) (point-max) method)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 ;; Hm.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 (t)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (goto-char (point-max)))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256
35985
b9c371244b90 (rfc2047-fold-region): Don't forward-char at EOB.
Dave Love <fx@gnu.org>
parents: 35838
diff changeset
257 ;; Fixme: This, and the require below may not be the Right Thing, but
b9c371244b90 (rfc2047-fold-region): Don't forward-char at EOB.
Dave Love <fx@gnu.org>
parents: 35838
diff changeset
258 ;; should be safe just before release. -- fx 2001-02-08
b9c371244b90 (rfc2047-fold-region): Don't forward-char at EOB.
Dave Love <fx@gnu.org>
parents: 35838
diff changeset
259 (eval-when-compile (defvar message-posting-charset))
b9c371244b90 (rfc2047-fold-region): Don't forward-char at EOB.
Dave Love <fx@gnu.org>
parents: 35838
diff changeset
260
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
261 (defun rfc2047-encodable-p ()
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
262 "Return non-nil if any characters in current buffer need encoding in headers.
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
263 The buffer may be narrowed."
35985
b9c371244b90 (rfc2047-fold-region): Don't forward-char at EOB.
Dave Love <fx@gnu.org>
parents: 35838
diff changeset
264 (require 'message) ; for message-posting-charset
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 (let ((charsets
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
266 (mm-find-mime-charset-region (point-min) (point-max))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
267 (and charsets
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
268 (not (equal charsets (list (car message-posting-charset)))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
270 ;; Use this syntax table when parsing into regions that may need
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
271 ;; encoding. Double quotes are string delimiters, backslash is
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
272 ;; character quoting, and all other RFC 2822 special characters are
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
273 ;; treated as punctuation so we can use forward-sexp/forward-word to
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
274 ;; skip to the end of regions appropriately. Nb. ietf-drums does
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
275 ;; things differently.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
276 (defconst rfc2047-syntax-table
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
277 ;; (make-char-table 'syntax-table '(2)) only works in Emacs.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
278 (let ((table (make-syntax-table)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
279 ;; The following is done to work for setting all elements of the table
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
280 ;; in Emacs 21 and 22 and XEmacs; it appears to be the cleanest way.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
281 ;; Play safe and don't assume the form of the word syntax entry --
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
282 ;; copy it from ?a.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
283 (if (fboundp 'set-char-table-range) ; Emacs
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
284 (funcall (intern "set-char-table-range")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
285 table t (aref (standard-syntax-table) ?a))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
286 (if (fboundp 'put-char-table)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
287 (if (fboundp 'get-char-table) ; warning avoidance
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
288 (put-char-table t (get-char-table ?a (standard-syntax-table))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
289 table))))
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
290 (modify-syntax-entry ?\\ "\\" table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
291 (modify-syntax-entry ?\" "\"" table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
292 (modify-syntax-entry ?\( "." table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
293 (modify-syntax-entry ?\) "." table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
294 (modify-syntax-entry ?\< "." table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
295 (modify-syntax-entry ?\> "." table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
296 (modify-syntax-entry ?\[ "." table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
297 (modify-syntax-entry ?\] "." table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
298 (modify-syntax-entry ?: "." table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
299 (modify-syntax-entry ?\; "." table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
300 (modify-syntax-entry ?, "." table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
301 (modify-syntax-entry ?@ "." table)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
302 table))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (defun rfc2047-encode-region (b e)
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
305 "Encode words in region B to E that need encoding.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
306 By default, the region is treated as containing RFC2822 addresses.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
307 Dynamically bind `rfc2047-encoding-type' to change that."
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
308 (save-restriction
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
309 (narrow-to-region b e)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
310 (if (eq 'mime rfc2047-encoding-type)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
311 ;; Simple case. Treat as single word after any initial ASCII
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
312 ;; part and before any tailing ASCII part. The leading ASCII
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
313 ;; is relevant for instance in Subject headers with `Re:' for
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
314 ;; interoperability with non-MIME clients, and we might as
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
315 ;; well avoid the tail too.
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
316 (progn
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
317 (goto-char (point-min))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
318 ;; Does it need encoding?
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
319 (skip-chars-forward "\000-\177")
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
320 (unless (eobp)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
321 (skip-chars-backward "^ \n") ; beginning of space-delimited word
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
322 (rfc2047-encode (point) (progn
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
323 (goto-char e)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
324 (skip-chars-backward "\000-\177")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
325 (skip-chars-forward "^ \n")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
326 ;; end of space-delimited word
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
327 (point)))))
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
328 ;; `address-mime' case -- take care of quoted words, comments.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
329 (with-syntax-table rfc2047-syntax-table
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
330 (let ((start) ; start of current token
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
331 end ; end of current token
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
332 ;; Whether there's an encoded word before the current
50881
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
333 ;; token, either immediately or separated by space.
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
334 last-encoded)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
335 (goto-char (point-min))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
336 (condition-case nil ; in case of unbalanced quotes
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
337 ;; Look for rfc2822-style: sequences of atoms, quoted
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
338 ;; strings, specials, whitespace. (Specials mustn't be
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
339 ;; encoded.)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
340 (while (not (eobp))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
341 (setq start (point))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
342 ;; Skip whitespace.
50881
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
343 (unless (= 0 (skip-chars-forward " \t\n"))
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
344 (setq start (point)))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
345 (cond
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
346 ((not (char-after))) ; eob
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
347 ;; else token start
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
348 ((eq ?\" (char-syntax (char-after)))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
349 ;; Quoted word.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
350 (forward-sexp)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
351 (setq end (point))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
352 ;; Does it need encoding?
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
353 (goto-char start)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
354 (skip-chars-forward "\000-\177" end)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
355 (if (= end (point))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
356 (setq last-encoded nil)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
357 ;; It needs encoding. Strip the quotes first,
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
358 ;; since encoded words can't occur in quotes.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
359 (goto-char end)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
360 (delete-backward-char 1)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
361 (goto-char start)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
362 (delete-char 1)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
363 (when last-encoded
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
364 ;; There was a preceding quoted word. We need
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
365 ;; to include any separating whitespace in this
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
366 ;; word to avoid it getting lost.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
367 (skip-chars-backward " \t")
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
368 ;; A space is needed between the encoded words.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
369 (insert ? )
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
370 (setq start (point)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
371 end (1+ end)))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
372 ;; Adjust the end position for the deleted quotes.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
373 (rfc2047-encode start (- end 2))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
374 (setq last-encoded t))) ; record that it was encoded
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
375 ((eq ?. (char-syntax (char-after)))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
376 ;; Skip other delimiters, but record that they've
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
377 ;; potentially separated quoted words.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
378 (forward-char)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
379 (setq last-encoded nil))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
380 (t ; normal token/whitespace sequence
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
381 ;; Find the end.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
382 (forward-word 1)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
383 (skip-chars-backward " \t")
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
384 (setq end (point))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
385 ;; Deal with encoding and leading space as for
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
386 ;; quoted words.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
387 (goto-char start)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
388 (skip-chars-forward "\000-\177" end)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
389 (if (= end (point))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
390 (setq last-encoded nil)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
391 (when last-encoded
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
392 (goto-char start)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
393 (skip-chars-backward " \t")
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
394 (insert ? )
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
395 (setq start (point)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
396 end (1+ end)))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
397 (rfc2047-encode start end)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
398 (setq last-encoded t)))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
399 (error
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
400 (error "Invalid data for rfc2047 encoding: %s"
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
401 (buffer-substring b e)))))))
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
402 (rfc2047-fold-region b (point))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (defun rfc2047-encode-string (string)
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
405 "Encode words in STRING.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
406 By default, the string is treated as containing addresses (see
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
407 `rfc2047-encoding-type')."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (with-temp-buffer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (insert string)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (rfc2047-encode-region (point-min) (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (buffer-string)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
413 (defun rfc2047-encode (b e)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
414 "Encode the word(s) in the region B to E.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
415 By default, the region is treated as containing addresses (see
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
416 `rfc2047-encoding-type')."
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
417 (let* ((mime-charset (mm-find-mime-charset-region b e))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
418 (cs (if (> (length mime-charset) 1)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
419 ;; Fixme: Instead of this, try to break region into
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
420 ;; parts that can be encoded separately.
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
421 (error "Can't rfc2047-encode `%s'"
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
422 (buffer-substring b e))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
423 (setq mime-charset (car mime-charset))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
424 (mm-charset-to-coding-system mime-charset)))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
425 ;; Fixme: Better, calculate the number of non-ASCII
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
426 ;; characters, at least for 8-bit charsets.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
427 (encoding (or (cdr (assq mime-charset
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 rfc2047-charset-encoding-alist))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
429 ;; For the charsets that don't have a preferred
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
430 ;; encoding, choose the one that's shorter.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
431 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
432 (narrow-to-region b e)
57243
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
433 (if (eq (rfc2047-qp-or-base64) 'base64)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
434 'B
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
435 'Q))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (start (concat
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 "=?" (downcase (symbol-name mime-charset)) "?"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (downcase (symbol-name encoding)) "?"))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
439 (factor (case mime-charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
440 ((iso-8859-5 iso-8859-7 iso-8859-8 koi8-r) 1)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
441 ((big5 gb2312 euc-kr) 2)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
442 (utf-8 4)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
443 (t 8)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
444 (pre (- b (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
445 (widen)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
446 (rfc2047-point-at-bol))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
447 ;; encoded-words must not be longer than 75 characters,
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
448 ;; including charset, encoding etc. This leaves us with
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
449 ;; 75 - (length start) - 2 - 2 characters. The last 2 is for
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
450 ;; possible base64 padding. In the worst case (iso-2022-*)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
451 ;; each character expands to 8 bytes which is expanded by a
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
452 ;; factor of 4/3 by base64 encoding.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
453 (length (floor (- 75 (length start) 4) (* factor (/ 4.0 3.0))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
454 ;; Limit line length to 76 characters.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
455 (length1 (max 1 (floor (- 76 (length start) 4 pre)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
456 (* factor (/ 4.0 3.0)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (first t))
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
458 (if mime-charset
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
459 (save-restriction
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
460 (narrow-to-region b e)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
461 (when (eq encoding 'B)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
462 ;; break into lines before encoding
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
463 (goto-char (point-min))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
464 (while (not (eobp))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
465 (if first
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
466 (progn
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
467 (goto-char (min (point-max) (+ length1 (point))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
468 (setq first nil))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
469 (goto-char (min (point-max) (+ length (point)))))
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
470 (unless (eobp)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
471 (insert ?\n)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
472 (setq first t))
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
473 (if (and (mm-multibyte-p)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
474 (mm-coding-system-p cs))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
475 (mm-encode-coding-region (point-min) (point-max) cs))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
476 (funcall (cdr (assq encoding rfc2047-encoding-function-alist))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
477 (point-min) (point-max))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
478 (goto-char (point-min))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
479 (while (not (eobp))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
480 (unless first
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
481 (insert ? ))
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
482 (setq first nil)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
483 (insert start)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
484 (end-of-line)
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
485 (insert "?=")
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
486 (forward-line 1))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
488 (defun rfc2047-fold-field ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
489 "Fold the current header field."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
490 (save-excursion
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
491 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
492 (rfc2047-narrow-to-field)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
493 (rfc2047-fold-region (point-min) (point-max)))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
494
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 (defun rfc2047-fold-region (b e)
35985
b9c371244b90 (rfc2047-fold-region): Don't forward-char at EOB.
Dave Love <fx@gnu.org>
parents: 35838
diff changeset
496 "Fold long lines in region B to E."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 (narrow-to-region b e)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 (goto-char (point-min))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
500 (let ((break nil)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
501 (qword-break nil)
50881
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
502 (first t)
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
503 (bol (save-restriction
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
504 (widen)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
505 (rfc2047-point-at-bol))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (while (not (eobp))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
507 (when (and (or break qword-break)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
508 (> (- (point) bol) 76))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
509 (goto-char (or break qword-break))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
510 (setq break nil
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
511 qword-break nil)
50881
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
512 (if (looking-at "[ \t]")
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
513 (insert ?\n)
35453
26726eff41ca 2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34674
diff changeset
514 (insert "\n "))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
515 (setq bol (1- (point)))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
516 ;; Don't break before the first non-LWSP characters.
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
517 (skip-chars-forward " \t")
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
518 (unless (eobp)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
519 (forward-char 1)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (cond
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
521 ((eq (char-after) ?\n)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
522 (forward-char 1)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
523 (setq bol (point)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
524 break nil
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
525 qword-break nil)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
526 (skip-chars-forward " \t")
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
527 (unless (or (eobp) (eq (char-after) ?\n))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
528 (forward-char 1)))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
529 ((eq (char-after) ?\r)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
530 (forward-char 1))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 ((memq (char-after) '(? ?\t))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
532 (skip-chars-forward " \t")
50881
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
533 (if first
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
534 ;; Don't break just after the header name.
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
535 (setq first nil)
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
536 (setq break (1- (point)))))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
537 ((not break)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
538 (if (not (looking-at "=\\?[^=]"))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
539 (if (eq (char-after) ?=)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
540 (forward-char 1)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
541 (skip-chars-forward "^ \t\n\r="))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
542 ;; Don't break at the start of the field.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
543 (unless (= (point) b)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
544 (setq qword-break (point)))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
545 (skip-chars-forward "^ \t\n\r")))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
546 (t
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
547 (skip-chars-forward "^ \t\n\r"))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
548 (when (and (or break qword-break)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
549 (> (- (point) bol) 76))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
550 (goto-char (or break qword-break))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
551 (setq break nil
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
552 qword-break nil)
50881
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
553 (if (looking-at "[ \t]")
47945
3915f2c7691e (message-posting-charset): defvar when compiling.
Dave Love <fx@gnu.org>
parents: 38413
diff changeset
554 (insert ?\n)
35453
26726eff41ca 2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 34674
diff changeset
555 (insert "\n "))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
556 (setq bol (1- (point)))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
557 ;; Don't break before the first non-LWSP characters.
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
558 (skip-chars-forward " \t")
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
559 (unless (eobp)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
560 (forward-char 1))))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
561
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
562 (defun rfc2047-unfold-field ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
563 "Fold the current line."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
564 (save-excursion
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
565 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
566 (rfc2047-narrow-to-field)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
567 (rfc2047-unfold-region (point-min) (point-max)))))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
568
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
569 (defun rfc2047-unfold-region (b e)
35985
b9c371244b90 (rfc2047-fold-region): Don't forward-char at EOB.
Dave Love <fx@gnu.org>
parents: 35838
diff changeset
570 "Unfold lines in region B to E."
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
571 (save-restriction
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
572 (narrow-to-region b e)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
573 (goto-char (point-min))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
574 (let ((bol (save-restriction
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
575 (widen)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
576 (rfc2047-point-at-bol)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
577 (eol (rfc2047-point-at-eol)))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
578 (forward-line 1)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
579 (while (not (eobp))
50881
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
580 (if (and (looking-at "[ \t]")
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
581 (< (- (rfc2047-point-at-eol) bol) 76))
50881
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
582 (delete-region eol (progn
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
583 (goto-char eol)
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
584 (skip-chars-forward "\r\n")
b042c57894f8 (rfc2047-header-encoding-alist): Add Followup-To.
Dave Love <fx@gnu.org>
parents: 47951
diff changeset
585 (point)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
586 (setq bol (rfc2047-point-at-bol)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
587 (setq eol (rfc2047-point-at-eol))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
588 (forward-line 1)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 (defun rfc2047-b-encode-region (b e)
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
591 "Base64-encode the header contained in region B to E."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 (narrow-to-region (goto-char b) e)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 (while (not (eobp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 (base64-encode-region (point) (progn (end-of-line) (point)) t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 (if (and (bolp) (eolp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 (delete-backward-char 1))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 (forward-line))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 (defun rfc2047-q-encode-region (b e)
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
601 "Quoted-printable-encode the header in region B to E."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604 (narrow-to-region (goto-char b) e)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
605 (let ((bol (save-restriction
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
606 (widen)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
607 (rfc2047-point-at-bol))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
608 (quoted-printable-encode-region
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
609 b e nil
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
610 ;; = (\075), _ (\137), ? (\077) are used in the encoded word.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
611 ;; Avoid using 8bit characters.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
612 ;; This list excludes `especials' (see the RFC2047 syntax),
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
613 ;; meaning that some characters in non-structured fields will
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
614 ;; get encoded when they con't need to be. The following is
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
615 ;; what it used to be.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
616 ;;; ;; Equivalent to "^\000-\007\011\013\015-\037\200-\377=_?"
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
617 ;;; "\010\012\014\040-\074\076\100-\136\140-\177")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
618 "-\b\n\f !#-'*+0-9A-Z\\^`-~\d")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
619 (subst-char-in-region (point-min) (point-max) ? ?_)
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
620 ;; The size of QP encapsulation is about 20, so set limit to
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
621 ;; 56=76-20.
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
622 (unless (< (- (point-max) (point-min)) 56)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
623 ;; Don't break if it could fit in one line.
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
624 ;; Let rfc2047-encode-region break it later.
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
625 (goto-char (1+ (point-min)))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
626 (while (and (not (bobp)) (not (eobp)))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
627 (goto-char (min (point-max) (+ 56 bol)))
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
628 (search-backward "=" (- (point) 2) t)
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
629 (unless (or (bobp) (eobp))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
630 (insert ?\n)
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
631 (setq bol (point)))))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 ;;; Functions for decoding RFC2047 messages
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
637 (eval-and-compile
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
638 (defconst rfc2047-encoded-word-regexp
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
639 "=\\?\\([^][\000-\040()<>@,\;:\\\"/?.=]+\\)\\?\\(B\\|Q\\)\
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
640 \\?\\([!->@-~ +]*\\)\\?="))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
641
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
642 ;; Fixme: This should decode in place, not cons intermediate strings.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
643 ;; Also check whether it needs to worry about delimiting fields like
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
644 ;; encoding.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
645
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
646 ;; In fact it's reported that (invalid) encoding of mailboxes in
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
647 ;; addr-specs is in use, so delimiting fields might help. Probably
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
648 ;; not decoding a word which isn't properly delimited is good enough
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
649 ;; and worthwhile (is it more correct or not?), e.g. something like
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
650 ;; `=?iso-8859-1?q?foo?=@'.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
652 (defun rfc2047-decode-region (start end)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
653 "Decode MIME-encoded words in region between START and END."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654 (interactive "r")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
655 (let ((case-fold-search t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656 b e)
47951
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
657 (save-excursion
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
658 (save-restriction
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
659 (narrow-to-region start end)
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
660 (goto-char (point-min))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
661 ;; Remove whitespace between encoded words.
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
662 (while (re-search-forward
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
663 (eval-when-compile
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
664 (concat "\\(" rfc2047-encoded-word-regexp "\\)"
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
665 "\\(\n?[ \t]\\)+"
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
666 "\\(" rfc2047-encoded-word-regexp "\\)"))
47951
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
667 nil t)
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
668 (delete-region (goto-char (match-end 1)) (match-beginning 6)))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
669 ;; Decode the encoded words.
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
670 (setq b (goto-char (point-min)))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
671 (while (re-search-forward rfc2047-encoded-word-regexp nil t)
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
672 (setq e (match-beginning 0))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
673 (insert (rfc2047-parse-and-decode
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
674 (prog1
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
675 (match-string 0)
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
676 (delete-region (match-beginning 0) (match-end 0)))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
677 ;; Remove newlines between decoded words, though such things
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
678 ;; essentially must not be there.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
679 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
680 (narrow-to-region e (point))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
681 (goto-char e)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
682 (while (re-search-forward "[\n\r]+" nil t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
683 (replace-match " "))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
684 (goto-char (point-max)))
47951
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
685 (when (and (mm-multibyte-p)
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
686 mail-parse-charset
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
687 (not (eq mail-parse-charset 'us-ascii))
47951
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
688 (not (eq mail-parse-charset 'gnus-decoded)))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
689 (mm-decode-coding-region b e mail-parse-charset))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
690 (setq b (point)))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
691 (when (and (mm-multibyte-p)
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
692 mail-parse-charset
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
693 (not (eq mail-parse-charset 'us-ascii))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
694 (not (eq mail-parse-charset 'gnus-decoded)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
695 (mm-decode-coding-region b (point-max) mail-parse-charset))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697 (defun rfc2047-decode-string (string)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698 "Decode the quoted-printable-encoded STRING and return the results."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 (let ((m (mm-multibyte-p)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
700 (if (string-match "=\\?" string)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
701 (with-temp-buffer
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
702 ;; Fixme: This logic is wrong, but seems to be required by
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
703 ;; Gnus summary buffer generation. The value of `m' depends
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
704 ;; on the current buffer, not global multibyteness or that
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
705 ;; of the string. Also the string returned should always be
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
706 ;; multibyte in a multibyte session, i.e. the buffer should
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
707 ;; be multibyte before `buffer-string' is called.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
708 (when m
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
709 (mm-enable-multibyte))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
710 (insert string)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
711 (inline
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
712 (rfc2047-decode-region (point-min) (point-max)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
713 (buffer-string))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
714 ;; Fixme: As above, `m' here is inappropriate.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
715 (if (and m
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
716 mail-parse-charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
717 (not (eq mail-parse-charset 'us-ascii))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
718 (not (eq mail-parse-charset 'gnus-decoded)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
719 (mm-decode-coding-string string mail-parse-charset)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
720 (mm-string-as-multibyte string)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721
47951
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
722 (defun rfc2047-parse-and-decode (word)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 "Decode WORD and return it if it is an encoded word.
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
724 Return WORD if it is not not an encoded word or if the charset isn't
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
725 decodable."
47951
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
726 (if (not (string-match rfc2047-encoded-word-regexp word))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
727 word
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
728 (or
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
729 (condition-case nil
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
730 (rfc2047-decode
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
731 (match-string 1 word)
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
732 (upcase (match-string 2 word))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
733 (match-string 3 word))
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
734 (error word))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
735 word))) ; un-decodable
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
736
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
737 (defun rfc2047-pad-base64 (string)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
738 "Pad STRING to quartets."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
739 ;; Be more liberal to accept buggy base64 strings. If
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
740 ;; base64-decode-string accepts buggy strings, this function could
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
741 ;; be aliased to identity.
57243
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
742 (if (= 0 (mod (length string) 4))
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
743 string
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
744 (when (string-match "=+$" string)
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
745 (setq string (substring string 0 (match-beginning 0))))
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
746 (case (mod (length string) 4)
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
747 (0 string)
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
748 (1 string) ;; Error, don't pad it.
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
749 (2 (concat string "=="))
c5e16264557d Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
750 (3 (concat string "=")))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751
47951
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
752 (defun rfc2047-decode (charset encoding string)
9cd6016af581 Revert decoding changes temporarily.
Dave Love <fx@gnu.org>
parents: 47945
diff changeset
753 "Decode STRING from the given MIME CHARSET in the given ENCODING.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754 Valid ENCODINGs are \"B\" and \"Q\".
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
755 If your Emacs implementation can't decode CHARSET, return nil."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
756 (if (stringp charset)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
757 (setq charset (intern (downcase charset))))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
758 (if (or (not charset)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759 (eq 'gnus-all mail-parse-ignored-charsets)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
760 (memq 'gnus-all mail-parse-ignored-charsets)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761 (memq charset mail-parse-ignored-charsets))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762 (setq charset mail-parse-charset))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763 (let ((cs (mm-charset-to-coding-system charset)))
33304
d401dfab680a Require gnus-util.
Dave Love <fx@gnu.org>
parents: 33127
diff changeset
764 (if (and (not cs) charset
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
765 (listp mail-parse-ignored-charsets)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
766 (memq 'gnus-unknown mail-parse-ignored-charsets))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
767 (setq cs (mm-charset-to-coding-system mail-parse-charset)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768 (when cs
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 (when (and (eq cs 'ascii)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770 mail-parse-charset)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771 (setq cs mail-parse-charset))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
772 (mm-decode-coding-string
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
773 (cond
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
774 ((equal "B" encoding)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
775 (base64-decode-string
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
776 (rfc2047-pad-base64 string)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
777 ((equal "Q" encoding)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
778 (quoted-printable-decode-string
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
779 (mm-replace-chars-in-string string ?_ ? )))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
780 (t (error "Invalid encoding: %s" encoding)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55411
diff changeset
781 cs))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
782
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
783 (provide 'rfc2047)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50881
diff changeset
785 ;;; arch-tag: a07fe3d4-22b5-4c4a-bd89-b1f82d5d36f6
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786 ;;; rfc2047.el ends here