annotate lisp/tm/tm-def.el @ 8:4b173ad71786 r19-15b5

Import from CVS: tag r19-15b5
author cvs
date Mon, 13 Aug 2007 08:47:35 +0200
parents b82b59fe008d
children 49a24b4fd526
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>
8
4b173ad71786 Import from CVS: tag r19-15b5
cvs
parents: 4
diff changeset
6 ;; Version: $Id: tm-def.el,v 1.2 1996/12/22 00:29:38 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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107 (setq tm:button-face 'bold)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 (setq tm:mouse-face 'highlight)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
109
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110 (defun tm:add-button (from to func &optional data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111 "Create a button between FROM and TO with callback FUNC and data DATA."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 (and tm:button-face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 (tl:overlay-put (tl:make-overlay from to) 'face tm:button-face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114 (tl:add-text-properties from to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115 (append (and tm:mouse-face
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116 (list 'mouse-face tm:mouse-face))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117 (list 'tm-callback func)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118 (and data (list 'tm-data data))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 ))
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 (defvar tm:mother-button-dispatcher nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124 (defun tm:button-dispatcher (event)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125 "Select the button under point."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126 (interactive "e")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127 (let (buf point func data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128 (save-window-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129 (mouse-set-point event)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
130 (setq buf (current-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
131 point (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
132 func (get-text-property (point) 'tm-callback)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
133 data (get-text-property (point) 'tm-data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
134 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
135 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
136 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
137 (set-buffer buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
138 (goto-char point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
139 (if func
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
140 (apply func data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
141 (if (fboundp tm:mother-button-dispatcher)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
142 (funcall tm:mother-button-dispatcher event)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
143 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
144 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
145
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
146
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147 ;;; @ for URL
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
149
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 (defvar tm:URL-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151 "\\(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
152
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
153 (defvar browse-url-browser-function nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
154
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
155 (defun tm:browse-url (&optional url)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
156 (if (fboundp browse-url-browser-function)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
157 (if url
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
158 (funcall browse-url-browser-function url)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
159 (call-interactively browse-url-browser-function))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
160 (if (fboundp tm:mother-button-dispatcher)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
161 (call-interactively tm:mother-button-dispatcher)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
162 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
163 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
164
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
165
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
166 ;;; @ definitions about MIME
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
167 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
168
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
169 (defconst mime/tspecials "][\000-\040()<>@,\;:\\\"/?.=")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
170 (defconst mime/token-regexp (concat "[^" mime/tspecials "]+"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
171 (defconst mime/charset-regexp mime/token-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
172
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
173 (defconst mime/content-type-subtype-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
174 (concat mime/token-regexp "/" mime/token-regexp))
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/disposition-type-regexp mime/token-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
177
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
178
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
179 ;;; @@ Base64
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 (defconst base64-token-regexp "[A-Za-z0-9+/=]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
183 (defconst base64-token-padding-regexp "[A-Za-z0-9+/=]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
184
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
185 (defconst mime/B-encoded-text-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
186 (concat "\\(\\("
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
187 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
188 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
189 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
190 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
191 "\\)*"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
192 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
193 base64-token-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
194 base64-token-padding-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
195 base64-token-padding-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
196 "\\)"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
197
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
198 (defconst mime/B-encoding-and-encoded-text-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
199 (concat "\\(B\\)\\?" mime/B-encoded-text-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
200
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
201
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
202 ;;; @@ Quoted-Printable
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 quoted-printable-hex-chars "0123456789ABCDEF")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
206 (defconst quoted-printable-octet-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
207 (concat "=[" quoted-printable-hex-chars
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
208 "][" quoted-printable-hex-chars "]"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
209
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
210 (defconst mime/Q-encoded-text-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
211 (concat "\\([^=?]\\|" quoted-printable-octet-regexp "\\)+"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
212 (defconst mime/Q-encoding-and-encoded-text-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
213 (concat "\\(Q\\)\\?" mime/Q-encoded-text-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
214
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
215
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
216 ;;; @ rot13-47
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
217 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
218 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
219 ;; modified by tower@prep Nov 86
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
220 ;; gnus-caesar-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
221 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
222 (defun tm:caesar-region (&optional n)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223 "Caesar rotation of region by N, default 13, for decrypting netnews.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 ROT47 will be performed for Japanese text in any case."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
225 (interactive (if current-prefix-arg ; Was there a prefix arg?
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
226 (list (prefix-numeric-value current-prefix-arg))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
227 (list nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 (cond ((not (numberp n)) (setq n 13))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
229 (t (setq n (mod n 26)))) ;canonicalize N
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
230 (if (not (zerop n)) ; no action needed for a rot of 0
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
231 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
232 (if (or (not (boundp 'caesar-translate-table))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
233 (/= (aref caesar-translate-table ?a) (+ ?a n)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
234 (let ((i 0) (lower "abcdefghijklmnopqrstuvwxyz") upper)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
235 (message "Building caesar-translate-table...")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
236 (setq caesar-translate-table (make-vector 256 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
237 (while (< i 256)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
238 (aset caesar-translate-table i i)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
239 (setq i (1+ i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
240 (setq lower (concat lower lower) upper (upcase lower) i 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241 (while (< i 26)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244 (setq i (1+ i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245 ;; ROT47 for Japanese text.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
246 ;; Thanks to ichikawa@flab.fujitsu.junet.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 (setq i 161)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248 (let ((t1 (logior ?O 128))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249 (t2 (logior ?! 128))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 (t3 (logior ?~ 128)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 (while (< i 256)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 (aset caesar-translate-table i
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 (let ((v (aref caesar-translate-table i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 (if (<= v t1) (if (< v t2) v (+ v 47))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 (if (<= v t3) (- v 47) v))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256 (setq i (1+ i))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257 (message "Building caesar-translate-table...done")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
258 (let ((from (region-beginning))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
259 (to (region-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
260 (i 0) str len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
261 (setq str (buffer-substring from to))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
262 (setq len (length str))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
263 (while (< i len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
264 (aset str i (aref caesar-translate-table (aref str i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
265 (setq i (1+ i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
266 (goto-char from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
267 (delete-region from to)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
268 (insert str)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
269
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
270
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
271 ;;; @ field
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
272 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
273
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
274 (defun tm:set-fields (sym field-list &optional regexp-sym)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
275 (or regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
276 (setq regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
277 (let ((name (symbol-name sym)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
278 (intern
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
279 (concat (if (string-match "\\(.*\\)-list" name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
280 (substring name 0 (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
281 name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
282 "-regexp")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
283 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
284 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
285 (set sym field-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
286 (set regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
287 (concat "^" (apply (function regexp-or) field-list) ":"))
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:add-fields (sym field-list &optional regexp-sym)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
291 (or regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
292 (setq regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
293 (let ((name (symbol-name sym)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
294 (intern
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
295 (concat (if (string-match "\\(.*\\)-list" name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
296 (substring name 0 (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
297 name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
298 "-regexp")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
299 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
300 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
301 (let ((fields (eval sym)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
302 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
303 (lambda (field)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
304 (or (member field fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
305 (setq fields (cons field fields))
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 (reverse field-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
309 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
310 (set regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
311 (concat "^" (apply (function regexp-or) fields) ":"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
312 (set sym 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 (defun tm:delete-fields (sym field-list &optional regexp-sym)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
316 (or regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
317 (setq regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
318 (let ((name (symbol-name sym)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
319 (intern
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
320 (concat (if (string-match "\\(.*\\)-list" name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
321 (substring name 0 (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
322 name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
323 "-regexp")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
324 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
325 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
326 (let ((fields (eval sym)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
327 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
328 (lambda (field)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
329 (setq fields (delete field fields))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
330 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
331 field-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
332 (set regexp-sym
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
333 (concat "^" (apply (function regexp-or) fields) ":"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
334 (set sym fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
335 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
336
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
337
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
338 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
339 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
340
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
341 (provide 'tm-def)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
342
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
343 ;;; tm-def.el ends here