* epa.el: Removed epa-*-mail stuff.
authorueno <ueno>
Mon, 29 Jan 2007 03:36:38 +0000 (03:36 +0000)
committerueno <ueno>
Mon, 29 Jan 2007 03:36:38 +0000 (03:36 +0000)
* Makefile.am (EXTRA_DIST): Added epa-mail.el.
* COMPILE (epg-modules): Added epa-mail.
* epa-mail.el: New file.

COMPILE
ChangeLog
Makefile.am
epa-mail.el [new file with mode: 0644]
epa.el

diff --git a/COMPILE b/COMPILE
index 4e068b7..208165e 100644 (file)
--- a/COMPILE
+++ b/COMPILE
@@ -1,7 +1,7 @@
 ;;; -*- Emacs-Lisp -*-
 
 (defvar epg-modules
-  '(epg-config epg epa epa-dired epa-file epa-setup))
+  '(epg-config epg epa epa-dired epa-file epa-mail epa-setup))
 
 (defun epg-compile-modules (modules)
   (let ((load-path (cons nil load-path))
index 3ccef25..72200d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-01-29  Daiki Ueno  <ueno@unixuser.org>
+
+       * epa.el: Removed epa-*-mail stuff.
+       * Makefile.am (EXTRA_DIST): Added epa-mail.el.
+       * COMPILE (epg-modules): Added epa-mail.
+       * epa-mail.el: New file.
+
 2007-01-05  Daiki Ueno  <ueno@unixuser.org>
 
        * epg-pgp50i.el: Removed.
index 4c60b68..278eb8c 100644 (file)
@@ -1,7 +1,7 @@
 AUTOMAKE_OPTIONS = no-dependencies
 
 EXTRA_DIST = COMPILE epg-config.el epg.el epa.el epa-dired.el \
-epa-file.el epa-setup.el
+epa-file.el epa-mail.el epa-setup.el
 
 CLEANFILES = auto-autoloads.el* custom-load.el *.elc
 FLAGS ?= -batch -q -no-site-file
diff --git a/epa-mail.el b/epa-mail.el
new file mode 100644 (file)
index 0000000..216f3b1
--- /dev/null
@@ -0,0 +1,161 @@
+;;; epa-mail.el --- the EasyPG Assistant, minor-mode for mail composer
+;; Copyright (C) 2006,2007 Daiki Ueno
+
+;; Author: Daiki Ueno <ueno@unixuser.org>
+;; Keywords: PGP, GnuPG, mail, message
+
+;; This file is part of EasyPG.
+
+;; 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 'epa)
+(require 'mail-utils)
+
+(defvar epa-key-list-mode-map
+  (let ((keymap (make-sparse-keymap)))
+    (define-key keymap "C-cC-ed" 'epa-mail-decrypt)
+    (define-key keymap "C-cC-ev" 'epa-mail-verify)
+    (define-key keymap "C-cC-es" 'epa-mail-sign)
+    (define-key keymap "C-cC-ee" 'epa-mail-encrypt)
+    (define-key keymap "C-cC-ei" 'epa-mail-import-keys)
+    (define-key keymap "C-cC-eo" 'epa-insert-keys)
+    keymap))
+
+;;;###autoload
+(define-minor-mode epa-mail-mode
+  "A minor-mode for composing encrypted/clearsigned mails."
+  nil nil epa-mail-mode-map)
+
+;;;###autoload
+(defun epa-mail-decrypt ()
+  "Decrypt OpenPGP armors in the current buffer.
+The buffer is expected to contain a mail message.
+
+Don't use this command in Lisp programs!"
+  (interactive)
+  (epa-decrypt-armor-in-region (point-min) (point-max)))
+
+;;;###autoload
+(defun epa-mail-verify ()
+  "Verify OpenPGP cleartext signed messages in the current buffer.
+The buffer is expected to contain a mail message.
+
+Don't use this command in Lisp programs!"
+  (interactive)
+  (epa-verify-cleartext-in-region (point-min) (point-max)))
+
+;;;###autoload
+(defun epa-mail-sign (start end signers mode)
+  "Sign the current buffer.
+The buffer is expected to contain a mail message.
+
+Don't use this command in Lisp programs!"
+  (interactive
+   (save-excursion
+     (goto-char (point-min))
+     (if (search-forward mail-header-separator nil t)
+        (forward-line))
+     (setq epa-last-coding-system-specified
+          (or coding-system-for-write
+              (epa--select-safe-coding-system (point) (point-max))))
+     (let ((verbose current-prefix-arg))
+       (list (point) (point-max)
+            (if verbose
+                (epa-select-keys (epg-make-context epa-protocol)
+                                 "Select keys for signing.
+If no one is selected, default secret key is used.  "
+                                 nil t))
+            (if verbose
+                (epa--read-signature-type)
+              'clear)))))
+  (epa-sign-region start end signers mode))
+
+;;;###autoload
+(defun epa-mail-encrypt (start end recipients sign signers)
+  "Encrypt the current buffer.
+The buffer is expected to contain a mail message.
+
+Don't use this command in Lisp programs!"
+  (interactive
+   (save-excursion
+     (let ((verbose current-prefix-arg)
+          (context (epg-make-context epa-protocol))
+          recipients recipient-keys)
+       (goto-char (point-min))
+       (save-restriction
+        (narrow-to-region (point)
+                          (if (search-forward mail-header-separator nil 0)
+                              (match-beginning 0)
+                            (point)))
+        (setq recipients
+              (mail-strip-quoted-names
+               (mapconcat #'identity
+                          (nconc (mail-fetch-field "to" nil nil t)
+                                 (mail-fetch-field "cc" nil nil t)
+                                 (mail-fetch-field "bcc" nil nil t))
+                          ","))))
+       (if recipients
+          (setq recipients (delete ""
+                                   (split-string recipients "[ \t\n]+"))))
+       (goto-char (point-min))
+       (if (search-forward mail-header-separator nil t)
+          (forward-line))
+       (setq epa-last-coding-system-specified
+            (or coding-system-for-write
+                (epa--select-safe-coding-system (point) (point-max))))
+       (list (point) (point-max)
+            (if verbose
+                (epa-select-keys
+                 context
+                 "Select recipients for encryption.
+If no one is selected, symmetric encryption will be performed.  "
+                 recipients)
+              (if recipients
+                  (apply #'nconc
+                         (mapcar
+                          (lambda (recipient)
+                            (setq recipient-keys
+                                  (epg-list-keys
+                                   (epg-make-context epa-protocol)
+                                   (concat "<" recipient ">")))
+                            (unless (or recipient-keys
+                                        (y-or-n-p
+                                         (format
+                                          "No public key for %s; skip it? "
+                                          recipient)))
+                              (error "No public key for %s" recipient))
+                            recipient-keys)
+                          recipients))))
+            (setq sign (if verbose (y-or-n-p "Sign? ")))
+            (if sign
+                (epa-select-keys context
+                                 "Select keys for signing.  "))))))
+  (epa-encrypt-region start end recipients sign signers))
+
+;;;###autoload
+(defun epa-mail-import-keys ()
+  "Import keys in the OpenPGP armor format in the current buffer.
+The buffer is expected to contain a mail message.
+
+Don't use this command in Lisp programs!"
+  (interactive)
+  (epa-import-armor-in-region (point-min) (point-max)))
+
+(provide 'epa-mail)
+
+;;; epa-mail.el ends here
diff --git a/epa.el b/epa.el
index 5e3cd1c..85421f2 100644 (file)
--- a/epa.el
+++ b/epa.el
@@ -27,7 +27,6 @@
 (require 'font-lock)
 (require 'widget)
 (eval-when-compile (require 'wid-edit))
-(require 'mail-utils)
 (require 'derived)
 
 (defgroup epa nil
@@ -61,11 +60,6 @@ the separate window."
   :type 'integer
   :group 'epa)
 
-(defcustom epa-mail-modes '(mail-mode message-mode)
-  "List of major-modes to compose mails."
-  :type 'list
-  :group 'epa)
-
 (defgroup epa-faces nil
   "Faces for epa-mode."
   :group 'epa)
@@ -864,6 +858,11 @@ Don't use this command in Lisp programs!"
            (error "No armor tail"))
          (epa-verify-region armor-start armor-end))))))
 
+(if (fboundp 'select-safe-coding-system)
+    (defalias 'epa--select-safe-coding-system 'select-safe-coding-system)
+  (defun epa--select-safe-coding-system (from to)
+    buffer-file-coding-system))
+
 ;;;###autoload
 (defun epa-sign-region (start end signers mode)
   "Sign the current region between START and END by SIGNERS keys selected.
@@ -1129,135 +1128,6 @@ Don't use this command in Lisp programs!"
     (message "Signing keys...done")))
 (make-obsolete 'epa-sign-keys "Do not use.")
 
-;;;###autoload
-(defun epa-decrypt-mail ()
-  "Decrypt OpenPGP armors in the current buffer.
-The buffer is expected to contain a mail message.
-
-Don't use this command in Lisp programs!"
-  (interactive)
-  (epa-decrypt-armor-in-region (point-min) (point-max)))
-
-(if (fboundp 'select-safe-coding-system)
-    (defalias 'epa--select-safe-coding-system 'select-safe-coding-system)
-  (defun epa--select-safe-coding-system (from to)
-    buffer-file-coding-system))
-
-;;;###autoload
-(defun epa-verify-mail ()
-  "Verify OpenPGP cleartext signed messages in the current buffer.
-The buffer is expected to contain a mail message.
-
-Don't use this command in Lisp programs!"
-  (interactive)
-  (epa-verify-cleartext-in-region (point-min) (point-max)))
-
-(defun epa--mail-mode-p ()
-  (let ((pointer epa-mail-modes))
-    (while (and pointer
-               (epa--derived-mode-p (car pointer)))
-      (setq pointer (cdr pointer)))
-    pointer))
-
-;;;###autoload
-(defun epa-sign-mail (start end signers mode)
-  "Sign the current buffer.
-The buffer is expected to contain a mail message.
-
-Don't use this command in Lisp programs!"
-  (interactive
-   (save-excursion
-     (goto-char (point-min))
-     (if (and (epa--mail-mode-p)
-             (search-forward mail-header-separator nil t))
-        (forward-line))
-     (setq epa-last-coding-system-specified
-          (or coding-system-for-write
-              (epa--select-safe-coding-system (point) (point-max))))
-     (let ((verbose current-prefix-arg))
-       (list (point) (point-max)
-            (if verbose
-                (epa-select-keys (epg-make-context epa-protocol)
-                                 "Select keys for signing.
-If no one is selected, default secret key is used.  "
-                                 nil t))
-            (if verbose
-                (epa--read-signature-type)
-              'clear)))))
-  (epa-sign-region start end signers mode))
-
-;;;###autoload
-(defun epa-encrypt-mail (start end recipients sign signers)
-  "Encrypt the current buffer.
-The buffer is expected to contain a mail message.
-
-Don't use this command in Lisp programs!"
-  (interactive
-   (save-excursion
-     (let ((verbose current-prefix-arg)
-          (context (epg-make-context epa-protocol))
-          recipients recipient-keys)
-       (goto-char (point-min))
-       (when (epa--mail-mode-p)
-        (save-restriction
-          (narrow-to-region (point)
-                            (if (search-forward mail-header-separator nil 0)
-                                (match-beginning 0)
-                              (point)))
-          (setq recipients
-                (mail-strip-quoted-names
-                 (mapconcat #'identity
-                            (nconc (mail-fetch-field "to" nil nil t)
-                                   (mail-fetch-field "cc" nil nil t)
-                                   (mail-fetch-field "bcc" nil nil t))
-                            ","))))
-        (if recipients
-            (setq recipients (delete ""
-                                     (split-string recipients "[ \t\n]+"))))
-        (goto-char (point-min))
-        (if (search-forward mail-header-separator nil t)
-            (forward-line)))
-       (setq epa-last-coding-system-specified
-            (or coding-system-for-write
-                (epa--select-safe-coding-system (point) (point-max))))
-       (list (point) (point-max)
-            (if verbose
-                (epa-select-keys
-                 context
-                 "Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-                 recipients)
-              (if recipients
-                  (apply #'nconc
-                         (mapcar
-                          (lambda (recipient)
-                            (setq recipient-keys
-                                  (epg-list-keys
-                                   (epg-make-context epa-protocol)
-                                   (concat "<" recipient ">")))
-                            (unless (or recipient-keys
-                                        (y-or-n-p
-                                         (format
-                                          "No public key for %s; skip it? "
-                                          recipient)))
-                              (error "No public key for %s" recipient))
-                            recipient-keys)
-                          recipients))))
-            (setq sign (if verbose (y-or-n-p "Sign? ")))
-            (if sign
-                (epa-select-keys context
-                                 "Select keys for signing.  "))))))
-  (epa-encrypt-region start end recipients sign signers))
-
-;;;###autoload
-(defun epa-import-mail ()
-  "Import keys in the OpenPGP armor format in the current buffer.
-The buffer is expected to contain a mail message.
-
-Don't use this command in Lisp programs!"
-  (interactive)
-  (epa-import-armor-in-region (point-min) (point-max)))
-
 (provide 'epa)
 
 ;;; epa.el ends here