* pgg.el (pgg-decrypt-region): Bind pgg-default-user-id to
authorSimon Josefsson <jas@extundo.com>
Thu, 10 Oct 2002 01:22:43 +0000 (01:22 +0000)
committerSimon Josefsson <jas@extundo.com>
Thu, 10 Oct 2002 01:22:43 +0000 (01:22 +0000)
key-identifier in packet.  Is this a good idea?

lisp/ChangeLog
lisp/pgg.el

index ccd3d9d..1204c4c 100644 (file)
@@ -1,5 +1,8 @@
 2002-10-10  Simon Josefsson  <jas@extundo.com>
 
+       * pgg.el (pgg-decrypt-region): Bind pgg-default-user-id to
+       key-identifier in packet.  Is this a good idea?
+
        * mml.el (mml-mode-map): Add security commands that operates on
        MIME parts.
        (mml-menu): And menu items for them.
index 9d1d46d..5b0db55 100644 (file)
@@ -172,10 +172,20 @@ If optional argument SIGN is non-nil, do a combined sign and encrypt."
 (defun pgg-decrypt-region (start end)
   "Decrypt the current region between START and END."
   (interactive "r")
-  (let ((status
-        (pgg-save-coding-system start end
-          (pgg-invoke "decrypt-region" (or pgg-scheme pgg-default-scheme)
-                      (point-min) (point-max)))))
+  (let* ((buf (current-buffer))
+        (packet (cdr (assq 1 (with-temp-buffer
+                               (insert-buffer buf)
+                               (pgg-decode-armor-region
+                                (point-min) (point-max))))))
+        (key (cdr (assq 'key-identifier packet)))
+        (pgg-default-user-id 
+         (if key
+             (concat "0x" (pgg-truncate-key-identifier key))
+           pgg-default-user-id))
+        (status
+         (pgg-save-coding-system start end
+           (pgg-invoke "decrypt-region" (or pgg-scheme pgg-default-scheme)
+                       (point-min) (point-max)))))
     (when (interactive-p)
       (pgg-display-output-buffer start end status))
     status))