-
Notifications
You must be signed in to change notification settings - Fork 16
/
semi-setup.el
313 lines (251 loc) · 8.36 KB
/
semi-setup.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
;;; semi-setup.el --- setup file for MIME-View. -*- lexical-binding: t -*-
;; Copyright (C) 1994,95,96,97,98,99,2000 Free Software Foundation, Inc.
;; Author: MORIOKA Tomohiko <[email protected]>
;; Keywords: mail, news, MIME, multimedia, multilingual, encoded-word
;; This file is part of SEMI (Setting for Emacs MIME Interfaces).
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
(require 'path-util)
(require 'alist)
(require 'semi-def)
(defun call-after-loaded (module func &optional hook-name)
"If MODULE is provided, then FUNC is called.
Otherwise func is set to MODULE-load-hook.
If optional argument HOOK-NAME is specified,
it is used as hook to set."
(if (featurep module)
(funcall func)
(or hook-name
(setq hook-name (intern (concat (symbol-name module) "-load-hook"))))
(add-hook hook-name func)))
;; for image/*
(defvar mime-setup-enable-inline-image
window-system
"*If it is non-nil, semi-setup sets up to use mime-image.")
(if mime-setup-enable-inline-image
(eval-after-load "mime-view"
'(require 'mime-image)))
;; for text/html
(when (and (boundp 'mime-html-previewer-alist)
(null (boundp 'mime-view-text/html-previewer-alist)))
(defvar mime-view-text/html-previewer-alist 'mime-html-previewer-alist))
(when (and (boundp 'mime-setup-enable-inline-html)
(null (boundp 'mime-view-text/html-previewer)))
(defvar mime-view-text/html-previewer mime-setup-enable-inline-html))
(defadvice mime-w3m-insinuate (around insinuate-to-semi-epg activate)
(setq mime-view-text/html-previewer 'w3m))
(make-obsolete-variable 'mime-html-previewer-alist
'mime-view-text/html-previewer-alist
"12 Jan 2014")
(make-obsolete-variable 'mime-setup-enable-inline-html
'mime-view-text/html-previewer
"12 Jan 2014")
;; for text/vcard, text/x-vcard
(defvar mime-setup-enable-vcard
(module-installed-p 'vcard)
"*If it is non-nil, semi-setup sets up to use mime-vcard.")
(eval-after-load "mime-view"
'(when mime-setup-enable-vcard
(mapc (lambda (subtype)
(mime-add-condition
'preview
`((type . text)(subtype . ,subtype)
(body . visible)
(major-mode . t)
(body-presentation-method . mime-display-text/vcard))
'strict "mime-vcard")
(set-alist 'mime-view-type-subtype-score-alist
`(text . ,subtype) 3))
'(vcard x-vcard))))
;; for PGP
(defvar mime-setup-enable-epg t
"*If it is non-nil, semi-setup sets up to use mime-pgp.")
(eval-after-load "mime-view"
'(when mime-setup-enable-epg
(mime-add-condition
'preview '((type . application)(subtype . pgp)
(major-mode . t)
(message-button . visible)))
(mime-add-condition
'action '((type . multipart)(subtype . signed)
(major-mode . t)
(method . mime-verify-multipart/signed))
'strict "mime-pgp")
(mime-add-condition
'action
'((type . application)(subtype . pgp-signature)
(major-mode . t)
(method . mime-verify-application/*-signature))
'strict "mime-pgp")
(mime-add-condition
'action
'((type . application)(subtype . pgp-encrypted)
(major-mode . t)
(method . mime-decrypt-application/pgp-encrypted))
'strict "mime-pgp")
(mime-add-condition
'action
'((type . application)(subtype . pgp-keys)
(major-mode . t)
(method . mime-add-application/pgp-keys))
'strict "mime-pgp")
(mime-add-condition
'action
'((type . application)(subtype . pkcs7-signature)
(major-mode . t)
(method . mime-verify-application/*-signature))
'strict "mime-pgp")
(mime-add-condition
'action
'((type . application)(subtype . x-pkcs7-signature)
(major-mode . t)
(method . mime-verify-application/*-signature))
'strict "mime-pgp")
(mime-add-condition
'action
'((type . application)(subtype . pkcs7-mime)
(major-mode . t)
(method . mime-view-application/pkcs7-mime))
'strict "mime-pgp")
(mime-add-condition
'action
'((type . application)(subtype . x-pkcs7-mime)
(major-mode . t)
(method . mime-view-application/pkcs7-mime))
'strict "mime-pgp")
(mime-add-condition
'preview
'((type . application)
(subtype . pkcs7-mime)
(body . mime-pgp-decrypt-when-preview)
(body-presentation-method . mime-preview-application/pkcs7-mime))
'strict "mime-pgp")
(mime-add-condition
'preview
'((type . multipart)
(subtype . encrypted)
("protocol" . "application/pgp-encrypted")
(body . visible)
(major-mode . t)
(body-presentation-method . mime-display-multipart/pgp-encrypted))
'strict "mime-pgp")
(mime-add-condition
'preview
'((type . application)
(subtype . pgp-signature)
(body . mime-pgp-verify-when-preview)
(major-mode . t)
(body-presentation-method . mime-preview-application/*-signature))
'strict "mime-pgp")
(mime-add-condition
'preview
'((type . application)
(subtype . pgp-encrypted)
(body . mime-pgp-decrypt-when-preview)
(major-mode . t)
(body-presentation-method . mime-preview-application/pgp-encrypted))
'strict "mime-pgp")
(mime-add-condition
'preview
'((type . application)
(subtype . pkcs7-signature)
(body . mime-pgp-verify-when-preview)
(major-mode . t)
(body-presentation-method . mime-preview-application/*-signature))
'strict "mime-pgp")
(mime-add-condition
'preview
'((type . application)
(subtype . x-pkcs7-signature)
(body . mime-pgp-verify-when-preview)
(major-mode . t)
(body-presentation-method . mime-preview-application/*-signature))
'strict "mime-pgp")))
(eval-after-load "mime-view"
'(progn
(mime-add-condition
'preview
'((type . application)
(subtype . ms-tnef)
(body . visible)
(major-mode . t)
(body-presentation-method . mime-display-application/ms-tnef))
'strict "mime-tnef")
(mime-add-condition
'preview
'((type . application)
(subtype . vnd.ms-tnef)
(body . visible)
(major-mode . t)
(body-presentation-method . mime-display-application/ms-tnef))
'strict "mime-tnef")))
;;; @ for mime-edit
;;;
;; (defun mime-setup-decode-message-header ()
;; (save-excursion
;; (save-restriction
;; (goto-char (point-min))
;; (narrow-to-region
;; (point-min)
;; (if (re-search-forward
;; (concat "^" (regexp-quote mail-header-separator) "$")
;; nil t)
;; (match-beginning 0)
;; (point-max)
;; ))
;; (mime-decode-header-in-buffer)
;; (set-buffer-modified-p nil)
;; )))
;; (add-hook 'mime-edit-mode-hook 'mime-setup-decode-message-header)
;;; @@ variables
;;;
(defvar mime-setup-use-signature nil
"If it is not nil, mime-setup sets up to use signature.el.")
(defvar mime-setup-default-signature-key "\C-c\C-s"
"*Key to insert signature.")
(defvar mime-setup-signature-key-alist '((mail-mode . "\C-c\C-w"))
"Alist of major-mode vs. key to insert signature.")
;;; @@ for signature
;;;
(autoload 'insert-signature "signature" "Insert signature" t)
(defun mime-setup-set-signature-key ()
(let ((keymap (current-local-map)))
(if keymap
(let ((key
(or (cdr (assq major-mode mime-setup-signature-key-alist))
mime-setup-default-signature-key)))
(define-key keymap key (function insert-signature))))))
(when mime-setup-use-signature
(add-hook 'mime-edit-mode-hook 'mime-setup-set-signature-key)
;; (setq message-signature nil)
)
;;; @ for mu-cite
;;;
;; (add-hook 'mu-cite/pre-cite-hook 'eword-decode-header)
;;; @ for Mac OS X
;;;
(when (eq system-type 'darwin)
(eval-after-load "mime-view"
'(progn
(mime-add-condition
'action
'((type . application)
(major-mode . t)
(method . mime-mac-save-and-play-with-open))
'with-default
"mime-mac"))))
;;; @ end
;;;
(provide 'semi-setup)
;;; semi-setup.el ends here