* Makefile.am (EXTRA_DIST): Added epa-mail.el.
* COMPILE (epg-modules): Added epa-mail.
* epa-mail.el: New file.
;;; -*- 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))
+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.
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
--- /dev/null
+;;; 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
(require 'font-lock)
(require 'widget)
(eval-when-compile (require 'wid-edit))
-(require 'mail-utils)
(require 'derived)
(defgroup epa nil
: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)
(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.
(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