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