2 ;;; tm-def.el --- definition module for tm
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995 MORIOKA Tomohiko
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
9 ;;; $Id: tm-def.el,v 6.7 1995/09/25 22:21:48 morioka Exp $
10 ;;; Keywords: mail, news, MIME, multimedia, definition
12 ;;; This file is part of tm (Tools for MIME).
21 (defvar mime/tmp-dir (or (getenv "TM_TMP_DIR") "/tmp/"))
23 (defvar mime/use-multi-frame
24 (and (>= emacs-major-version 19) window-system))
26 (defvar mime/find-file-function
27 (if mime/use-multi-frame
28 (function find-file-other-frame)
36 (defconst mime/output-buffer-name "*MIME-out*")
37 (defconst mime/decoding-buffer-name "*MIME-decoding*")
40 ;;; @ for various Emacs variants
43 (cond ((boundp 'MULE) (require 'tm-mule))
44 ((boundp 'NEMACS)(require 'tm-nemacs))
45 (t (require 'tm-orig))
52 (defun tm:set-face-region (b e face)
53 (let ((overlay (tl:make-overlay b e)))
54 (tl:overlay-put overlay 'face face)
57 (setq tm:button-face 'bold)
58 (setq tm:mouse-face 'highlight)
60 (defun tm:add-button (from to func &optional data)
61 "Create a button between FROM and TO with callback FUNC and data DATA."
63 (tl:overlay-put (tl:make-overlay from to) 'face tm:button-face))
64 (tl:add-text-properties from to
65 (append (and tm:mouse-face
66 (list 'mouse-face tm:mouse-face))
67 (list 'tm-callback func)
68 (and data (list 'tm-data data))
72 (defvar tm:mother-button-dispatcher nil)
74 (defun tm:button-dispatcher (event)
75 "Select the button under point."
77 (mouse-set-point event)
78 (let ((func (get-text-property (point) 'tm-callback))
79 (data (get-text-property (point) 'tm-data))
83 (if (fboundp tm:mother-button-dispatcher)
84 (funcall tm:mother-button-dispatcher event)
93 "\\(http\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*[-a-zA-Z0-9_=#$@~`%&*+|\\/]")
95 (defvar browse-url-browser-function nil)
97 (defun tm:browse-url ()
98 (if (fboundp browse-url-browser-function)
99 (call-interactively browse-url-browser-function)
100 (if (fboundp tm:mother-button-dispatcher)
101 (funcall tm:mother-button-dispatcher event)
106 ;;; @ definitions about MIME
109 (defconst mime/tspecials "][\000-\040()<>@,\;:\\\"/?.=")
110 (defconst mime/token-regexp (concat "[^" mime/tspecials "]+"))
111 (defconst mime/charset-regexp mime/token-regexp)
113 (defconst mime/content-type-subtype-regexp
114 (concat mime/token-regexp "/" mime/token-regexp))
115 (defconst mime/content-parameter-value-regexp
117 message/quoted-string-regexp
124 (defconst base64-token-regexp "[A-Za-z0-9+/=]")
126 (defconst mime/B-encoded-text-regexp
133 (defconst mime/B-encoding-and-encoded-text-regexp
134 (concat "\\(B\\)\\?" mime/B-encoded-text-regexp))
137 ;;; @@ Quoted-Printable
140 (defconst quoted-printable-hex-chars "0123456789ABCDEF")
141 (defconst quoted-printable-octet-regexp
142 (concat "=[" quoted-printable-hex-chars
143 "][" quoted-printable-hex-chars "]"))
145 (defconst mime/Q-encoded-text-regexp
146 (concat "\\([^=?]\\|" quoted-printable-octet-regexp "\\)+"))
147 (defconst mime/Q-encoding-and-encoded-text-regexp
148 (concat "\\(Q\\)\\?" mime/Q-encoded-text-regexp))