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