Fix the last change.
[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., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, 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 ;; for text/x-vcard
75 (defvar mime-setup-enable-vcard
76   (module-installed-p 'vcard)
77   "*If it is non-nil, semi-setup sets uf to use mime-vcard.")
78
79 (if mime-setup-enable-vcard
80     (eval-after-load "mime-view"
81       '(progn
82          (autoload 'mime-display-text/x-vcard "mime-vcard")
83
84          (mime-add-condition
85           'preview 
86           '((type . text)(subtype . x-vcard)
87             (body . visible)
88             (body-presentation-method . mime-display-text/x-vcard))
89           'strict)
90
91          (set-alist 'mime-view-type-subtype-score-alist
92                     '(text . x-vcard) 3))))
93
94 ;; for PGP
95 (defvar mime-setup-enable-pgp t
96   "*If it is non-nil, semi-setup sets uf to use mime-pgp.")
97
98 (if mime-setup-enable-pgp
99     (eval-after-load "mime-view"
100       '(progn
101          (mime-add-condition
102           'preview '((type . application)(subtype . pgp)
103                      (message-button . visible)))
104          (mime-add-condition
105           'action '((type . application)(subtype . pgp)
106                     (method . mime-view-application/pgp))
107           'strict "mime-pgp")
108          (mime-add-condition
109           'action '((type . text)(subtype . x-pgp)
110                     (method . mime-view-application/pgp)))
111          
112          (mime-add-condition
113           'action '((type . multipart)(subtype . signed)
114                     (method . mime-verify-multipart/signed))
115           'strict "mime-pgp")
116          
117          (mime-add-condition
118           'action
119           '((type . application)(subtype . pgp-signature)
120             (method . mime-verify-application/pgp-signature))
121           'strict "mime-pgp")
122          
123          (mime-add-condition
124           'action
125           '((type . application)(subtype . pgp-encrypted)
126             (method . mime-decrypt-application/pgp-encrypted))
127           'strict "mime-pgp")
128          
129          (mime-add-condition
130           'action
131           '((type . application)(subtype . pgp-keys)
132             (method . mime-add-application/pgp-keys))
133           'strict "mime-pgp")
134
135          (mime-add-condition
136           'action
137           '((type . application)(subtype . pkcs7-signature)
138             (method . mime-verify-application/pkcs7-signature))
139           'strict "mime-pgp")
140
141          (mime-add-condition
142           'action
143           '((type . application)(subtype . pkcs7-mime)
144             (method . mime-view-application/pkcs7-mime))
145           'strict "mime-pgp")
146          ))
147   )
148
149
150 ;;; @ for mime-edit
151 ;;;
152
153 ;; (defun mime-setup-decode-message-header ()
154 ;;   (save-excursion
155 ;;     (save-restriction
156 ;;       (goto-char (point-min))
157 ;;       (narrow-to-region
158 ;;        (point-min)
159 ;;        (if (re-search-forward
160 ;;             (concat "^" (regexp-quote mail-header-separator) "$")
161 ;;             nil t)
162 ;;            (match-beginning 0)
163 ;;          (point-max)
164 ;;          ))
165 ;;       (mime-decode-header-in-buffer)
166 ;;       (set-buffer-modified-p nil)
167 ;;       )))
168
169 ;; (add-hook 'mime-edit-mode-hook 'mime-setup-decode-message-header)
170
171
172 ;;; @@ variables
173 ;;;
174
175 (defvar mime-setup-use-signature t
176   "If it is not nil, mime-setup sets up to use signature.el.")
177
178 (defvar mime-setup-default-signature-key "\C-c\C-s"
179   "*Key to insert signature.")
180
181 (defvar mime-setup-signature-key-alist '((mail-mode . "\C-c\C-w"))
182   "Alist of major-mode vs. key to insert signature.")
183
184
185 ;;; @@ for signature
186 ;;;
187
188 (defun mime-setup-set-signature-key ()
189   (let ((keymap (current-local-map)))
190     (if keymap
191         (let ((key
192                (or (cdr (assq major-mode mime-setup-signature-key-alist))
193                    mime-setup-default-signature-key)))
194           (define-key keymap key (function insert-signature))
195           ))))
196
197 (when mime-setup-use-signature
198   (autoload 'insert-signature "signature" "Insert signature" t)
199   (add-hook 'mime-edit-mode-hook 'mime-setup-set-signature-key)
200   ;; (setq message-signature nil)
201   )
202
203
204 ;;; @ for mu-cite
205 ;;;
206
207 ;; (add-hook 'mu-cite/pre-cite-hook 'eword-decode-header)
208
209
210 ;;; @ end
211 ;;;
212
213 (provide 'semi-setup)
214
215 ;;; semi-setup.el ends here