Apply Simon Josefsson <jas@pdc.kth.se>'s patch.
[elisp/semi.git] / semi-setup.el
index d29ae73..33ec99c 100644 (file)
@@ -1,12 +1,11 @@
-;;; mime-setup.el --- setup file for MIME-View.
+;;; semi-setup.el --- setup file for MIME-View.
 
-;; Copyright (C) 1994,1995,1996,1997 Free Software Foundation, Inc.
+;; Copyright (C) 1994,1995,1996,1997,1998 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id: semi-setup.el,v 0.1 1997-02-21 05:57:53 tmorioka Exp $
 ;; Keywords: mail, news, MIME, multimedia, multilingual, encoded-word
 
-;; This file is part of SEMI (SEMI is Emacs MIME Interfaces).
+;; 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
 
 ;;; Code:
 
-(require 'tl-misc)
-
-
-;;; @ for mime-view
-;;;
-
-(call-after-loaded
- 'mime-view
- (function
-  (lambda ()
-    ;; for message/partial
-    (require 'mime-partial)
-    
-    ;; for anonymous ftp
-    (set-atype 'mime/content-decoding-condition
-              '((type . "message/external-body")
-                ("access-type" . "anon-ftp")
-                (method . mime-article/decode-message/external-ftp)
-                ))
-    (autoload 'mime-article/decode-message/external-ftp "tm-ftp")
-    
-    ;; for LaTeX
-    (set-atype 'mime/content-decoding-condition
-              '((type . "text/x-latex")
-                (method . mime/decode-text/latex)
-                ))
-    (set-atype 'mime/content-decoding-condition
-              '((type . "application/x-latex")
-                (method . mime/decode-text/latex)
-                ))
-    ;;(set-atype 'mime/content-decoding-condition
-    ;;         '((type . "application/octet-stream")
-    ;;           ("type" . "latex")
-    ;;           (method . mime/decode-text/latex)
-    ;;           ))
-    (autoload 'mime/decode-text/latex "tm-latex")
-    )))
+(require 'semi-def)
+(require 'path-util)
 
 
 ;; for image/* and X-Face
        (or running-xemacs
           (and (featurep 'mule)(module-installed-p 'bitmap))
           ))
-  "*If it is non-nil, semi-setup sets up to use tm-image.")
+  "*If it is non-nil, semi-setup sets up to use mime-image.")
 
 (if mime-setup-enable-inline-image
     (call-after-loaded 'mime-view
                       (function
                        (lambda ()
-                         (require 'tm-image)
+                         (require 'mime-image)
                          )))
   )
 
 
 (defvar mime-setup-enable-pgp
   (module-installed-p 'mailcrypt)
-  "*If it is non-nil, semi-setup sets uf to use tm-pgp.")
+  "*If it is non-nil, semi-setup sets uf to use mime-pgp.")
 
 ;; for PGP
 (if mime-setup-enable-pgp
-    (call-after-loaded 'mime-view
-                      (function
-                       (lambda ()
-                         (require 'tm-pgp)
-                         )))
+    (eval-after-load "mime-view"
+      '(progn
+        (mime-add-condition
+         'preview '((type . application)(subtype . pgp)
+                    (message-button . visible)))
+        (mime-add-condition
+         'action '((type . application)(subtype . pgp)
+                   (method . mime-method-for-application/pgp))
+         'strict "mime-pgp")
+        (mime-add-condition
+         'action '((type . text)(subtype . x-pgp)
+                   (method . mime-method-for-application/pgp)))
+        
+        (mime-add-condition
+         'action '((type . multipart)(subtype . signed)
+                   (method . mime-method-to-verify-multipart/signed))
+         'strict "mime-pgp")
+        
+        (mime-add-condition
+         'action
+         '((type . application)(subtype . pgp-signature)
+           (method . mime-method-to-verify-application/pgp-signature))
+         'strict "mime-pgp")
+        
+        (mime-add-condition
+         'action
+         '((type . application)(subtype . pgp-encrypted)
+           (method . mime-method-to-decrypt-application/pgp-encrypted))
+         'strict "mime-pgp")
+        
+        (mime-add-condition
+         'action
+         '((type . application)(subtype . pgp-keys)
+           (method . mime-method-to-add-application/pgp-keys))
+         'strict "mime-pgp")
+        ))
   )
 
 
-;;; @ for mh-e
+;;; @ for mime-edit
 ;;;
 
-(let ((le (function
-          (lambda ()
-            (require 'tm-mh-e)
-            ))
-         ))
-  (call-after-loaded 'mh-e le 'mh-folder-mode-hook)
-  (if (not (featurep 'mh-e))
-      (add-hook 'mh-letter-mode-hook le)
-    ))
+(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)
+        ))
+      (eword-decode-header)
+      (set-buffer-modified-p nil)
+      )))
+
+(add-hook 'mime-edit-mode-hook 'mime-setup-decode-message-header)
+
+
+;;; @@ variables
+;;;
+
+(defvar mime-setup-use-signature t
+  "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
+;;;
+
+(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
+  (autoload 'insert-signature "signature" "Insert signature" t)
+  (add-hook 'mime-edit-mode-hook 'mime-setup-set-signature-key)
+  ;; (setq message-signature nil)
+  )
 
 
-;;; @ for Gnus
+;;; @ for mu-cite
 ;;;
-  
-(defun semi-setup-load-gnus ()
-  (let (gnus-load-hook)
-    (require 'gnus-mime)
-    ))
 
-(add-hook 'gnus-load-hook 'semi-setup-load-gnus)
+(add-hook 'mu-cite/pre-cite-hook 'eword-decode-header)
 
 
 ;;; @ end