diff options
author | Thierry Volpiatto <thievol@posteo.net> | 2020-08-17 07:06:15 +0200 |
---|---|---|
committer | Thierry Volpiatto <thievol@posteo.net> | 2020-08-17 07:24:21 +0200 |
commit | 5c8ad6a370b0e157934f119b1aa9c3c2f44149ff (patch) | |
tree | c82bb142fe42a05b5351ba7dad7c1c1f0407dbbe /helm-misc.el | |
parent | 65a5ed63feba4840be5ea039bb41e336c627f64d (diff) |
Add action to helm-epa
Diffstat (limited to 'helm-misc.el')
-rw-r--r-- | helm-misc.el | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/helm-misc.el b/helm-misc.el index 26499d25..7f5b1087 100644 --- a/helm-misc.el +++ b/helm-misc.el @@ -331,15 +331,18 @@ Default action change TZ environment variable locally to emacs." (defvar epa-protocol) (defvar epa-last-coding-system-specified) (defvar mail-header-separator) -(declare-function epg-list-keys "epg") -(declare-function epg-make-context "epg") -(declare-function epg-key-sub-key-list "epg") -(declare-function epg-sub-key-id "epg") -(declare-function epg-key-user-id-list "epg") -(declare-function epg-user-id-string "epg") -(declare-function epg-user-id-validity "epg") -(declare-function epa-sign-region "epg") -(declare-function epa--read-signature-type "epg") +(declare-function epg-list-keys "epg") +(declare-function epg-make-context "epg") +(declare-function epg-key-sub-key-list "epg") +(declare-function epg-sub-key-id "epg") +(declare-function epg-key-user-id-list "epg") +(declare-function epg-user-id-string "epg") +(declare-function epg-user-id-validity "epg") +(declare-function epa-sign-region "epg") +(declare-function epa--read-signature-type "epg") +(declare-function epa-display-error "epg") +(declare-function epg-export-keys-to-string "epg") +(declare-function epg-context-armor "epg") (defun helm-epg-get-key-list () "Build candidate list for `helm-list-epg-keys'." @@ -375,6 +378,18 @@ Default action change TZ environment variable locally to emacs." (epa-encrypt-file file candidate) (message "File encrypted with key `%s %s'" key id))) +(defun helm-epa-kill-keys-armor (_candidate) + "Copy marked keys to kill ring." + (let ((keys (helm-marked-candidates)) + (context (epg-make-context epa-protocol))) + (with-no-warnings + (setf (epg-context-armor context) t)) + (condition-case error + (kill-new (epg-export-keys-to-string context keys)) + (error + (epa-display-error context) + (signal (car error) (cdr error)))))) + (defun helm-epa-mail-sign (candidate) "Sign email with key CANDIDATE." (let ((key (epg-sub-key-id (car (epg-key-sub-key-list candidate)))) @@ -431,6 +446,7 @@ This is the helm interface for `epa-list-keys'." :candidates 'helm-epg-get-key-list :action '(("Show key" . epa--show-key) ("encrypt file with key" . helm-epa-encrypt-file) + ("Copy keys to kill ring" . helm-epa-kill-keys-armor) ;; TODO filter these actions according to context. ("Sign mail with key" . helm-epa-mail-sign) ("Encrypt mail with key" . helm-epa-mail-encrypt))) |