1 ;;; semi-def.el --- definition module for SEMI
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 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-product ["EMY" (1 13 3) "To err is human"]
34 "Product name, version number and code name 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."
65 (put-text-property from to 'face mime-button-face))
66 (and mime-button-mouse-face
67 (put-text-property from to 'mouse-face mime-button-mouse-face))
68 (add-text-properties from to (list 'mime-button-callback function
71 (add-text-properties from to (list 'mime-button-data data))))
73 (defsubst mime-insert-button (string function &optional data)
74 "Insert STRING as button with callback FUNCTION and DATA."
78 (narrow-to-region (point)(point))
79 (insert (concat "[" string "]\n"))
80 (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)))
99 (if (fboundp mime-button-mother-dispatcher)
100 (funcall mime-button-mother-dispatcher event))))))
106 (defcustom mime-browse-url-regexp
107 (concat "\\(http\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):"
108 "\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?"
109 "[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*[-a-zA-Z0-9_=#$@~`%&*+|\\/]")
110 "*Regexp to match URL in text body."
114 (defcustom mime-browse-url-function (function browse-url)
115 "*Function to browse URL."
119 (defsubst mime-add-url-buttons ()
120 "Add URL-buttons for text body."
121 (goto-char (point-min))
122 (while (re-search-forward mime-browse-url-regexp nil t)
123 (let ((beg (match-beginning 0))
125 (mime-add-button beg end mime-browse-url-function
126 (list (buffer-substring beg end))))))
133 (if (featurep 'xemacs)
134 (defun select-menu-alist (title menu-alist)
143 (setq ret ',(cdr cell))
149 (defun select-menu-alist (title menu-alist)
151 (list '(1 1) (selected-window))
152 (list title (cons title menu-alist)))))
153 (defun select-menu-alist (title menu-alist)
155 (assoc (completing-read (concat title " : ") menu-alist)
162 (defvar mime-condition-type-alist
163 '((preview . mime-preview-condition)
164 (action . mime-acting-condition)))
166 (defvar mime-condition-mode-alist
167 '((with-default . ctree-set-calist-with-default)
168 (t . ctree-set-calist-strictly)))
170 (defun mime-add-condition (target-type condition &optional mode file)
171 "Add CONDITION to database specified by TARGET-TYPE.
172 TARGET-TYPE must be 'preview or 'action.
173 If optional argument MODE is 'strict or nil (omitted), CONDITION is
175 If optional argument MODE is 'with-default, CONDITION is added with
177 If optional argument FILE is specified, it is loaded when CONDITION is
179 (let ((sym (cdr (assq target-type mime-condition-type-alist))))
181 (let ((func (cdr (or (assq mode mime-condition-mode-alist)
182 (assq t mime-condition-mode-alist)))))
185 (funcall func sym condition)
187 (let ((method (cdr (assq 'method condition))))
188 (autoload method file))))
189 (error "Function for mode `%s' is not found." mode)))
190 (error "Variable for target-type `%s' is not found." target-type))))
198 ;;; semi-def.el ends here