OSDN Git Service

* epa.el (epa-import-armor-in-region): New command.
authorDaiki Ueno <ueno@unixuser.org>
Sun, 31 Dec 2006 02:10:33 +0000 (02:10 +0000)
committerDaiki Ueno <ueno@unixuser.org>
Sun, 31 Dec 2006 02:10:33 +0000 (02:10 +0000)
(epa-import): New command.

ChangeLog
epa.el

index 3643122..0dcf182 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@
        (epa-verify): New command.
        (epa-sign): New command.
        (epa-encrypt): New command.
+       (epa-import-armor-in-region): New command.
+       (epa-import): New command.
 
 2006-12-29  Daiki Ueno  <ueno@unixuser.org>
 
diff --git a/epa.el b/epa.el
index 2af91fc..6c48380 100644 (file)
--- a/epa.el
+++ b/epa.el
@@ -1074,6 +1074,37 @@ Don't use this command in Lisp programs!"
                           (epg-context-result-for context 'import))))))
 
 ;;;###autoload
+(defun epa-import-armor-in-region (start end)
+  "Import keys in the OpenPGP armor format in the current region
+between START and END.
+
+Don't use this command in Lisp programs!"
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region start end)
+      (goto-char start)
+      (let (armor-start armor-end)
+       (while (re-search-forward
+               "-----BEGIN \\(PGP \\(PUBLIC\\|PRIVATE\\) KEY BLOCK\\)-----$"
+               nil t)
+         (setq armor-start (match-beginning 0)
+               armor-end (re-search-forward
+                          (concat "^-----END " (match-string 1) "-----$")
+                          nil t))
+         (unless armor-end
+           (error "No armor tail"))
+         (epa-import-keys-region armor-start armor-end))))))
+
+;;;###autoload
+(defun epa-import ()
+  "Import keys in the OpenPGP armor format in the current buffer.
+
+Don't use this command in Lisp programs!"
+  (interactive)
+  (epa-import-armor-in-region (point-min) (point-max)))
+
+;;;###autoload
 (defun epa-export-keys (keys file)
   "Export selected KEYS to FILE.