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-user-interface-version '("WEMI" "Numazu" 1 8 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 (defconst mime-echo-buffer-name "*MIME-echo*"
43 "Name of buffer to display MIME-playing information.")
45 (defconst mime-temp-buffer-name " *MIME-temp*")
51 (defcustom mime-button-face 'bold
52 "Face used for content-button or URL-button of MIME-Preview buffer."
56 (defcustom mime-button-mouse-face 'highlight
57 "Face used for MIME-preview buffer mouse highlighting."
61 (defsubst mime-insert-button (string function &optional data)
62 "Insert STRING as button with callback FUNCTION and DATA."
64 (narrow-to-region (point)(point))
65 (mapcar #'(lambda (line)
68 :action `(lambda (widget &optional event)
71 :mouse-down-action `(lambda (widget event)
73 (save-window-excursion
74 (mouse-set-point event)
75 (setq buf (current-buffer)
85 (split-string string "\n"))
86 ;;(mime-add-button (point-min)(point-max) function data)
89 (defvar mime-button-mother-dispatcher nil)
91 (defun mime-button-dispatcher (event)
92 "Select the button under point."
94 (let (buf point func data)
95 (save-window-excursion
96 (mouse-set-point event)
97 (setq buf (current-buffer)
99 func (get-text-property (point) 'mime-button-callback)
100 data (get-text-property (point) 'mime-button-data)
107 (if (fboundp mime-button-mother-dispatcher)
108 (funcall mime-button-mother-dispatcher event)
115 (defcustom mime-browse-url-regexp
116 (concat "\\(http\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):"
117 "\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?"
118 "[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*[-a-zA-Z0-9_=#$@~`%&*+|\\/]")
119 "*Regexp to match URL in text body."
123 (defcustom mime-browse-url-function (function browse-url)
124 "*Function to browse URL."
128 (defsubst mime-add-url-buttons ()
129 "Add URL-buttons for text body."
130 (goto-char (point-min))
131 (while (re-search-forward mime-browse-url-regexp nil t)
132 (let ((beg (match-beginning 0))
134 (widget-convert-text 'url-link beg end)
142 (if (featurep 'xemacs)
143 (defun select-menu-alist (title menu-alist)
152 (setq ret ',(cdr cell))
161 (defun select-menu-alist (title menu-alist)
163 (list '(1 1) (selected-window))
164 (list title (cons title menu-alist))
167 (defun select-menu-alist (title menu-alist)
169 (assoc (completing-read (concat title " : ") menu-alist)
178 (defvar pgp-function-alist
181 (verify mc-verify "mc-toplev")
182 (decrypt mc-decrypt "mc-toplev")
183 (fetch-key mc-pgp-fetch-key "mc-pgp")
184 (snarf-keys mc-snarf-keys "mc-toplev")
186 (mime-sign mime-mc-pgp-sign-region "mime-mc")
187 (traditional-sign mc-pgp-sign-region "mc-pgp")
188 (encrypt mime-mc-pgp-encrypt-region "mime-mc")
189 (insert-key mc-insert-public-key "mc-toplev")
191 "Alist of service names vs. corresponding functions and its filenames.
192 Each element looks like (SERVICE FUNCTION FILE).
194 SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
195 `fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt'
198 Function is a symbol of function to do specified SERVICE.
200 FILE is string of filename which has definition of corresponding
203 (defmacro pgp-function (method)
204 "Return function to do service METHOD."
205 `(cadr (assq ,method (symbol-value 'pgp-function-alist))))
209 (autoload (cadr method)(nth 2 method))
217 (defvar mime-condition-type-alist
218 '((preview . mime-preview-condition)
219 (action . mime-acting-condition)))
221 (defvar mime-condition-mode-alist
222 '((with-default . ctree-set-calist-with-default)
223 (t . ctree-set-calist-strictly)))
225 (defun mime-add-condition (target-type condition &optional mode file)
226 "Add CONDITION to database specified by TARGET-TYPE.
227 TARGET-TYPE must be 'preview or 'action.
228 If optional argument MODE is 'strict or nil (omitted), CONDITION is
230 If optional argument MODE is 'with-default, CONDITION is added with
232 If optional argument FILE is specified, it is loaded when CONDITION is
234 (let ((sym (cdr (assq target-type mime-condition-type-alist))))
236 (let ((func (cdr (or (assq mode mime-condition-mode-alist)
237 (assq t mime-condition-mode-alist)))))
240 (funcall func sym condition)
242 (let ((method (cdr (assq 'method condition))))
243 (autoload method file)
246 (error "Function for mode `%s' is not found." mode)
248 (error "Variable for target-type `%s' is not found." target-type)
257 ;;; semi-def.el ends here