X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mime-setup.el;h=816c70875543af63f21711ec28d57e30612b56fa;hb=8678be9b6b0060864ec793c6fd1d72df93ae9007;hp=74de2bd5b0f9ef3859aec5aef31b8caf4a133f1f;hpb=97a4d0fb367a9ef62d8ff08c55db71b7a0933848;p=elisp%2Ftm.git diff --git a/mime-setup.el b/mime-setup.el index 74de2bd..816c708 100644 --- a/mime-setup.el +++ b/mime-setup.el @@ -1,216 +1,134 @@ ;;; -;;; $Id: mime-setup.el,v 1.17 1994/08/20 12:06:34 morioka Exp $ +;;; mime-setup.el --- setup file for tm viewer and composer. ;;; - -(provide 'mime-setup) +;;; Copyright (C) 1995 Free Software Foundation, Inc. +;;; Copyright (C) 1994 .. 1996 MORIOKA Tomohiko +;;; +;;; Author: MORIOKA Tomohiko +;;; Version: +;;; $Id: mime-setup.el,v 7.14 1996/02/14 09:15:36 morioka Exp $ +;;; Keywords: mail, news, MIME, multimedia, multilingual, encoded-word +;;; +;;; This file is part of tm (Tools for MIME). +;;; +;;; This program is free software; you can redistribute it and/or +;;; modify it under the terms of the GNU General Public License as +;;; published by the Free Software Foundation; either version 2, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with This program. If not, write to the Free Software +;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +;;; +;;; Code: (require 'tm-setup) +(autoload 'mime/editor-mode "tm-edit" + "Minor mode for editing MIME message." t) +(autoload 'mime/decode-message-header "tm-ew-d" + "Decode MIME encoded-words in message header." t) + +(defun mime-setup-decode-message-header () + (save-excursion + (save-restriction + (goto-char (point-min)) + (narrow-to-region + (point-min) + (if (re-search-forward + (concat "^" (regexp-quote mail-header-separator) "$") + nil t) + (match-beginning 0) + (point-max) + )) + (mime/decode-message-header) + (set-buffer-modified-p nil) + ))) + +(add-hook 'mime/editor-mode-hook 'mime-setup-decode-message-header) -;;; @ variables -;;; -(defvar mime-setup-use-sc t) - -;;; @ for Edit MIME mode +;;; @ variables ;;; -(autoload 'mime-mode "mime" "Edit MIME message." t) -(autoload 'mime-convert-buffer "mime" "convert to MIME." t) -(autoload 'mime/encode-message-header "tiny-mime" - "convert message header to MIME style." t) +(defvar mime-setup-use-sc nil) +(defvar mime-setup-use-signature t) +(defvar mime-setup-default-signature-key "\C-c\C-s") +(defvar mime-setup-signature-key-alist '((mail-mode . "\C-c\C-w"))) -(autoload 'insert-signature "signature" "Insert signature" t) -(add-hook 'mime-mode-hook - (function - (lambda () - (define-key (current-local-map) - "\C-c\C-s" (function insert-signature)) - ))) -(setq mime-translate-hook (function mime/encode-message-header)) +;;; @ for signature +;;; -(if (boundp 'MULE) - (progn - (defun mime-header-charset-chooser-for-mule-no-encode-ISO-2022-JP (begin end) - (let ((lclist (find-charset-region begin end))) - (cond ((null lclist) nil) ;US-ASCII requres no encoding. - ((memq lc-ltn1 lclist) - '("ISO-8859-1" . "Q")) - ((memq lc-ltn2 lclist) - '("ISO-8859-2" . "Q")) - ((memq lc-ltn3 lclist) - '("ISO-8859-3" . "Q")) - ((memq lc-ltn4 lclist) - '("ISO-8859-4" . "Q")) - ((memq lc-crl lclist) - '("ISO-8859-5" . "Q")) - ;;((memq lc-arb lclist) - ;; '("ISO-8859-6" . "Q")) - ((memq lc-grk lclist) - '("ISO-8859-7" . "Q")) - ((memq lc-hbw lclist) - '("ISO-8859-8" . "Q")) - ((memq lc-ltn5 lclist) - '("ISO-8859-9" . "Q")) - ((memq lc-jp lclist) nil) - (t ;Unknown charset. It must be Mule! - '("ISO-2022-JP-2" . "B")) - ))) - (setq mime-header-charset-chooser - 'mime-header-charset-chooser-for-mule-no-encode-ISO-2022-JP) - ) - (progn - (defun mime-header-charset-chooser-for-nemacs-no-encode-ISO-2022-JP (begin end)) - (setq mime-header-charset-chooser - 'mime-header-charset-chooser-for-nemacs-no-encode-ISO-2022-JP) +(defun mime-setup-set-signature-key () + (let ((key (or (cdr (assq major-mode mime-setup-signature-key-alist)) + mime-setup-default-signature-key))) + (define-key (current-local-map) key (function insert-signature)) )) -(setq mime-content-types - '(("text" - ;; Charset parameter need not to be specified, since it is - ;; defined automatically while translation. - ("plain" - ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8") - ) - ("richtext" - ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8") - ) - ("x-latex" - ("x-name") - ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8") - )) - ("message" - ("external-body" - ("access-type" - ("anon-ftp" - ("site" "wnoc-fuk.wide.ad.jp" "nic.karrn.ad.jp") - ("directory") - ("name") - ("mode" "binary" "ascii")) - ("ftp" - ("site") - ("directory") - ("name") - ("mode" "binary" "ascii")) - ("tftp" - ("site") - ("name")) - ("afs" - ("site") - ("name")) - ("local-file" - ("site") - ("name")) - ("mail-server" - ("server")))) - ("rfc822")) - ("application" - ("octet-stream" - ("name") - ("type" "" "tar" "shar") - ("conversions")) - ("postscript") - ("x-kiss" - ("x-name") - ("x-cnf"))) - ("image" - ("gif" ("x-name")) - ("jpeg" ("x-name")) - ("x-pic" ("x-name")) - ("x-xwd") - ("x-xbm")) - ("audio" - ("basic")) - ("video" - ("mpeg"))) - ) - -(setq mime-file-types - '(("\\.rtf$" "text" "richtext" nil nil) - ("\\.ps$" "application" "postscript" nil "quoted-printable") - ("\\.gif$" "image" "gif" nil "base64") - ("\\.jpg$" "image" "jpeg" nil "base64") - ("\\.xwd$" "image" "x-xwd" nil "base64") - ("\\.xbm$" "image" "x-xbm" nil "base64") - ("\\.PIC$" "image" "x-pic" nil "base64") - ("\\.pic$" "image" "x-pic" nil "base64") - ("\\.tiff$" "image" "tiff" nil "base64") - ("\\.au$" "audio" "basic" nil "base64") - ("\\.mpg$" "video" "mpeg" nil "base64") - ("\\.el$" "application" "octet-stream" nil "7bit") - ("\\.signature" "text" "plain" nil nil) - (".*" nil nil nil nil)) - ) +(if mime-setup-use-signature + (progn + (autoload 'insert-signature "signature" "Insert signature" t) + (add-hook 'mime/editor-mode-hook 'mime-setup-set-signature-key) + (setq gnus-signature-file nil) + (setq mail-signature nil) + )) ;;; @ about SuperCite ;;; + (if mime-setup-use-sc (require 'sc-setup) ) +;;; @ for RMAIL and VM +;;; + +(add-hook 'mail-setup-hook 'mime/decode-message-header) +(add-hook 'mail-setup-hook 'mime/editor-mode 'append) +(add-hook 'mail-send-hook 'mime-editor/maybe-translate) + + ;;; @ for mh-e ;;; -(add-hook 'mh-letter-mode-hook - (function - (lambda () - (mime/decode-message-header) - (mime-mode) - (make-local-variable 'mail-header-separator) - (setq mail-header-separator "--------")) - )) + +(defun mime-setup-mh-draft-setting () + (mime/editor-mode) + (make-local-variable 'mail-header-separator) + (setq mail-header-separator "--------") + (save-excursion + (goto-char (point-min)) + (setq buffer-read-only nil) + (if (re-search-forward "^-*$" nil t) + (progn + (replace-match mail-header-separator) + (set-buffer-modified-p (buffer-modified-p)) + )) + )) + +(add-hook 'mh-letter-mode-hook 'mime-setup-mh-draft-setting t) +(add-hook 'mh-before-send-letter-hook 'mime-editor/maybe-translate) ;;; @ for GNUS ;;; -(add-hook 'news-reply-mode-hook - (function - (lambda () - (mime/decode-message-header) - (mime-mode) - ))) -(setq gnus-signature-file nil) +(add-hook 'news-reply-mode-hook 'mime/editor-mode) +(add-hook 'news-inews-hook 'mime-editor/maybe-translate) -;;; @ for RMAIL -;;; -(autoload 'rmail-show-mime "rmailmime" "Show MIME messages." t) -(autoload 'rmail-convert-mime-header "rmailmime" "Convert MIME header." nil) -(setq rmail-message-filter (function mime/decode-message-header)) -(add-hook 'rmail-mode-hook - (function - (lambda () - ;; Forward mail using MIME. - (require 'mime) - (substitute-key-definition 'rmail-forward - 'mime-forward-from-rmail-using-mail - (current-local-map)) - (local-set-key "v" 'rmail-show-mime) - ))) - - -;;; @ for Mail mode (includes VM mode) + +;;; @ end ;;; -(add-hook 'mail-mode-hook (function mime-mode)) -(add-hook 'mail-setup-hook (function mime/decode-message-header)) -;;; @@ In VM, the following definitions may be requried: -;;; -(if (boundp 'vm-visible-headers) - (progn - (setq vm-preview-lines nil) - (setq vm-invisible-header-regexp nil) - (setq vm-visible-headers - (append vm-visible-headers - '("Mime-Version:" - "Content-Type:" - "Content-Transfer-Encoding:"))) - )) +(provide 'mime-setup) + +(run-hooks 'mime-setup-load-hook) -;;; Local Variables: -;;; mode: emacs-lisp -;;; mode: outline-minor -;;; outline-regexp: ";;; @+\\|(......" -;;; End: +;;; mime-setup.el ends here