Synch with `semi-1_14_0'.
[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     (add-hook hook-name func)))
40
41
42 ;; for image/*
43 (defvar mime-setup-enable-inline-image
44   (and window-system
45        (or (featurep 'xemacs)(featurep 'mule)))
46   "*If it is non-nil, semi-setup sets up to use mime-image.")
47
48 (if mime-setup-enable-inline-image
49     (eval-after-load "mime-view"
50       '(require 'mime-image)))
51
52 ;; for text/html
53 (defvar mime-setup-enable-inline-html
54   (module-installed-p 'w3)
55   "*If it is non-nil, semi-setup sets up to use mime-w3.")
56
57 (if mime-setup-enable-inline-html
58     (eval-after-load "mime-view"
59       '(progn
60          (autoload 'mime-preview-text/html "mime-w3")
61          
62          (ctree-set-calist-strictly
63           'mime-preview-condition
64           '((type . text)(subtype . html)
65             (body . visible)
66             (body-presentation-method . mime-preview-text/html)))
67          
68          (set-alist 'mime-view-type-subtype-score-alist
69                     '(text . html) 3))))
70
71 ;; for text/x-vcard
72 (defvar mime-setup-enable-vcard
73   (module-installed-p 'vcard)
74   "*If it is non-nil, semi-setup sets uf to use mime-vcard.")
75
76 (if mime-setup-enable-vcard
77     (eval-after-load "mime-view"
78       '(progn
79          (autoload 'mime-display-text/x-vcard "mime-vcard")
80
81          (mime-add-condition
82           'preview 
83           '((type . text)(subtype . x-vcard)
84             (body . visible)
85             (body-presentation-method . mime-display-text/x-vcard))
86           'strict)
87
88          (set-alist 'mime-view-type-subtype-score-alist
89                     '(text . x-vcard) 3))))
90
91 ;; for PGP
92 (defvar mime-setup-enable-pgp t
93   "*If it is non-nil, semi-setup sets uf to use mime-pgp.")
94
95 (if mime-setup-enable-pgp
96     (eval-after-load "mime-view"
97       '(progn
98          (mime-add-condition
99           'preview '((type . application)(subtype . pgp)
100                      (message-button . visible)))
101          (mime-add-condition
102           'action '((type . application)(subtype . pgp)
103                     (method . mime-view-application/pgp))
104           'strict "mime-pgp")
105          (mime-add-condition
106           'action '((type . text)(subtype . x-pgp)
107                     (method . mime-view-application/pgp)))
108          
109          (mime-add-condition
110           'action '((type . multipart)(subtype . signed)
111                     (method . mime-verify-multipart/signed))
112           'strict "mime-pgp")
113          
114          (mime-add-condition
115           'action
116           '((type . application)(subtype . pgp-signature)
117             (method . mime-verify-application/pgp-signature))
118           'strict "mime-pgp")
119          
120          (mime-add-condition
121           'action
122           '((type . application)(subtype . pgp-encrypted)
123             (method . mime-decrypt-application/pgp-encrypted))
124           'strict "mime-pgp")
125          
126          (mime-add-condition
127           'action
128           '((type . application)(subtype . pgp-keys)
129             (method . mime-add-application/pgp-keys))
130           'strict "mime-pgp")
131
132          (mime-add-condition
133           'action
134           '((type . application)(subtype . pkcs7-signature)
135             (method . mime-verify-application/pkcs7-signature))
136           'strict "mime-pgp")
137
138          (mime-add-condition
139           'action
140           '((type . application)(subtype . pkcs7-mime)
141             (method . mime-view-application/pkcs7-mime))
142           'strict "mime-pgp"))))
143
144
145 ;;; @ for mime-edit
146 ;;;
147
148 ;; (defun mime-setup-decode-message-header ()
149 ;;   (save-excursion
150 ;;     (save-restriction
151 ;;       (goto-char (point-min))
152 ;;       (narrow-to-region
153 ;;        (point-min)
154 ;;        (if (re-search-forward
155 ;;             (concat "^" (regexp-quote mail-header-separator) "$")
156 ;;             nil t)
157 ;;            (match-beginning 0)
158 ;;          (point-max)
159 ;;          ))
160 ;;       (mime-decode-header-in-buffer)
161 ;;       (set-buffer-modified-p nil)
162 ;;       )))
163
164 ;; (add-hook 'mime-edit-mode-hook 'mime-setup-decode-message-header)
165
166
167 ;;; @@ variables
168 ;;;
169
170 (defvar mime-setup-use-signature t
171   "If it is not nil, mime-setup sets up to use signature.el.")
172
173 (defvar mime-setup-default-signature-key "\C-c\C-s"
174   "*Key to insert signature.")
175
176 (defvar mime-setup-signature-key-alist '((mail-mode . "\C-c\C-w"))
177   "Alist of major-mode vs. key to insert signature.")
178
179
180 ;;; @@ for signature
181 ;;;
182
183 (defun mime-setup-set-signature-key ()
184   (let ((keymap (current-local-map)))
185     (if keymap
186         (let ((key
187                (or (cdr (assq major-mode mime-setup-signature-key-alist))
188                    mime-setup-default-signature-key)))
189           (define-key keymap key (function insert-signature))))))
190
191 (when mime-setup-use-signature
192   (autoload 'insert-signature "signature" "Insert signature" t)
193   (add-hook 'mime-edit-mode-hook 'mime-setup-set-signature-key)
194   ;; (setq message-signature nil)
195   )
196
197
198 ;;; @ for mu-cite
199 ;;;
200
201 ;; (add-hook 'mu-cite/pre-cite-hook 'eword-decode-header)
202
203
204 ;;; @ end
205 ;;;
206
207 (provide 'semi-setup)
208
209 ;;; semi-setup.el ends here