1 ;;; mime-def.el --- definition module for SEMI
3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: mime-def.el,v 0.57 1997-07-03 11:57:44 morioka Exp $
7 ;; Keywords: definition, MIME, multimedia, mail, news
9 ;; This file is part of SEMI (SEMI is Emacs MIME Interfaces).
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
31 (defconst semi-version-name "Kaga-Ichinomiya")
33 (autoload 'mule-caesar-region "mule-caesar"
34 "Caesar rotation of current region." t)
40 (defvar mime/use-multi-frame
41 (and (>= emacs-major-version 19) window-system))
43 (defvar mime/find-file-function
44 (if mime/use-multi-frame
45 (function find-file-other-frame)
53 (defconst mime-echo-buffer-name "*MIME-echo*"
54 "Name of buffer to display MIME-playing information.")
56 (defconst mime-temp-buffer-name " *MIME-temp*")
59 ;;; @ definitions about MIME
62 (defconst mime-tspecials "][\000-\040()<>@,\;:\\\"/?.=")
63 (defconst mime-token-regexp (concat "[^" mime-tspecials "]+"))
64 (defconst mime-charset-regexp mime-token-regexp)
66 (defconst mime-media-type/subtype-regexp
67 (concat mime-token-regexp "/" mime-token-regexp))
69 (defconst mime/disposition-type-regexp mime-token-regexp)
75 (defvar mime-button-face 'bold
76 "Face used for content-button or URL-button of MIME-Preview buffer.")
78 (defvar mime-button-mouse-face 'highlight
79 "Face used for MIME-preview buffer mouse highlighting.")
81 (defsubst mime-add-button (from to function &optional data)
82 "Create a button between FROM and TO with callback FUNCTION and DATA."
83 (let ((overlay (make-overlay from to)))
85 (overlay-put overlay 'face mime-button-face))
86 (and mime-button-mouse-face
87 (overlay-put overlay 'mouse-face mime-button-mouse-face))
88 (add-text-properties from to (list 'mime-button-callback function))
90 (add-text-properties from to (list 'mime-button-data data)))
91 ;;(add-text-properties from to (list 'keymap widget-keymap))
94 (defsubst mime-insert-button (string function &optional data)
95 "Insert STRING as button with callback FUNCTION and DATA."
97 (narrow-to-region (point)(point))
98 (insert (concat "[" string "]"))
99 ;; (widget-push-button-value-create
100 ;; (widget-convert 'push-button
101 ;; :notify (lambda (&rest ignore)
102 ;; (mime-view-play-current-entity)
106 (mime-add-button (point-min)(point-max) function data)
109 (defvar mime-button-mother-dispatcher nil)
111 (defun mime-button-dispatcher (event)
112 "Select the button under point."
114 (let (buf point func data)
115 (save-window-excursion
116 (mouse-set-point event)
117 (setq buf (current-buffer)
119 func (get-text-property (point) 'mime-button-callback)
120 data (get-text-property (point) 'mime-button-data)
128 (if (fboundp mime-button-mother-dispatcher)
129 (funcall mime-button-mother-dispatcher event)
137 (defvar pgp-function-alist
140 (verify mc-verify "mc-toplev")
141 (decrypt mc-decrypt "mc-toplev")
142 (fetch-key mc-pgp-fetch-key "mc-pgp")
143 (snarf-keys mc-snarf-keys "mc-toplev")
145 (mime-sign mime-mc-pgp-sign-region "mime-mc")
146 (traditional-sign mc-pgp-sign-region "mc-pgp")
147 (encrypt mime-mc-pgp-encrypt-region "mime-mc")
148 (insert-key mc-insert-public-key "mc-toplev")
150 "Alist of service names vs. corresponding functions and its filenames.
151 Each element looks like (SERVICE FUNCTION FILE).
153 SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
154 `fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt'
157 Function is a symbol of function to do specified SERVICE.
159 FILE is string of filename which has definition of corresponding
162 (defmacro pgp-function (method)
163 "Return function to do service METHOD."
164 (` (car (cdr (assq (, method) (symbol-value 'pgp-function-alist)))))
169 (autoload (second method)(third method))
174 ;;; @ method selector kernel
182 (defun field-unifier-for-mode (a b)
195 (defsubst regexp-or (&rest args)
196 (concat "\\(" (mapconcat (function identity) args "\\|") "\\)"))
198 (defun tm:set-fields (sym field-list &optional regexp-sym)
201 (let ((name (symbol-name sym)))
203 (concat (if (string-match "\\(.*\\)-list" name)
204 (substring name 0 (match-end 1))
211 (concat "^" (apply (function regexp-or) field-list) ":"))
214 (defun tm:add-fields (sym field-list &optional regexp-sym)
217 (let ((name (symbol-name sym)))
219 (concat (if (string-match "\\(.*\\)-list" name)
220 (substring name 0 (match-end 1))
225 (let ((fields (eval sym)))
228 (or (member field fields)
229 (setq fields (cons field fields))
235 (concat "^" (apply (function regexp-or) fields) ":"))
239 (defun tm:delete-fields (sym field-list &optional regexp-sym)
242 (let ((name (symbol-name sym)))
244 (concat (if (string-match "\\(.*\\)-list" name)
245 (substring name 0 (match-end 1))
250 (let ((fields (eval sym)))
253 (setq fields (delete field fields))
257 (concat "^" (apply (function regexp-or) fields) ":"))
265 (defsubst get-version-string (id)
266 "Return a version-string from RCS ID."
267 (and (string-match ",v \\([0-9][0-9.][0-9.]+\\)" id)
268 (substring id (match-beginning 1)(match-end 1))
275 (defsubst eliminate-top-spaces (string)
276 "Eliminate top sequence of space or tab in STRING."
277 (if (string-match "^[ \t]+" string)
278 (substring string (match-end 0))
281 (defun call-after-loaded (module func &optional hook-name)
282 "If MODULE is provided, then FUNC is called.
283 Otherwise func is set to MODULE-load-hook.
284 If optional argument HOOK-NAME is specified,
285 it is used as hook to set."
286 (if (featurep module)
289 (setq hook-name (intern (concat (symbol-name module) "-load-hook")))
291 (add-hook hook-name func)
300 ;;; mime-def.el ends here