annotate lisp/tm/tm-ew-e.el @ 136:b980b6286996 r20-2b2

Import from CVS: tag r20-2b2
author cvs
date Mon, 13 Aug 2007 09:31:12 +0200
parents 0d2f883870bc
children 3bb7ccffb0c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1 ;;; tm-ew-e.el --- RFC 2047 based encoded-word encoder for GNU Emacs
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 74
diff changeset
3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 74
diff changeset
6 ;; Version: $Revision: 1.2 $
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
7 ;; Keywords: encoded-word, MIME, multilingual, header, mail, news
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
8
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
9 ;; This file is part of tm (Tools for MIME).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
10
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
11 ;; This program is free software; you can redistribute it and/or
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
12 ;; modify it under the terms of the GNU General Public License as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
13 ;; published by the Free Software Foundation; either version 2, or (at
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
14 ;; your option) any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
15
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
16 ;; This program is distributed in the hope that it will be useful, but
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
19 ;; General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
20
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
25
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
26 ;;; Code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
27
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
28 (require 'mel)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29 (require 'std11)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30 (require 'tm-def)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31 (require 'tl-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
32
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
33
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
34 ;;; @ version
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
36
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37 (defconst tm-ew-e/RCS-ID
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 74
diff changeset
38 "$Id: tm-ew-e.el,v 1.2 1997/02/15 22:21:29 steve Exp $")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39 (defconst mime-eword/encoder-version (get-version-string tm-ew-e/RCS-ID))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
40
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
41
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
42 ;;; @ variables
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
43 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
44
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
45 (defvar mime/field-encoding-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
46 (if (boundp 'mime/no-encoding-header-fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
47 (nconc
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
48 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
49 (lambda (field-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
50 (cons field-name 'default-mime-charset)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
52 mime/no-encoding-header-fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53 '((t . mime))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
54 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55 '(("X-Nsubject" . iso-2022-jp-2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 ("Newsgroups" . nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
57 (t . mime)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
59 "*Alist to specify field encoding method.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
60 Its key is field-name, value is encoding method.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
61
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62 If method is `mime', this field will be encoded into MIME format.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64 If method is a MIME-charset, this field will be encoded as the charset
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
65 when it must be convert into network-code.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
66
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
67 If method is `default-mime-charset', this field will be encoded as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
68 variable `default-mime-charset' when it must be convert into
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 network-code.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71 If method is nil, this field will not be encoded. [tm-ew-e.el]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
73 (defvar mime/generate-X-Nsubject
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
74 (and (boundp 'mime/use-X-Nsubject)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
75 mime/use-X-Nsubject)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
76 "*If it is not nil, X-Nsubject field is generated
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
77 when Subject field is encoded by `mime/encode-message-header'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
78 \[tm-ew-e.el]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80 (defvar mime-eword/charset-encoding-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 '((us-ascii . nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82 (iso-8859-1 . "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
83 (iso-8859-2 . "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84 (iso-8859-3 . "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85 (iso-8859-4 . "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
86 (iso-8859-5 . "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87 (koi8-r . "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 (iso-8859-7 . "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 (iso-8859-8 . "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90 (iso-8859-9 . "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 (iso-2022-jp . "B")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 (iso-2022-kr . "B")
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
93 (gb2312 . "B")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
94 (cn-gb . "B")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
95 (cn-gb-2312 . "B")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 (euc-kr . "B")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97 (iso-2022-jp-2 . "B")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98 (iso-2022-int-1 . "B")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
99 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
100
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
101
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 ;;; @ encoded-text encoder
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
104
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 (defun tm-eword::encode-encoded-text (charset encoding string &optional mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106 (let ((text
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107 (cond ((string= encoding "B")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 (base64-encode-string string))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
109 ((string= encoding "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110 (q-encoding-encode-string string mode))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 (if text
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114 (concat "=?" (upcase (symbol-name charset)) "?"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115 encoding "?" text "?=")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 ;;; @ leading char
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
120 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
121
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
122 (defun tm-eword::char-type (chr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123 (if (or (= chr 32)(= chr ?\t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125 (char-charset chr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128 (defun tm-eword::parse-lc-word (str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129 (let* ((chr (sref str 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
130 (lc (tm-eword::char-type chr))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
131 (i (char-length chr))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
132 (len (length str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
133 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
134 (while (and (< i len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
135 (setq chr (sref str i))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
136 (eq lc (tm-eword::char-type chr))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
137 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
138 (setq i (+ i (char-length chr)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
139 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
140 (cons (cons lc (substring str 0 i)) (substring str i))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
141 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
142
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
143 (defun tm-eword::split-to-lc-words (str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
144 (let (ret dest)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
145 (while (and (not (string= str ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
146 (setq ret (tm-eword::parse-lc-word str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 (setq dest (cons (car ret) dest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
149 (setq str (cdr ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151 (reverse dest)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
152 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
153
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
154
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
155 ;;; @ word
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
156 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
157
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
158 (defun tm-eword::parse-word (lcwl)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
159 (let* ((lcw (car lcwl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
160 (lc (car lcw))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
161 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
162 (if (null lc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
163 lcwl
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
164 (let ((lcl (list lc))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
165 (str (cdr lcw))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
166 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
167 (catch 'tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
168 (while (setq lcwl (cdr lcwl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
169 (setq lcw (car lcwl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
170 (setq lc (car lcw))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
171 (if (null lc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
172 (throw 'tag nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
173 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
174 (if (not (memq lc lcl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
175 (setq lcl (cons lc lcl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
176 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
177 (setq str (concat str (cdr lcw)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
178 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
179 (cons (cons lcl str) lcwl)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
180 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
181
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
182 (defun tm-eword::lc-words-to-words (lcwl)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
183 (let (ret dest)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
184 (while (setq ret (tm-eword::parse-word lcwl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
185 (setq dest (cons (car ret) dest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
186 (setq lcwl (cdr ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
187 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
188 (reverse dest)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
189 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
190
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
191
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
192 ;;; @ rule
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
193 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
194
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
195 (defmacro tm-eword::make-rword (text charset encoding type)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
196 (` (list (, text)(, charset)(, encoding)(, type))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
197 (defmacro tm-eword::rword-text (rword)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
198 (` (car (, rword))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
199 (defmacro tm-eword::rword-charset (rword)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
200 (` (car (cdr (, rword)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
201 (defmacro tm-eword::rword-encoding (rword)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
202 (` (car (cdr (cdr (, rword))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
203 (defmacro tm-eword::rword-type (rword)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
204 (` (car (cdr (cdr (cdr (, rword)))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
205
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
206 (defun tm-eword::find-charset-rule (charsets)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
207 (if charsets
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
208 (let* ((charset (charsets-to-mime-charset charsets))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
209 (encoding (cdr (assq charset mime-eword/charset-encoding-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
210 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
211 (list charset encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
212 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
213
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
214 (defun tm-eword::words-to-ruled-words (wl &optional mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
215 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
216 (lambda (word)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
217 (let ((ret (tm-eword::find-charset-rule (car word))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
218 (tm-eword::make-rword (cdr word) (car ret)(nth 1 ret) mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
219 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
220 wl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
221
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
222 (defun tm-eword::space-process (seq)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223 (let (prev a ac b c cc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 (while seq
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
225 (setq b (car seq))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
226 (setq seq (cdr seq))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
227 (setq c (car seq))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 (setq cc (tm-eword::rword-charset c))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
229 (if (null (tm-eword::rword-charset b))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
230 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
231 (setq a (car prev))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
232 (setq ac (tm-eword::rword-charset a))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
233 (if (and (tm-eword::rword-encoding a)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
234 (tm-eword::rword-encoding c))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
235 (cond ((eq ac cc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
236 (setq prev (cons
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
237 (cons (concat (car a)(car b)(car c))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
238 (cdr a))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
239 (cdr prev)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
240 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241 (setq seq (cdr seq))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244 (setq prev (cons
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245 (cons (concat (car a)(car b))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
246 (cdr a))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 (cdr prev)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 (setq prev (cons b prev))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 (setq prev (cons b prev))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 (reverse prev)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257 (defun tm-eword::split-string (str &optional mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
258 (tm-eword::space-process
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
259 (tm-eword::words-to-ruled-words (tm-eword::lc-words-to-words
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
260 (tm-eword::split-to-lc-words str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
261 mode)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
262
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
263
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
264 ;;; @ length
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
265 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
266
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
267 (defun tm-eword::encoded-word-length (rword)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
268 (let ((string (tm-eword::rword-text rword))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
269 (charset (tm-eword::rword-charset rword))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
270 (encoding (tm-eword::rword-encoding rword))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
271 ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
272 (setq ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
273 (cond ((string-equal encoding "B")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
274 (setq string (encode-mime-charset-string string charset))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
275 (base64-encoded-length string)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
276 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
277 ((string-equal encoding "Q")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
278 (setq string (encode-mime-charset-string string charset))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
279 (q-encoding-encoded-length string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
280 (tm-eword::rword-type rword))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
281 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
282 (if ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
283 (cons (+ 7 (length (symbol-name charset)) ret) string)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
284 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
285
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
286
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
287 ;;; @ encode-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
288 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
289
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
290 (defun tm-eword::encode-string-1 (column rwl)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
291 (let* ((rword (car rwl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
292 (ret (tm-eword::encoded-word-length rword))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
293 string len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
294 (if (null ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
295 (cond ((and (setq string (car rword))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
296 (<= (setq len (+ (length string) column)) 76)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
297 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
298 (setq rwl (cdr rwl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
299 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
300 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
301 (setq string "\n ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
302 (setq len 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
303 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
304 (cond ((and (setq len (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
305 (<= (+ column len) 76)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
306 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
307 (setq string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
308 (tm-eword::encode-encoded-text
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
309 (tm-eword::rword-charset rword)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
310 (tm-eword::rword-encoding rword)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
311 (cdr ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
312 (tm-eword::rword-type rword)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
313 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
314 (setq len (+ (length string) column))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
315 (setq rwl (cdr rwl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
316 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
317 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
318 (setq string (car rword))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 74
diff changeset
319 (let* ((p 0) np
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
320 (str "") nstr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
321 (while (and (< p len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
322 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
323 (setq np (+ p (char-length (sref string p))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
324 (setq nstr (substring string 0 np))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
325 (setq ret (tm-eword::encoded-word-length
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
326 (cons nstr (cdr rword))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
327 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
328 (setq nstr (cdr ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
329 (setq len (+ (car ret) column))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
330 (<= len 76)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
331 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
332 (setq str nstr
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
333 p np))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
334 (if (string-equal str "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
335 (setq string "\n "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
336 len 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
337 (setq rwl (cons (cons (substring string p) (cdr rword))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
338 (cdr rwl)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
339 (setq string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
340 (tm-eword::encode-encoded-text
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
341 (tm-eword::rword-charset rword)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
342 (tm-eword::rword-encoding rword)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
343 str
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
344 (tm-eword::rword-type rword)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
345 (setq len (+ (length string) column))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
346 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
347 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
348 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
349 (list string len rwl)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
350 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
351
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
352 (defun tm-eword::encode-rwl (column rwl)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
353 (let (ret dest ps special str ew-f pew-f)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
354 (while rwl
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
355 (setq ew-f (nth 2 (car rwl)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
356 (if (and pew-f ew-f)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
357 (setq rwl (cons '(" ") rwl)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
358 pew-f nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
359 (setq pew-f ew-f)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
360 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
361 (setq ret (tm-eword::encode-string-1 column rwl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
362 (setq str (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
363 (if (eq (elt str 0) ?\n)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
364 (if (eq special ?\()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
365 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
366 (setq dest (concat dest "\n ("))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
367 (setq ret (tm-eword::encode-string-1 2 rwl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
368 (setq str (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
369 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
370 (cond ((eq special 32)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
371 (if (string= str "(")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
372 (setq ps t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
373 (setq dest (concat dest " "))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
374 (setq ps nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
375 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
376 ((eq special ?\()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
377 (if ps
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
378 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
379 (setq dest (concat dest " ("))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
380 (setq ps nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
381 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
382 (setq dest (concat dest "("))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
383 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
384 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
385 (cond ((string= str " ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
386 (setq special 32)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
387 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
388 ((string= str "(")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
389 (setq special ?\()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
390 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
391 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
392 (setq special nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
393 (setq dest (concat dest str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
394 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
395 (setq column (nth 1 ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
396 rwl (nth 2 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
397 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
398 (list dest column)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
399 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
400
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
401 (defun tm-eword::encode-string (column str &optional mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
402 (tm-eword::encode-rwl column (tm-eword::split-string str mode))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
403 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
404
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
405
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
406 ;;; @ converter
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
407 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
408
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
409 (defun tm-eword::phrase-to-rwl (phrase)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
410 (let (token type dest str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
411 (while phrase
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
412 (setq token (car phrase))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
413 (setq type (car token))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
414 (cond ((eq type 'quoted-string)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
415 (setq str (concat "\"" (cdr token) "\""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
416 (setq dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
417 (append dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
418 (list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
419 (let ((ret (tm-eword::find-charset-rule
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
420 (find-non-ascii-charset-string str))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
421 (tm-eword::make-rword
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
422 str (car ret)(nth 1 ret) 'phrase)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
423 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
424 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
425 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
426 ((eq type 'comment)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
427 (setq dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
428 (append dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
429 '(("(" nil nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
430 (tm-eword::words-to-ruled-words
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
431 (tm-eword::lc-words-to-words
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
432 (tm-eword::split-to-lc-words (cdr token)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
433 'comment)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
434 '((")" nil nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
435 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
436 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
437 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
438 (setq dest (append dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
439 (tm-eword::words-to-ruled-words
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
440 (tm-eword::lc-words-to-words
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
441 (tm-eword::split-to-lc-words (cdr token))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
442 ) 'phrase)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
443 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
444 (setq phrase (cdr phrase))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
445 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
446 (tm-eword::space-process dest)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
447 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
448
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
449 (defun tm-eword::phrase-route-addr-to-rwl (phrase-route-addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
450 (if (eq (car phrase-route-addr) 'phrase-route-addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
451 (let ((phrase (nth 1 phrase-route-addr))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
452 (route (nth 2 phrase-route-addr))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
453 dest)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
454 (if (eq (car (car phrase)) 'spaces)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
455 (setq phrase (cdr phrase))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
456 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
457 (setq dest (tm-eword::phrase-to-rwl phrase))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
458 (if dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
459 (setq dest (append dest '((" " nil nil))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
460 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
461 (append
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
462 dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
463 (list (list (concat "<" (std11-addr-to-string route) ">") nil nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
464 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
465
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
466 (defun tm-eword::addr-spec-to-rwl (addr-spec)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
467 (if (eq (car addr-spec) 'addr-spec)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
468 (list (list (std11-addr-to-string (cdr addr-spec)) nil nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
469 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
470
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
471 (defun tm-eword::mailbox-to-rwl (mbox)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
472 (let ((addr (nth 1 mbox))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
473 (comment (nth 2 mbox))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
474 dest)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
475 (setq dest (or (tm-eword::phrase-route-addr-to-rwl addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
476 (tm-eword::addr-spec-to-rwl addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
477 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
478 (if comment
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
479 (setq dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
480 (append dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
481 '((" " nil nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
482 ("(" nil nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
483 (tm-eword::split-string comment 'comment)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
484 '((")" nil nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
485 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
486 dest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
487
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
488 (defun tm-eword::addresses-to-rwl (addresses)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
489 (let ((dest (tm-eword::mailbox-to-rwl (car addresses))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
490 (if dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
491 (while (setq addresses (cdr addresses))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
492 (setq dest (append dest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
493 '(("," nil nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
494 '((" " nil nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
495 (tm-eword::mailbox-to-rwl (car addresses))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
496 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
497 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
498 dest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
499
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
500 (defun tm-eword::encode-address-list (column str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
501 (tm-eword::encode-rwl
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
502 column
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
503 (tm-eword::addresses-to-rwl (std11-parse-addresses-string str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
504 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
505
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
506
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
507 ;;; @ application interfaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
508 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
509
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
510 (defun mime/encode-field (str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
511 (setq str (std11-unfold-string str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
512 (let ((ret (string-match std11-field-head-regexp str)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
513 (or (if ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
514 (let ((field-name (substring str 0 (1- (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
515 (field-body (eliminate-top-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
516 (substring str (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
517 fname)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
518 (if (setq ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
519 (cond ((string-equal field-body "") "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
520 ((member (setq fname (downcase field-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
521 '("reply-to" "from" "sender"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
522 "resent-reply-to" "resent-from"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
523 "resent-sender" "to" "resent-to"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
524 "cc" "resent-cc"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
525 "bcc" "resent-bcc" "dcc")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
526 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
527 (car (tm-eword::encode-address-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
528 (+ (length field-name) 2) field-body))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
529 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
530 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
531 (car (tm-eword::encode-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
532 (+ (length field-name) 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
533 field-body 'text))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
534 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
535 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
536 (concat field-name ": " ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
537 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
538 (car (tm-eword::encode-string 0 str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
539 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
540
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
541 (defun mime/exist-encoded-word-in-subject ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
542 (let ((str (std11-field-body "Subject")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
543 (if (and str (string-match mime/encoded-word-regexp str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
544 str)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
545
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
546 (defun mime/encode-message-header (&optional code-conversion)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
547 (interactive "*")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
548 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
549 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
550 (std11-narrow-to-header mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
551 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
552 (let ((default-cs (mime-charset-to-coding-system default-mime-charset))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
553 beg end field-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
554 (while (re-search-forward std11-field-head-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
555 (setq beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
556 (setq field-name (buffer-substring beg (1- (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
557 (setq end (std11-field-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
558 (and (find-non-ascii-charset-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
559 (let ((ret (or (ASSOC (downcase field-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
560 mime/field-encoding-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
561 :test (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
562 (lambda (str1 str2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
563 (and (stringp str2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
564 (string= str1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
565 (downcase str2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
566 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
567 (assq t mime/field-encoding-method-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
568 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
569 (if ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
570 (let ((method (cdr ret)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
571 (cond ((eq method 'mime)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
572 (let ((field
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
573 (buffer-substring-no-properties beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
574 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
575 (delete-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
576 (insert (mime/encode-field field))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
577 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
578 (code-conversion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
579 (let ((cs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
580 (or (mime-charset-to-coding-system
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
581 method)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
582 default-cs)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
583 (encode-coding-region beg end cs)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
584 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
585 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
586 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
587 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
588 (and mime/generate-X-Nsubject
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
589 (or (std11-field-body "X-Nsubject")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
590 (let ((str (mime/exist-encoded-word-in-subject)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
591 (if str
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
592 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
593 (setq str
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
594 (mime-eword/decode-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
595 (std11-unfold-string str)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
596 (if code-conversion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
597 (setq str
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
598 (encode-mime-charset-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
599 str
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
600 (or (cdr (ASSOC
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
601 "x-nsubject"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
602 mime/field-encoding-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
603 :test
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
604 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
605 (lambda (str1 str2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
606 (and (stringp str2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
607 (string= str1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
608 (downcase str2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
609 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
610 'iso-2022-jp-2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
611 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
612 (insert (concat "\nX-Nsubject: " str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
613 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
614 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
615
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
616 (defun mime-eword/encode-string (str &optional column mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
617 (car (tm-eword::encode-rwl (or column 0) (tm-eword::split-string str mode)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
618 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
619
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
620
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
621 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
622 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
623
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
624 (provide 'tm-ew-e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
625
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
626 ;;; tm-ew-e.el ends here