tm 7.80.
[elisp/tm.git] / mime-setup.el.in
1 ;;; mime-setup.el --- setup file for tm viewer and composer.
2
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Maintainer: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
7 ;; Version:
8 ;;      $Id: mime-setup.el.in,v 7.25 1996/08/18 17:03:42 morioka Exp $
9 ;; Keywords: mail, news, MIME, multimedia, multilingual, encoded-word
10
11 ;; This file is part of tm (Tools for MIME).
12
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
17
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with this program; see the file COPYING.  If not, write to
25 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Code:
29
30 (require 'tm-setup)
31
32 (autoload 'mime/editor-mode "tm-edit"
33   "Minor mode for editing MIME message." t)
34 (autoload 'mime/decode-message-header "tm-ew-d"
35   "Decode MIME encoded-words in message header." t)
36
37 (defun mime-setup-decode-message-header ()
38   (save-excursion
39     (save-restriction
40       (goto-char (point-min))
41       (narrow-to-region
42        (point-min)
43        (if (re-search-forward
44             (concat "^" (regexp-quote mail-header-separator) "$")
45             nil t)
46            (match-beginning 0)
47          (point-max)
48          ))
49       (mime/decode-message-header)
50       (set-buffer-modified-p nil)
51       )))
52
53 (add-hook 'mime/editor-mode-hook 'mime-setup-decode-message-header)
54
55
56 ;;; @ variables
57 ;;;
58
59 (defvar mime-setup-use-sc nil)
60 (defvar mime-setup-use-signature t)
61 (defvar mime-setup-default-signature-key "\C-c\C-s")
62 (defvar mime-setup-signature-key-alist '((mail-mode . "\C-c\C-w")))
63
64
65 ;;; @ for signature
66 ;;;
67
68 (defun mime-setup-set-signature-key ()
69   (let ((key (or (cdr (assq major-mode mime-setup-signature-key-alist))
70                  mime-setup-default-signature-key)))
71     (define-key (current-local-map) key (function insert-signature))
72     ))
73
74 (if mime-setup-use-signature
75     (progn
76       (autoload 'insert-signature "signature" "Insert signature" t)
77       (add-hook 'mime/editor-mode-hook 'mime-setup-set-signature-key)
78       (setq gnus-signature-file nil)
79       (setq mail-signature nil)
80       (setq message-signature nil)
81       ))
82
83
84 ;;; @ about SuperCite
85 ;;;
86
87 (if mime-setup-use-sc
88     (require 'sc-setup)
89   )
90
91
92 ;;; @ for mu-cite
93 ;;;
94
95 (add-hook 'mu-cite/pre-cite-hook 'mime/decode-message-header)
96
97
98 ;;; @ for RMAIL and VM
99 ;;;
100
101 (add-hook 'mail-setup-hook 'mime/decode-message-header)
102 (add-hook 'mail-setup-hook 'mime/editor-mode 'append)
103 (add-hook 'mail-send-hook  'mime-editor/maybe-translate)
104
105
106 ;;; @ for mh-e
107 ;;;
108
109 (defun mime-setup-mh-draft-setting ()
110   (mime/editor-mode)
111   (make-local-variable 'mail-header-separator)
112   (setq mail-header-separator "--------")
113   (save-excursion
114     (goto-char (point-min))
115     (setq buffer-read-only nil)
116     (if (re-search-forward "^-*$" nil t)
117         (progn
118           (replace-match mail-header-separator)
119           (set-buffer-modified-p (buffer-modified-p))
120           ))
121     ))
122
123 (add-hook 'mh-letter-mode-hook 'mime-setup-mh-draft-setting t)
124 (add-hook 'mh-before-send-letter-hook 'mime-editor/maybe-translate)
125
126
127 ;;; @ for GNUS
128 ;;;
129
130 (add-hook 'news-reply-mode-hook 'mime/editor-mode)
131 (add-hook 'news-inews-hook      'mime-editor/maybe-translate)
132
133
134 ;;; @ for message (September Gnus 0.58 or later)
135 ;;;
136
137 (or (boundp 'epoch::version)
138     (progn
139       (add-hook 'message-setup-hook 'mime/editor-mode)
140       (add-hook 'message-send-hook  'mime-editor/maybe-translate)
141       (add-hook 'message-header-hook 'mime/encode-message-header)
142       
143       (call-after-loaded
144        'message
145        (function
146         (lambda ()
147           (require 'message-mime)
148           )))
149       ))
150
151
152 ;;; @ end
153 ;;;
154
155 (provide 'mime-setup)
156
157 (run-hooks 'mime-setup-load-hook)
158
159 ;;; mime-setup.el ends here
160 ;;;
161 ;;; Local Variables:
162 ;;; mode: emacs-lisp
163 ;;; End: