1 ;;; semi-def.el --- definition module for WEMI
3 ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
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))
35 (defconst mime-user-interface-product ["WEMI" (1 13 5) "Fijieda"]
36 "Product name, version number and code name of MIME-kernel package.")
38 (autoload 'mule-caesar-region "mule-caesar"
39 "Caesar rotation of current region." t)
41 (autoload 'widget-convert-button "wid-edit")
47 (defconst mime-echo-buffer-name "*MIME-echo*"
48 "Name of buffer to display MIME-playing information.")
50 (defconst mime-temp-buffer-name " *MIME-temp*")
56 (defcustom mime-button-face 'bold
57 "Face used for content-button or URL-button of MIME-Preview buffer."
61 (defcustom mime-button-mouse-face 'highlight
62 "Face used for MIME-preview buffer mouse highlighting."
66 (defsubst mime-insert-button (string function &optional data)
67 "Insert STRING as button with callback FUNCTION and DATA."
69 (narrow-to-region (point)(point))
70 (mapcar #'(lambda (line)
75 :action `(lambda (widget &optional event)
78 :mouse-down-action `(lambda (widget event)
80 (save-window-excursion
81 (mouse-set-point event)
82 (setq buf (current-buffer)
90 (if (featurep 'xemacs)
94 (while (setq extent (extent-at start nil nil extent))
95 (set-extent-endpoints extent end (point)))
96 (delete-region start end)))
98 (split-string string "\n"))))
100 (defvar mime-button-mother-dispatcher nil)
102 (defun mime-button-dispatcher (event)
103 "Select the button under point."
105 (let (buf point func data)
106 (save-window-excursion
107 (mouse-set-point event)
108 (setq buf (current-buffer)
110 func (get-text-property (point) 'mime-button-callback)
111 data (get-text-property (point) 'mime-button-data)
118 (if (fboundp mime-button-mother-dispatcher)
119 (funcall mime-button-mother-dispatcher event)
126 (defcustom mime-browse-url-regexp
127 (concat "\\(http\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):"
128 "\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?"
129 "[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*[-a-zA-Z0-9_=#$@~`%&*+|\\/]")
130 "*Regexp to match URL in text body."
134 (defcustom mime-browse-url-function (function browse-url)
135 "*Function to browse URL."
139 (defsubst mime-add-url-buttons ()
140 "Add URL-buttons for text body."
141 (goto-char (point-min))
142 (while (re-search-forward mime-browse-url-regexp nil t)
143 (let ((beg (match-beginning 0))
145 (widget-convert-button 'mime-url-link beg end
146 (buffer-substring beg end))
149 (define-widget 'mime-url-link 'link
150 "A link to an www page."
151 :help-echo 'widget-url-link-help-echo
152 :action 'widget-mime-url-link-action)
154 (defun widget-mime-url-link-action (widget &optional event)
155 "Open the url specified by WIDGET."
156 (funcall mime-browse-url-function (widget-value widget)))
163 (if (featurep 'xemacs)
164 (defun select-menu-alist (title menu-alist)
173 (setq ret ',(cdr cell))
182 (defun select-menu-alist (title menu-alist)
184 (list '(1 1) (selected-window))
185 (list title (cons title menu-alist))
188 (defun select-menu-alist (title menu-alist)
190 (assoc (completing-read (concat title " : ") menu-alist)
199 (defvar pgp-function-alist
202 (verify mc-verify "mc-toplev")
203 (decrypt mc-decrypt "mc-toplev")
204 (fetch-key mc-pgp-fetch-key "mc-pgp")
205 (snarf-keys mc-snarf-keys "mc-toplev")
207 (mime-sign mime-mc-pgp-sign-region "mime-mc")
208 (traditional-sign mc-pgp-sign-region "mc-pgp")
209 (encrypt mime-mc-pgp-encrypt-region "mime-mc")
210 (insert-key mc-insert-public-key "mc-toplev")
212 "Alist of service names vs. corresponding functions and its filenames.
213 Each element looks like (SERVICE FUNCTION FILE).
215 SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
216 `fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt'
219 Function is a symbol of function to do specified SERVICE.
221 FILE is string of filename which has definition of corresponding
224 (defmacro pgp-function (method)
225 "Return function to do service METHOD."
226 `(cadr (assq ,method (symbol-value 'pgp-function-alist))))
230 (autoload (cadr method)(nth 2 method))
238 (defvar mime-condition-type-alist
239 '((preview . mime-preview-condition)
240 (action . mime-acting-condition)))
242 (defvar mime-condition-mode-alist
243 '((with-default . ctree-set-calist-with-default)
244 (t . ctree-set-calist-strictly)))
246 (defun mime-add-condition (target-type condition &optional mode file)
247 "Add CONDITION to database specified by TARGET-TYPE.
248 TARGET-TYPE must be 'preview or 'action.
249 If optional argument MODE is 'strict or nil (omitted), CONDITION is
251 If optional argument MODE is 'with-default, CONDITION is added with
253 If optional argument FILE is specified, it is loaded when CONDITION is
255 (let ((sym (cdr (assq target-type mime-condition-type-alist))))
257 (let ((func (cdr (or (assq mode mime-condition-mode-alist)
258 (assq t mime-condition-mode-alist)))))
261 (funcall func sym condition)
263 (let ((method (cdr (assq 'method condition))))
264 (autoload method file)
267 (error "Function for mode `%s' is not found." mode)
269 (error "Variable for target-type `%s' is not found." target-type)
278 ;;; semi-def.el ends here