tm 6.88.
[elisp/tm.git] / tm-def.el
1 ;;;
2 ;;; tm-def.el --- definition module for tm
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Version:
9 ;;;     $Id: tm-def.el,v 6.3 1995/09/21 00:12:52 morioka Exp $
10 ;;; Keywords: mail, news, MIME, multimedia, definition
11 ;;;
12 ;;; This file is part of tm (Tools for MIME).
13 ;;;
14
15 (require 'emu)
16
17
18 ;;; @ variables
19 ;;;
20
21 (defvar mime/tmp-dir (or (getenv "TM_TMP_DIR") "/tmp/"))
22
23 (defvar mime/use-multi-frame
24   (and (>= emacs-major-version 19) window-system))
25
26 (defvar mime/find-file-function
27   (if mime/use-multi-frame
28       (function find-file-other-frame)
29     (function find-file)
30     ))
31
32
33 ;;; @ for various Emacs variants
34 ;;;
35
36 (cond ((boundp 'MULE)  (require 'tm-mule))
37       ((boundp 'NEMACS)(require 'tm-nemacs))
38       (t               (require 'tm-orig))
39       )
40
41 (defun tm:set-face-region (b e face)
42   (let ((overlay (tl:make-overlay b e)))
43     (tl:overlay-put overlay 'face face)
44     ))
45
46 (setq tm:button-face 'bold)
47 (setq tm:mouse-face 'highlight)
48
49 (defun tm:add-button (from to func &optional data)
50   "Create a button between FROM and TO with callback FUNC and data DATA."
51   (and tm:button-face
52        (tl:overlay-put (tl:make-overlay from to) 'face tm:button-face))
53   (tl:add-text-properties from to
54                           (append (and tm:mouse-face
55                                        (list 'mouse-face tm:mouse-face))
56                                   (list 'tm-callback func)
57                                   (and data (list 'tm-data data))
58                                   ))
59   )
60
61 (defun tm:button-dispatcher (event)
62   "Select the button under point."
63   (interactive "e")
64   (mouse-set-point event)
65   (let ((func (get-text-property (point) 'tm-callback)))
66     (if func
67         (call-interactively func)
68         )))
69
70
71 ;;; @ definitions about MIME
72 ;;;
73
74 (defconst mime/tspecials "][\000-\040()<>@,\;:\\\"/?.=")
75 (defconst mime/token-regexp (concat "[^" mime/tspecials "]+"))
76 (defconst mime/charset-regexp mime/token-regexp)
77
78
79 ;;; @@ Base64
80 ;;;
81
82 (defconst base64-token-regexp "[A-Za-z0-9+/=]")
83
84 (defconst mime/B-encoded-text-regexp
85   (concat "\\("
86           base64-token-regexp
87           base64-token-regexp
88           base64-token-regexp
89           base64-token-regexp
90           "\\)+"))
91 (defconst mime/B-encoding-and-encoded-text-regexp
92   (concat "\\(B\\)\\?" mime/B-encoded-text-regexp))
93
94
95 ;;; @@ Quoted-Printable
96 ;;;
97
98 (defconst quoted-printable-hex-chars "0123456789ABCDEF")
99 (defconst quoted-printable-octet-regexp
100   (concat "=[" quoted-printable-hex-chars
101           "][" quoted-printable-hex-chars "]"))
102
103 (defconst mime/Q-encoded-text-regexp
104   (concat "\\([^=?]\\|" quoted-printable-octet-regexp "\\)+"))
105 (defconst mime/Q-encoding-and-encoded-text-regexp
106   (concat "\\(Q\\)\\?" mime/Q-encoded-text-regexp))
107
108
109 ;;; @ end
110 ;;;
111
112 (provide 'tm-def)