* epa.el (epa-display-info): Generalized; renamed from
[elisp/epg.git] / epa.el
diff --git a/epa.el b/epa.el
index cbed315..9844b75 100644 (file)
--- a/epa.el
+++ b/epa.el
@@ -174,7 +174,6 @@ the separate window."
     (define-key keymap "d" 'epa-decrypt-file)
     (define-key keymap "v" 'epa-verify-file)
     (define-key keymap "s" 'epa-sign-file)
-    (define-key keymap "S" 'epa-sign-keys)
     (define-key keymap "e" 'epa-encrypt-file)
     (define-key keymap "r" 'epa-delete-keys)
     (define-key keymap "i" 'epa-import-keys)
@@ -515,7 +514,7 @@ If SECRET is non-nil, list secret keys instead of public keys."
     (pop-to-buffer (current-buffer))
     (epa-key-mode)))
 
-(defun epa-display-verify-result (verify-result)
+(defun epa-display-info (info)
   (if epa-popup-info-window
       (progn
        (unless epa-info-buffer
@@ -525,13 +524,13 @@ If SECRET is non-nil, list secret keys instead of public keys."
          (let ((inhibit-read-only t)
                buffer-read-only)
            (erase-buffer)
-           (insert (epg-verify-result-to-string verify-result)))
+           (insert info))
          (epa-info-mode))
        (pop-to-buffer epa-info-buffer)
        (if (> (window-height) epa-info-window-height)
            (shrink-window (- (window-height) epa-info-window-height)))
        (goto-char (point-min)))
-    (message "%s" (epg-verify-result-to-string verify-result))))
+    (message "%s" info)))
 
 (defun epa-passphrase-callback-function (context key-id handback)
   (if (eq key-id 'SYM)
@@ -572,7 +571,8 @@ If SECRET is non-nil, list secret keys instead of public keys."
     (epg-decrypt-file context file plain)
     (message "Decrypting %s...done" (file-name-nondirectory file))
     (if (epg-context-result-for context 'verify)
-       (epa-display-verify-result (epg-context-result-for context 'verify)))))
+       (epa-display-info (epg-verify-result-to-string
+                          (epg-context-result-for context 'verify))))))
 
 ;;;###autoload
 (defun epa-verify-file (file)
@@ -587,7 +587,8 @@ If SECRET is non-nil, list secret keys instead of public keys."
     (epg-verify-file context file plain)
     (message "Verifying %s...done" (file-name-nondirectory file))
     (if (epg-context-result-for context 'verify)
-       (epa-display-verify-result (epg-context-result-for context 'verify)))))
+       (epa-display-info (epg-verify-result-to-string
+                          (epg-context-result-for context 'verify))))))
 
 ;;;###autoload
 (defun epa-sign-file (file signers mode)
@@ -659,7 +660,8 @@ Don't use this command in Lisp programs!"
       (goto-char start)
       (insert (decode-coding-string plain coding-system-for-read))
       (if (epg-context-result-for context 'verify)
-         (epa-display-verify-result (epg-context-result-for context 'verify))))))
+         (epa-display-info (epg-verify-result-to-string
+                            (epg-context-result-for context 'verify)))))))
 
 ;;;###autoload
 (defun epa-decrypt-armor-in-region (start end)
@@ -703,11 +705,13 @@ Don't use this command in Lisp programs!"
                        (buffer-substring start end)
                        coding-system-for-write))
     (if (epg-context-result-for context 'verify)
-       (epa-display-verify-result (epg-context-result-for context 'verify)))))
+       (epa-display-info (epg-verify-result-to-string
+                          (epg-context-result-for context 'verify))))))
 
 ;;;###autoload
-(defun epa-verify-armor-in-region (start end)
-  "Verify OpenPGP armors in the current region between START and END.
+(defun epa-verify-cleartext-in-region (start end)
+  "Verify OpenPGP cleartext signed messages in the current region
+between START and END.
 
 Don't use this command in Lisp programs!"
   (interactive "r")
@@ -716,20 +720,15 @@ Don't use this command in Lisp programs!"
       (narrow-to-region start end)
       (goto-char start)
       (let (armor-start armor-end)
-       (while (re-search-forward "-----BEGIN PGP\\( SIGNED\\)? MESSAGE-----$"
+       (while (re-search-forward "-----BEGIN PGP SIGNED MESSAGE-----$"
                                  nil t)
          (setq armor-start (match-beginning 0))
-         (if (match-beginning 1)       ;cleartext signed message
-             (progn
-               (unless (re-search-forward "^-----BEGIN PGP SIGNATURE-----$"
+         (unless (re-search-forward "^-----BEGIN PGP SIGNATURE-----$"
                                           nil t)
-                 (error "Invalid cleartext signed message"))
-               (setq armor-end (re-search-forward
-                                "^-----END PGP SIGNATURE-----$"
-                                nil t)))
-           (setq armor-end (re-search-forward
-                            "^-----END PGP MESSAGE-----$"
-                            nil t)))
+           (error "Invalid cleartext signed message"))
+         (setq armor-end (re-search-forward
+                          "^-----END PGP SIGNATURE-----$"
+                          nil t))
          (unless armor-end
            (error "No armor tail"))
          (epa-verify-region armor-start armor-end))))))
@@ -798,7 +797,9 @@ If no one is selected, symmetric encryption will be performed.  ")))
 
 ;;;###autoload
 (defun epa-delete-keys (keys &optional allow-secret)
-  "Delete selected KEYS."
+  "Delete selected KEYS.
+
+Don't use this command in Lisp programs!"
   (interactive
    (let ((keys (epa--marked-keys)))
      (unless keys
@@ -813,17 +814,23 @@ If no one is selected, symmetric encryption will be performed.  ")))
 
 ;;;###autoload
 (defun epa-import-keys (file)
-  "Import keys from FILE."
+  "Import keys from FILE.
+
+Don't use this command in Lisp programs!"
   (interactive "fFile: ")
   (let ((context (epg-make-context)))
     (message "Importing %s..." (file-name-nondirectory file))
     (epg-import-keys-from-file context (expand-file-name file))
     (message "Importing %s...done" (file-name-nondirectory file))
-    (apply #'epa-list-keys epa-list-keys-arguments)))
+    (if (epg-context-result-for context 'import)
+       (epa-display-info (epg-import-result-to-string
+                          (epg-context-result-for context 'import)))))
 
 ;;;###autoload
 (defun epa-export-keys (keys file)
-  "Export selected KEYS to FILE."
+  "Export selected KEYS to FILE.
+
+Don't use this command in Lisp programs!"
   (interactive
    (let ((keys (epa--marked-keys))
         default-name)
@@ -851,7 +858,9 @@ If no one is selected, symmetric encryption will be performed.  ")))
 ;;;###autoload
 (defun epa-sign-keys (keys &optional local)
   "Sign selected KEYS.
-If LOCAL is non-nil, the signature is marked as non exportable."
+If a prefix-arg is specified, the signature is marked as non exportable.
+
+Don't use this command in Lisp programs!"
   (interactive
    (let ((keys (epa--marked-keys)))
      (unless keys
@@ -865,6 +874,7 @@ If LOCAL is non-nil, the signature is marked as non exportable."
     (message "Signing keys...")
     (epg-sign-keys context keys local)
     (message "Signing keys...done")))
+(make-obsolete 'epa-sign-keys "Do not use.")
 
 (provide 'epa)