(mime-save-content): Return filename.
[elisp/semi.git] / semi-setup.el
1 ;;; semi-setup.el --- setup file for MIME-View.
2
3 ;; Copyright (C) 1994,95,96,97,98,99,2000 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
6 ;; Keywords: mail, news, MIME, multimedia, multilingual, encoded-word
7
8 ;; This file is part of SEMI (Setting for Emacs MIME Interfaces).
9
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
14
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
24
25 ;;; Code:
26
27 (require 'semi-def)
28 (require 'path-util)
29
30 (defun call-after-loaded (module func &optional hook-name)
31   "If MODULE is provided, then FUNC is called.
32 Otherwise func is set to MODULE-load-hook.
33 If optional argument HOOK-NAME is specified,
34 it is used as hook to set."
35   (if (featurep module)
36       (funcall func)
37     (or hook-name
38         (setq hook-name (intern (concat (symbol-name module) "-load-hook")))
39         )
40     (add-hook hook-name func)
41     ))
42
43
44 ;; for image/*
45 (defvar mime-setup-enable-inline-image
46   (and window-system
47        (or (featurep 'xemacs)(featurep 'mule)))
48   "*If it is non-nil, semi-setup sets up to use mime-image.")
49
50 (if mime-setup-enable-inline-image
51     (eval-after-load "mime-view"
52       '(require 'mime-image)))
53
54 ;; for text/html
55 (defvar mime-setup-enable-inline-html
56   (module-installed-p 'w3)
57   "*If it is non-nil, semi-setup sets up to use mime-w3.")
58
59 (if mime-setup-enable-inline-html
60     (eval-after-load "mime-view"
61       '(progn
62          (autoload 'mime-preview-text/html "mime-w3")
63          
64          (ctree-set-calist-strictly
65           'mime-preview-condition
66           '((type . text)(subtype . html)
67             (body . visible)
68             (body-presentation-method . mime-preview-text/html)))
69          
70          (set-alist 'mime-view-type-subtype-score-alist
71                     '(text . html) 3)
72          )))
73
74
75 ;; for PGP
76 (defvar mime-setup-enable-pgp t
77   "*If it is non-nil, semi-setup sets uf to use mime-pgp.")
78
79 (if mime-setup-enable-pgp
80     (eval-after-load "mime-view"
81       '(progn
82          (require 'mime-pgp)
83
84          (mime-add-condition
85           'preview '((type . application)(subtype . pgp)
86                      (message-button . visible)))
87          (mime-add-condition
88           'action '((type . application)(subtype . pgp)
89                     (method . mime-view-application/pgp))
90           'strict "mime-pgp")
91          (mime-add-condition
92           'action '((type . text)(subtype . x-pgp)
93                     (method . mime-view-application/pgp)))
94          
95          (mime-add-condition
96           'action '((type . multipart)(subtype . signed)
97                     (method . mime-verify-multipart/signed))
98           'strict "mime-pgp")
99          
100          (mime-add-condition
101           'action
102           '((type . application)(subtype . pgp-signature)
103             (method . mime-verify-application/pgp-signature))
104           'strict "mime-pgp")
105          
106          (mime-add-condition
107           'action
108           '((type . application)(subtype . pgp-encrypted)
109             (method . mime-decrypt-application/pgp-encrypted))
110           'strict "mime-pgp")
111          
112          (mime-add-condition
113           'action
114           '((type . application)(subtype . pgp-keys)
115             (method . mime-add-application/pgp-keys))
116           'strict "mime-pgp")
117
118          (mime-add-condition
119           'action
120           '((type . application)(subtype . pkcs7-signature)
121             (method . mime-verify-application/pkcs7-signature))
122           'strict "mime-pgp")
123
124          (mime-add-condition
125           'action
126           '((type . application)(subtype . x-pkcs7-signature)
127             (method . mime-verify-application/pkcs7-signature))
128           'strict "mime-pgp")
129          
130          (mime-add-condition
131           'action
132           '((type . application)(subtype . pkcs7-mime)
133             (method . mime-view-application/pkcs7-mime))
134           'strict "mime-pgp")
135
136          (mime-add-condition
137           'action
138           '((type . application)(subtype . x-pkcs7-mime)
139             (method . mime-view-application/pkcs7-mime))
140           'strict "mime-pgp")
141
142          (ctree-set-calist-strictly
143           'mime-preview-condition
144           '((type . multipart) (subtype . encrypted) ("protocol" . "application/pgp-encrypted")
145             (body . visible)
146             (body-presentation-method . mime-display-multipart/pgp-encrypted)))
147          ))
148   )
149
150
151 ;;; @ for mime-edit
152 ;;;
153
154 ;; (defun mime-setup-decode-message-header ()
155 ;;   (save-excursion
156 ;;     (save-restriction
157 ;;       (goto-char (point-min))
158 ;;       (narrow-to-region
159 ;;        (point-min)
160 ;;        (if (re-search-forward
161 ;;             (concat "^" (regexp-quote mail-header-separator) "$")
162 ;;             nil t)
163 ;;            (match-beginning 0)
164 ;;          (point-max)
165 ;;          ))
166 ;;       (mime-decode-header-in-buffer)
167 ;;       (set-buffer-modified-p nil)
168 ;;       )))
169
170 ;; (add-hook 'mime-edit-mode-hook 'mime-setup-decode-message-header)
171
172
173 ;;; @@ variables
174 ;;;
175
176 (defvar mime-setup-use-signature t
177   "If it is not nil, mime-setup sets up to use signature.el.")
178
179 (defvar mime-setup-default-signature-key "\C-c\C-s"
180   "*Key to insert signature.")
181
182 (defvar mime-setup-signature-key-alist '((mail-mode . "\C-c\C-w"))
183   "Alist of major-mode vs. key to insert signature.")
184
185
186 ;;; @@ for signature
187 ;;;
188
189 (defun mime-setup-set-signature-key ()
190   (let ((keymap (current-local-map)))
191     (if keymap
192         (let ((key
193                (or (cdr (assq major-mode mime-setup-signature-key-alist))
194                    mime-setup-default-signature-key)))
195           (define-key keymap key (function insert-signature))
196           ))))
197
198 (when mime-setup-use-signature
199   (autoload 'insert-signature "signature" "Insert signature" t)
200   (add-hook 'mime-edit-mode-hook 'mime-setup-set-signature-key)
201   ;; (setq message-signature nil)
202   )
203
204
205 ;;; @ for mu-cite
206 ;;;
207
208 ;; (add-hook 'mu-cite/pre-cite-hook 'eword-decode-header)
209
210
211 ;;; @ end
212 ;;;
213
214 (provide 'semi-setup)
215
216 ;;; semi-setup.el ends here