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