1 ;;; semi-def.el --- definition module for REMI
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 SEMI (Sample of Emacs MIME Implementation).
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))
33 (defconst mime-user-interface-version '("SEMI" "Toyama" 1 8 0)
34 "Implementation name, version name and numbers of MIME-kernel package.")
36 (autoload 'mule-caesar-region "mule-caesar"
37 "Caesar rotation of current region." t)
43 (defconst mime-echo-buffer-name "*MIME-echo*"
44 "Name of buffer to display MIME-playing information.")
46 (defconst mime-temp-buffer-name " *MIME-temp*")
52 (defcustom mime-button-face 'bold
53 "Face used for content-button or URL-button of MIME-Preview buffer."
57 (defcustom mime-button-mouse-face 'highlight
58 "Face used for MIME-preview buffer mouse highlighting."
62 (defsubst mime-add-button (from to function &optional data)
63 "Create a button between FROM and TO with callback FUNCTION and DATA."
64 (let ((overlay (make-overlay from to)))
66 (overlay-put overlay 'face mime-button-face))
67 (and mime-button-mouse-face
68 (overlay-put overlay 'mouse-face mime-button-mouse-face))
69 (add-text-properties from to (list 'mime-button-callback function))
71 (add-text-properties from to (list 'mime-button-data data)))
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 (insert (concat "[" string "]\n"))
79 (mime-add-button (point-min)(point-max) function data)
82 (defvar mime-button-mother-dispatcher nil)
84 (defun mime-button-dispatcher (event)
85 "Select the button under point."
87 (let (buf point func data)
88 (save-window-excursion
89 (mouse-set-point event)
90 (setq buf (current-buffer)
92 func (get-text-property (point) 'mime-button-callback)
93 data (get-text-property (point) 'mime-button-data)
100 (if (fboundp mime-button-mother-dispatcher)
101 (funcall mime-button-mother-dispatcher event)
108 (require 'browse-url)
110 (defcustom mime-browse-url-regexp
111 (concat "\\(http\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):"
112 "\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?"
113 "[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*[-a-zA-Z0-9_=#$@~`%&*+|\\/]")
114 "*Regexp to match URL in text body."
118 (defun mime-browse-url (&optional url)
119 (if (fboundp browse-url-browser-function)
121 (funcall browse-url-browser-function url)
122 (call-interactively browse-url-browser-function))
123 (if (fboundp mime-button-mother-dispatcher)
124 (call-interactively mime-button-mother-dispatcher)
127 (defsubst mime-browse-add-url-buttons ()
128 "Add URL-buttons for text body."
129 (goto-char (point-min))
130 (while (re-search-forward mime-browse-url-regexp nil t)
131 (let ((beg (match-beginning 0))
133 (mime-add-button beg end (function mime-browse-url)
134 (list (buffer-substring beg end))))))
136 (defun mime-browse-add-url-buttons-maybe ()
137 "Add URL-buttons if 'browse-url-browser-function is non-nil."
138 (if browse-url-browser-function
139 (mime-browse-add-url-buttons)
147 (if (featurep 'xemacs)
148 (defun select-menu-alist (title menu-alist)
157 (setq ret ',(cdr cell))
166 (defun select-menu-alist (title menu-alist)
168 (list '(1 1) (selected-window))
169 (list title (cons title menu-alist))
172 (defun select-menu-alist (title menu-alist)
174 (assoc (completing-read (concat title " : ") menu-alist)
183 (defvar pgp-function-alist
186 (verify mc-verify "mc-toplev")
187 (decrypt mc-decrypt "mc-toplev")
188 (fetch-key mc-pgp-fetch-key "mc-pgp")
189 (snarf-keys mc-snarf-keys "mc-toplev")
191 (mime-sign mime-mc-pgp-sign-region "mime-mc")
192 (traditional-sign mc-pgp-sign-region "mc-pgp")
193 (encrypt mime-mc-pgp-encrypt-region "mime-mc")
194 (insert-key mc-insert-public-key "mc-toplev")
196 "Alist of service names vs. corresponding functions and its filenames.
197 Each element looks like (SERVICE FUNCTION FILE).
199 SERVICE is a symbol of PGP processing. It allows `verify', `decrypt',
200 `fetch-key', `snarf-keys', `mime-sign', `traditional-sign', `encrypt'
203 Function is a symbol of function to do specified SERVICE.
205 FILE is string of filename which has definition of corresponding
208 (defmacro pgp-function (method)
209 "Return function to do service METHOD."
210 `(cadr (assq ,method (symbol-value 'pgp-function-alist))))
214 (autoload (cadr method)(nth 2 method))
222 (defvar mime-condition-type-alist
223 '((preview . mime-preview-condition)
224 (action . mime-acting-condition)))
226 (defvar mime-condition-mode-alist
227 '((with-default . ctree-set-calist-with-default)
228 (t . ctree-set-calist-strictly)))
230 (defun mime-add-condition (target-type condition &optional mode file)
231 "Add CONDITION to database specified by TARGET-TYPE.
232 TARGET-TYPE must be 'preview or 'action.
233 If optional argument MODE is 'strict or nil (omitted), CONDITION is
235 If optional argument MODE is 'with-default, CONDITION is added with
237 If optional argument FILE is specified, it is loaded when CONDITION is
239 (let ((sym (cdr (assq target-type mime-condition-type-alist))))
241 (let ((func (cdr (or (assq mode mime-condition-mode-alist)
242 (assq t mime-condition-mode-alist)))))
245 (funcall func sym condition)
247 (let ((method (cdr (assq 'method condition))))
248 (autoload method file)
251 (error "Function for mode `%s' is not found." mode)
253 (error "Variable for target-type `%s' is not found." target-type)
262 ;;; semi-def.el ends here