;;; ;;; tm-def.el --- definition module for tm ;;; ;;; Copyright (C) 1995 Free Software Foundation, Inc. ;;; Copyright (C) 1995 MORIOKA Tomohiko ;;; ;;; Author: MORIOKA Tomohiko ;;; Version: ;;; $Id: tm-def.el,v 7.0 1995/10/05 13:27:34 morioka Exp $ ;;; Keywords: mail, news, MIME, multimedia, definition ;;; ;;; This file is part of tm (Tools for MIME). ;;; (require 'emu) (require 'tl-822) ;;; @ variables ;;; (defvar mime/tmp-dir (or (getenv "TM_TMP_DIR") "/tmp/")) (defvar mime/use-multi-frame (and (>= emacs-major-version 19) window-system)) (defvar mime/find-file-function (if mime/use-multi-frame (function find-file-other-frame) (function find-file) )) ;;; @ constants ;;; (defconst mime/output-buffer-name "*MIME-out*") (defconst mime/decoding-buffer-name "*MIME-decoding*") ;;; @ for various Emacs variants ;;; (cond ((boundp 'MULE) (require 'tm-mule)) ((boundp 'NEMACS)(require 'tm-nemacs)) (t (require 'tm-orig)) ) ;;; @ button ;;; (defun tm:set-face-region (b e face) (let ((overlay (tl:make-overlay b e))) (tl:overlay-put overlay 'face face) )) (setq tm:button-face 'bold) (setq tm:mouse-face 'highlight) (defun tm:add-button (from to func &optional data) "Create a button between FROM and TO with callback FUNC and data DATA." (and tm:button-face (tl:overlay-put (tl:make-overlay from to) 'face tm:button-face)) (tl:add-text-properties from to (append (and tm:mouse-face (list 'mouse-face tm:mouse-face)) (list 'tm-callback func) (and data (list 'tm-data data)) )) ) (defvar tm:mother-button-dispatcher nil) (defun tm:button-dispatcher (event) "Select the button under point." (interactive "e") (mouse-set-point event) (let ((func (get-text-property (point) 'tm-callback)) (data (get-text-property (point) 'tm-data)) ) (if func (apply func data) (if (fboundp tm:mother-button-dispatcher) (funcall tm:mother-button-dispatcher event) ) ))) ;;; @ for URL ;;; (defvar tm:URL-regexp "\\(http\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*[-a-zA-Z0-9_=#$@~`%&*+|\\/]") (defvar browse-url-browser-function nil) (defun tm:browse-url () (if (fboundp browse-url-browser-function) (call-interactively browse-url-browser-function) (if (fboundp tm:mother-button-dispatcher) (call-interactively tm:mother-button-dispatcher) ) )) ;;; @ definitions about MIME ;;; (defconst mime/tspecials "][\000-\040()<>@,\;:\\\"/?.=") (defconst mime/token-regexp (concat "[^" mime/tspecials "]+")) (defconst mime/charset-regexp mime/token-regexp) (defconst mime/content-type-subtype-regexp (concat mime/token-regexp "/" mime/token-regexp)) (defconst mime/content-parameter-value-regexp (concat "\\(" rfc822/quoted-string-regexp "\\|[^; \t\n]*\\)")) ;;; @@ Base64 ;;; (defconst base64-token-regexp "[A-Za-z0-9+/=]") (defconst mime/B-encoded-text-regexp (concat "\\(" base64-token-regexp base64-token-regexp base64-token-regexp base64-token-regexp "\\)+")) (defconst mime/B-encoding-and-encoded-text-regexp (concat "\\(B\\)\\?" mime/B-encoded-text-regexp)) ;;; @@ Quoted-Printable ;;; (defconst quoted-printable-hex-chars "0123456789ABCDEF") (defconst quoted-printable-octet-regexp (concat "=[" quoted-printable-hex-chars "][" quoted-printable-hex-chars "]")) (defconst mime/Q-encoded-text-regexp (concat "\\([^=?]\\|" quoted-printable-octet-regexp "\\)+")) (defconst mime/Q-encoding-and-encoded-text-regexp (concat "\\(Q\\)\\?" mime/Q-encoded-text-regexp)) ;;; @ end ;;; (provide 'tm-def)