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.63 1997-09-09 05:57:03 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 "Hinomiko")
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 "][()<>@,\;:\\\"/?=")
63 (defconst mime-token-regexp (concat "[^" mime-tspecials "\000-\040]+"))
64 (defconst mime-charset-regexp mime-token-regexp)
66 (defconst mime-media-type/subtype-regexp
67 (concat mime-token-regexp "/" mime-token-regexp))
73 (defvar mime-button-face 'bold
74 "Face used for content-button or URL-button of MIME-Preview buffer.")
76 (defvar mime-button-mouse-face 'highlight
77 "Face used for MIME-preview buffer mouse highlighting.")
79 (defsubst mime-add-button (from to function &optional data)
80 "Create a button between FROM and TO with callback FUNCTION and DATA."
81 (let ((overlay (make-overlay from to)))
83 (overlay-put overlay 'face mime-button-face))
84 (and mime-button-mouse-face
85 (overlay-put overlay 'mouse-face mime-button-mouse-face))
86 (add-text-properties from to (list 'mime-button-callback function))
88 (add-text-properties from to (list 'mime-button-data data)))
89 ;;(add-text-properties from to (list 'keymap widget-keymap))
92 (defsubst mime-insert-button (string function &optional data)
93 "Insert STRING as button with callback FUNCTION and DATA."
95 (narrow-to-region (point)(point))
96 (insert (concat "[" string "]"))
97 ;; (widget-push-button-value-create
98 ;; (widget-convert 'push-button
99 ;; :notify (lambda (&rest ignore)
100 ;; (mime-view-play-current-entity)
104 (mime-add-button (point-min)(point-max) function data)
107 (defvar mime-button-mother-dispatcher nil)
109 (defun mime-button-dispatcher (event)
110 "Select the button under point."
112 (let (buf point func data)
113 (save-window-excursion
114 (mouse-set-point event)
115 (setq buf (current-buffer)
117 func (get-text-property (point) 'mime-button-callback)
118 data (get-text-property (point) 'mime-button-data)
126 (if (fboundp mime-button-mother-dispatcher)
127 (funcall mime-button-mother-dispatcher event)
135 (defvar pgp-function-alist
138 (verify mc-verify "mc-toplev")
139 (decrypt mc-decrypt "mc-toplev")
140 (fetch-key mc-pgp-fetch-key "mc-pgp")
141 (snarf-keys mc-snarf-keys "mc-toplev")
143 (mime-sign mime-mc-pgp-sign-region "mime-mc")
144 (traditional-sign mc-pgp-sign-region "mc-pgp")
145 (encrypt mime-mc-pgp-encrypt-region "mime-mc")
146 (insert-key mc-insert-public-key "mc-toplev")
148 "Alist of service names vs. corresponding functions and its filenames.
149 Each element looks like (SERVICE FUNCTION FILE).
151 SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
152 `fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt'
155 Function is a symbol of function to do specified SERVICE.
157 FILE is string of filename which has definition of corresponding
160 (defmacro pgp-function (method)
161 "Return function to do service METHOD."
162 (` (car (cdr (assq (, method) (symbol-value 'pgp-function-alist)))))
167 (autoload (second method)(third method))
172 ;;; @ method selector kernel
180 (defun field-unifier-for-mode (a b)
193 (defsubst regexp-or (&rest args)
194 (concat "\\(" (mapconcat (function identity) args "\\|") "\\)"))
196 (defun tm:set-fields (sym field-list &optional regexp-sym)
199 (let ((name (symbol-name sym)))
201 (concat (if (string-match "\\(.*\\)-list" name)
202 (substring name 0 (match-end 1))
209 (concat "^" (apply (function regexp-or) field-list) ":"))
212 (defun tm:add-fields (sym field-list &optional regexp-sym)
215 (let ((name (symbol-name sym)))
217 (concat (if (string-match "\\(.*\\)-list" name)
218 (substring name 0 (match-end 1))
223 (let ((fields (eval sym)))
226 (or (member field fields)
227 (setq fields (cons field fields))
233 (concat "^" (apply (function regexp-or) fields) ":"))
237 (defun tm:delete-fields (sym field-list &optional regexp-sym)
240 (let ((name (symbol-name sym)))
242 (concat (if (string-match "\\(.*\\)-list" name)
243 (substring name 0 (match-end 1))
248 (let ((fields (eval sym)))
251 (setq fields (delete field fields))
255 (concat "^" (apply (function regexp-or) fields) ":"))
263 (defsubst get-version-string (id)
264 "Return a version-string from RCS ID."
265 (and (string-match ",v \\([0-9][0-9.][0-9.]+\\)" id)
266 (substring id (match-beginning 1)(match-end 1))
273 (defsubst eliminate-top-spaces (string)
274 "Eliminate top sequence of space or tab in STRING."
275 (if (string-match "^[ \t]+" string)
276 (substring string (match-end 0))
279 (defun call-after-loaded (module func &optional hook-name)
280 "If MODULE is provided, then FUNC is called.
281 Otherwise func is set to MODULE-load-hook.
282 If optional argument HOOK-NAME is specified,
283 it is used as hook to set."
284 (if (featurep module)
287 (setq hook-name (intern (concat (symbol-name module) "-load-hook")))
289 (add-hook hook-name func)
298 ;;; mime-def.el ends here