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