* pgg-epg.el (pgg-epg-encrypt-region): Ask a user whether to skip a
authorueno <ueno>
Fri, 5 Jan 2007 00:34:43 +0000 (00:34 +0000)
committerueno <ueno>
Fri, 5 Jan 2007 00:34:43 +0000 (00:34 +0000)
recipient whose public key is not available.

ChangeLog
pgg-epg.el

index e4424b7..2b15539 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2007-01-05  Daiki Ueno  <ueno@unixuser.org>
 
+       * pgg-epg.el (pgg-epg-encrypt-region): Ask a user whether to skip a
+       recipient whose public key is not available.
        * epa.el (epa-encrypt-mail): Ask a user whether to skip a
        recipient whose public key is not available.
 
index 86c6155..16fe555 100644 (file)
@@ -65,7 +65,7 @@ If optional PASSPHRASE is not specified, it will be obtained from the
 passphrase cache or user."
   (let ((context (epg-make-context))
        (inhibit-redisplay t)           ;Gnus users don't like flickering
-       cipher)
+       cipher recipient-keys)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context pgg-text-mode)
     (epg-context-set-passphrase-callback context #'pgg-epg-passphrase-callback)
@@ -76,15 +76,24 @@ passphrase cache or user."
       (erase-buffer))
     (condition-case error
        (setq cipher
-             (epg-encrypt-string context
-                                 (buffer-substring start end)
-                                 (mapcar
-                                  (lambda (recipient)
-                                    (car (epg-list-keys context recipient)))
-                                  (if pgg-encrypt-for-me
-                                      (cons pgg-default-user-id recipients)
-                                    recipients))
-                                 sign t)
+             (epg-encrypt-string
+              context
+              (buffer-substring start end)
+              (apply #'nconc
+                     (mapcar
+                      (lambda (recipient)
+                        (setq recipient-keys
+                              (epg-list-keys context 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)
+                      (if pgg-encrypt-for-me
+                          (cons pgg-default-user-id recipients)
+                        recipients)))
+              sign t)
              pgg-epg-secret-key-id-list nil)
       (error
        (while pgg-epg-secret-key-id-list