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.6 1995/09/24 22:24:17 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)
33 ;;; @ for various Emacs variants
36 (cond ((boundp 'MULE) (require 'tm-mule))
37 ((boundp 'NEMACS)(require 'tm-nemacs))
38 (t (require 'tm-orig))
45 (defun tm:set-face-region (b e face)
46 (let ((overlay (tl:make-overlay b e)))
47 (tl:overlay-put overlay 'face face)
50 (setq tm:button-face 'bold)
51 (setq tm:mouse-face 'highlight)
53 (defun tm:add-button (from to func &optional data)
54 "Create a button between FROM and TO with callback FUNC and data DATA."
56 (tl:overlay-put (tl:make-overlay from to) 'face tm:button-face))
57 (tl:add-text-properties from to
58 (append (and tm:mouse-face
59 (list 'mouse-face tm:mouse-face))
60 (list 'tm-callback func)
61 (and data (list 'tm-data data))
65 (defvar tm:mother-button-dispatcher nil)
67 (defun tm:button-dispatcher (event)
68 "Select the button under point."
70 (mouse-set-point event)
71 (let ((func (get-text-property (point) 'tm-callback))
72 (data (get-text-property (point) 'tm-data))
76 (if (fboundp tm:mother-button-dispatcher)
77 (funcall tm:mother-button-dispatcher event)
86 "\\(http\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*[-a-zA-Z0-9_=#$@~`%&*+|\\/]")
88 (defvar browse-url-browser-function nil)
90 (defun tm:browse-url ()
91 (if (fboundp browse-url-browser-function)
92 (call-interactively browse-url-browser-function)
93 (if (fboundp tm:mother-button-dispatcher)
94 (funcall tm:mother-button-dispatcher event)
99 ;;; @ definitions about MIME
102 (defconst mime/tspecials "][\000-\040()<>@,\;:\\\"/?.=")
103 (defconst mime/token-regexp (concat "[^" mime/tspecials "]+"))
104 (defconst mime/charset-regexp mime/token-regexp)
110 (defconst base64-token-regexp "[A-Za-z0-9+/=]")
112 (defconst mime/B-encoded-text-regexp
119 (defconst mime/B-encoding-and-encoded-text-regexp
120 (concat "\\(B\\)\\?" mime/B-encoded-text-regexp))
123 ;;; @@ Quoted-Printable
126 (defconst quoted-printable-hex-chars "0123456789ABCDEF")
127 (defconst quoted-printable-octet-regexp
128 (concat "=[" quoted-printable-hex-chars
129 "][" quoted-printable-hex-chars "]"))
131 (defconst mime/Q-encoded-text-regexp
132 (concat "\\([^=?]\\|" quoted-printable-octet-regexp "\\)+"))
133 (defconst mime/Q-encoding-and-encoded-text-regexp
134 (concat "\\(Q\\)\\?" mime/Q-encoded-text-regexp))