1 ;;; semi-def.el --- definition module for WEMI
3 ;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: definition, MIME, multimedia, mail, news
8 ;; This file is part of WEMI (Widget based Emacs MIME Interfaces).
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
32 (defconst mime-module-version '("WEMI" "
\e.D
\eNRfuna" 1 3 1)
33 "Implementation name, version name and numbers of MIME-kernel package.")
35 (autoload 'mule-caesar-region "mule-caesar"
36 "Caesar rotation of current region." t)
42 (defvar mime/use-multi-frame
43 (and (>= emacs-major-version 19) window-system))
45 (defvar mime/find-file-function
46 (if mime/use-multi-frame
47 (function find-file-other-frame)
55 (defconst mime-echo-buffer-name "*MIME-echo*"
56 "Name of buffer to display MIME-playing information.")
58 (defconst mime-temp-buffer-name " *MIME-temp*")
64 (defcustom mime-button-face 'bold
65 "Face used for content-button or URL-button of MIME-Preview buffer."
69 (defcustom mime-button-mouse-face 'highlight
70 "Face used for MIME-preview buffer mouse highlighting."
74 (defsubst mime-insert-button (string function &optional data)
75 "Insert STRING as button with callback FUNCTION and DATA."
77 (narrow-to-region (point)(point))
78 (mapcar #'(lambda (line)
81 :action `(lambda (widget &optional event)
84 :mouse-down-action `(lambda (widget event)
86 (save-window-excursion
87 (mouse-set-point event)
88 (setq buf (current-buffer)
98 (split-string string "\n"))
99 ;;(mime-add-button (point-min)(point-max) function data)
102 (defvar mime-button-mother-dispatcher nil)
104 (defun mime-button-dispatcher (event)
105 "Select the button under point."
107 (let (buf point func data)
108 (save-window-excursion
109 (mouse-set-point event)
110 (setq buf (current-buffer)
112 func (get-text-property (point) 'mime-button-callback)
113 data (get-text-property (point) 'mime-button-data)
121 (if (fboundp mime-button-mother-dispatcher)
122 (funcall mime-button-mother-dispatcher event)
131 (if (featurep 'xemacs)
132 (defun select-menu-alist (title menu-alist)
141 (setq ret ',(cdr cell))
150 (defun select-menu-alist (title menu-alist)
152 (list '(1 1) (selected-window))
153 (list title (cons title menu-alist))
156 (defun select-menu-alist (title menu-alist)
158 (assoc (completing-read (concat title " : ") menu-alist)
167 (defvar pgp-function-alist
170 (verify mc-verify "mc-toplev")
171 (decrypt mc-decrypt "mc-toplev")
172 (fetch-key mc-pgp-fetch-key "mc-pgp")
173 (snarf-keys mc-snarf-keys "mc-toplev")
175 (mime-sign mime-mc-pgp-sign-region "mime-mc")
176 (traditional-sign mc-pgp-sign-region "mc-pgp")
177 (encrypt mime-mc-pgp-encrypt-region "mime-mc")
178 (insert-key mc-insert-public-key "mc-toplev")
180 "Alist of service names vs. corresponding functions and its filenames.
181 Each element looks like (SERVICE FUNCTION FILE).
183 SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
184 `fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt'
187 Function is a symbol of function to do specified SERVICE.
189 FILE is string of filename which has definition of corresponding
192 (defmacro pgp-function (method)
193 "Return function to do service METHOD."
194 `(cadr (assq ,method (symbol-value 'pgp-function-alist)))
199 (autoload (cadr method)(nth 2 method))
207 (defun tm:set-fields (sym field-list &optional regexp-sym)
210 (let ((name (symbol-name sym)))
212 (concat (if (string-match "\\(.*\\)-list" name)
213 (substring name 0 (match-end 1))
220 (concat "^" (apply (function regexp-or) field-list) ":"))
223 (defun tm:add-fields (sym field-list &optional regexp-sym)
226 (let ((name (symbol-name sym)))
228 (concat (if (string-match "\\(.*\\)-list" name)
229 (substring name 0 (match-end 1))
234 (let ((fields (eval sym)))
237 (or (member field fields)
238 (setq fields (cons field fields))
244 (concat "^" (apply (function regexp-or) fields) ":"))
248 (defun tm:delete-fields (sym field-list &optional regexp-sym)
251 (let ((name (symbol-name sym)))
253 (concat (if (string-match "\\(.*\\)-list" name)
254 (substring name 0 (match-end 1))
259 (let ((fields (eval sym)))
262 (setq fields (delete field fields))
266 (concat "^" (apply (function regexp-or) fields) ":"))
274 (defsubst get-version-string (id)
275 "Return a version-string from RCS ID."
276 (and (string-match ",v \\([0-9][0-9.][0-9.]+\\)" id)
277 (substring id (match-beginning 1)(match-end 1))
284 (defun call-after-loaded (module func &optional hook-name)
285 "If MODULE is provided, then FUNC is called.
286 Otherwise func is set to MODULE-load-hook.
287 If optional argument HOOK-NAME is specified,
288 it is used as hook to set."
289 (if (featurep module)
292 (setq hook-name (intern (concat (symbol-name module) "-load-hook")))
294 (add-hook hook-name func)
303 ;;; semi-def.el ends here