annotate lisp/tm/tm-def.el @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents 49a24b4fd526
children 8fc7fe29b841
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1 ;;; tm-def.el --- definition module for tm
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
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>
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
6 ;; Version: $Id: tm-def.el,v 1.4 1997/02/02 05:06:19 steve Exp $
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
7 ;; Keywords: mail, news, MIME, multimedia, definition
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 'emu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31 ;;; @ variables
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 (defvar mime/tmp-dir (or (getenv "TM_TMP_DIR") "/tmp/"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
36 (defvar mime/use-multi-frame
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37 (and (>= emacs-major-version 19) window-system))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
38
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39 (defvar mime/find-file-function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
40 (if mime/use-multi-frame
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
41 (function find-file-other-frame)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
42 (function find-file)
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/output-buffer-window-is-shared-with-bbdb t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
46 "*If t, mime/output-buffer window is shared with BBDB window.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
47
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
48
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
49 ;;; @ constants
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
50 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
52 (defconst mime/output-buffer-name "*MIME-out*")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53 (defconst mime/temp-buffer-name " *MIME-temp*")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
54
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 ;;; @ charset and encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
57 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
59 (defvar mime-charset-type-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
60 '((us-ascii 7 nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
61 (iso-8859-1 8 "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62 (iso-8859-2 8 "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63 (iso-8859-3 8 "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64 (iso-8859-4 8 "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
65 (iso-8859-5 8 "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
66 (koi8-r 8 "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
67 (iso-8859-7 8 "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
68 (iso-8859-8 8 "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 (iso-8859-9 8 "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70 (iso-2022-jp 7 "base64")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71 (iso-2022-kr 7 "base64")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72 (euc-kr 8 "base64")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
73 (gb2312 8 "quoted-printable")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
74 (big5 8 "base64")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
75 (iso-2022-jp-2 7 "base64")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
76 (iso-2022-int-1 7 "base64")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
77 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
78
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79 (defun mime/encoding-name (transfer-level &optional not-omit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80 (cond ((> transfer-level 8) "binary")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 ((= transfer-level 8) "8bit")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82 (not-omit "7bit")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
83 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85 (defun mime/make-charset-default-encoding-alist (transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
86 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87 (lambda (charset-type)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 (let ((charset (upcase (symbol-name (car charset-type))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 (type (nth 1 charset-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90 (encoding (nth 2 charset-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 (if (<= type transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93 (cons charset (mime/encoding-name type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
94 (cons charset encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
95 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 mime-charset-type-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
99 ;;; @ button
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
100 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
101
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 (defun tm:set-face-region (b e face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 (let ((overlay (tl:make-overlay b e)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
104 (tl:overlay-put overlay 'face face)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 8
diff changeset
107 (defvar tm:button-face 'bold
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 8
diff changeset
108 "Face used for content-button or URL-button of MIME-Preview buffer.
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 8
diff changeset
109 \[tm-def.el]")
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 8
diff changeset
110
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 8
diff changeset
111 (defvar tm:mouse-face 'highlight
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 8
diff changeset
112 "Face used for MIME-preview buffer mouse highlighting. [tm-def.el]")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
114 (defvar tm:warning-face nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
115 "Face used for invalid encoded-word.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
116
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117 (defun tm:add-button (from to func &optional data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118 "Create a button between FROM and TO with callback FUNC and data DATA."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 (and tm:button-face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
120 (tl:overlay-put (tl:make-overlay from to) 'face tm:button-face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
121 (tl:add-text-properties from to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
122 (append (and tm:mouse-face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123 (list 'mouse-face tm:mouse-face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124 (list 'tm-callback func)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125 (and data (list 'tm-data data))
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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129 (defvar tm:mother-button-dispatcher nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
130
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
131 (defun tm:button-dispatcher (event)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
132 "Select the button under point."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
133 (interactive "e")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
134 (let (buf point func data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
135 (save-window-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
136 (mouse-set-point event)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
137 (setq buf (current-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
138 point (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
139 func (get-text-property (point) 'tm-callback)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
140 data (get-text-property (point) 'tm-data)
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 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
144 (set-buffer buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
145 (goto-char point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
146 (if func
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147 (apply func data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 (if (fboundp tm:mother-button-dispatcher)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
149 (funcall tm:mother-button-dispatcher event)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151 ))))
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 ;;; @ for URL
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
155 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
156
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
157 (defvar tm:URL-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
158 "\\(http\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*[-a-zA-Z0-9_=#$@~`%&*+|\\/]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
159
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
160 (defvar browse-url-browser-function nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
161
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
162 (defun tm:browse-url (&optional url)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
163 (if (fboundp browse-url-browser-function)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
164 (if url
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
165 (funcall browse-url-browser-function url)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
166 (call-interactively browse-url-browser-function))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
167 (if (fboundp tm:mother-button-dispatcher)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
168 (call-interactively tm:mother-button-dispatcher)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
169 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
170 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
171
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
172
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
173 ;;; @ definitions about MIME
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
174 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
175
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
176 (defconst mime/tspecials "][\000-\040()<>@,\;:\\\"/?.=")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
177 (defconst mime/token-regexp (concat "[^" mime/tspecials "]+"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
178 (defconst mime/charset-regexp mime/token-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
179
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
180 (defconst mime/content-type-subtype-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
181 (concat mime/token-regexp "/" mime/token-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
182
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
183 (defconst mime/disposition-type-regexp mime/token-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
184
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
185
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
186 ;;; @@ Base64
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
187 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
188
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 10
diff changeset
189 (defconst base64-token-regexp "[A-Za-z0-9+/]")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
190 (defconst base64-token-padding-regexp "[A-Za-z0-9+/=]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
191
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
192 (defconst mime/B-encoded-text-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
193 (concat "\\(\\("
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
194 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
195 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
196 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
197 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
198 "\\)*"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
199 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
200 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
201 base64-token-padding-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
202 base64-token-padding-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
203 "\\)"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
204
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
205 (defconst mime/B-encoding-and-encoded-text-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
206 (concat "\\(B\\)\\?" mime/B-encoded-text-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
207
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
208
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
209 ;;; @@ Quoted-Printable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
210 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
211
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
212 (defconst quoted-printable-hex-chars "0123456789ABCDEF")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
213 (defconst quoted-printable-octet-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
214 (concat "=[" quoted-printable-hex-chars
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
215 "][" quoted-printable-hex-chars "]"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
216
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
217 (defconst mime/Q-encoded-text-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
218 (concat "\\([^=?]\\|" quoted-printable-octet-regexp "\\)+"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
219 (defconst mime/Q-encoding-and-encoded-text-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
220 (concat "\\(Q\\)\\?" mime/Q-encoded-text-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
221
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
222
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223 ;;; @ rot13-47
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
225 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
226 ;; modified by tower@prep Nov 86
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
227 ;; gnus-caesar-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
229 (defun tm:caesar-region (&optional n)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
230 "Caesar rotation of region by N, default 13, for decrypting netnews.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
231 ROT47 will be performed for Japanese text in any case."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
232 (interactive (if current-prefix-arg ; Was there a prefix arg?
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
233 (list (prefix-numeric-value current-prefix-arg))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
234 (list nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
235 (cond ((not (numberp n)) (setq n 13))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
236 (t (setq n (mod n 26)))) ;canonicalize N
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
237 (if (not (zerop n)) ; no action needed for a rot of 0
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
238 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
239 (if (or (not (boundp 'caesar-translate-table))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
240 (/= (aref caesar-translate-table ?a) (+ ?a n)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241 (let ((i 0) (lower "abcdefghijklmnopqrstuvwxyz") upper)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 (message "Building caesar-translate-table...")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 (setq caesar-translate-table (make-vector 256 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244 (while (< i 256)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245 (aset caesar-translate-table i i)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
246 (setq i (1+ i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 (setq lower (concat lower lower) upper (upcase lower) i 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248 (while (< i 26)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 (setq i (1+ i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 ;; ROT47 for Japanese text.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 ;; Thanks to ichikawa@flab.fujitsu.junet.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 (setq i 161)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 (let ((t1 (logior ?O 128))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256 (t2 (logior ?! 128))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257 (t3 (logior ?~ 128)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
258 (while (< i 256)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
259 (aset caesar-translate-table i
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
260 (let ((v (aref caesar-translate-table i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
261 (if (<= v t1) (if (< v t2) v (+ v 47))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
262 (if (<= v t3) (- v 47) v))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
263 (setq i (1+ i))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
264 (message "Building caesar-translate-table...done")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
265 (let ((from (region-beginning))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
266 (to (region-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
267 (i 0) str len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
268 (setq str (buffer-substring from to))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
269 (setq len (length str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
270 (while (< i len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
271 (aset str i (aref caesar-translate-table (aref str i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
272 (setq i (1+ i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
273 (goto-char from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
274 (delete-region from to)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
275 (insert str)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
276
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
277
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
278 ;;; @ field
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
279 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
280
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
281 (defun tm:set-fields (sym field-list &optional regexp-sym)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
282 (or regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
283 (setq regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
284 (let ((name (symbol-name sym)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
285 (intern
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
286 (concat (if (string-match "\\(.*\\)-list" name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
287 (substring name 0 (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
288 name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
289 "-regexp")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
290 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
291 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
292 (set sym field-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
293 (set regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
294 (concat "^" (apply (function regexp-or) field-list) ":"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
295 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
296
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
297 (defun tm:add-fields (sym field-list &optional regexp-sym)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
298 (or regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
299 (setq regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
300 (let ((name (symbol-name sym)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
301 (intern
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
302 (concat (if (string-match "\\(.*\\)-list" name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
303 (substring name 0 (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
304 name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
305 "-regexp")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
306 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
307 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
308 (let ((fields (eval sym)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
309 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
310 (lambda (field)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
311 (or (member field fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
312 (setq fields (cons field fields))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
313 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
314 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
315 (reverse field-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
316 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
317 (set regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
318 (concat "^" (apply (function regexp-or) fields) ":"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
319 (set sym fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
320 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
321
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
322 (defun tm:delete-fields (sym field-list &optional regexp-sym)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
323 (or regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
324 (setq regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
325 (let ((name (symbol-name sym)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
326 (intern
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
327 (concat (if (string-match "\\(.*\\)-list" name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
328 (substring name 0 (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
329 name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
330 "-regexp")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
331 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
332 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
333 (let ((fields (eval sym)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
334 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
335 (lambda (field)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
336 (setq fields (delete field fields))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
337 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
338 field-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
339 (set regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
340 (concat "^" (apply (function regexp-or) fields) ":"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
341 (set sym fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
342 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
343
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
344
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
345 ;;; @ end
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 (provide 'tm-def)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
349
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
350 ;;; tm-def.el ends here