From 81e0c49084d7ed12b5d5b470d4f70126df6d5289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20M=C3=BCller?= Date: Wed, 4 Mar 2020 11:15:52 +0100 Subject: [PATCH] mu4e: Add option to attachment-options to import gpg public key This pull request adds an option to the attachment-options that allows to import pgp-public-keys. --- mu4e/mu4e-view.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index 964c7ec5..8dcb61fd 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -146,6 +146,7 @@ Args EXTENSION and PROGRAM should be specified as strings." ("wopen-with" . mu4e-view-open-attachment-with) ("ein-emacs" . mu4e-view-open-attachment-emacs) ("dimport-in-diary" . mu4e-view-import-attachment-diary) + ("kimport-public-key" . mu4e-view-import-public-key) ("|pipe" . mu4e-view-pipe-attachment)) "List of actions to perform on message attachments. The actions are cons-cells of the form: @@ -1452,6 +1453,13 @@ If PIPECMD is nil, ask user for it." (index (plist-get att :index))) (mu4e~view-temp-action (mu4e-message-field msg :docid) index "diary"))) +(defun mu4e-view-import-public-key (msg attachnum) + "Import MSG's attachment ATTACHNUM into the gpg-keyring." + (interactive) + (let* ((att (mu4e~view-get-attach msg attachnum)) + (index (plist-get att :index))) + (mu4e~view-temp-action (mu4e-message-field msg :docid) index 'gpg))) + (defun mu4e-view-attachment-action (&optional msg) "Ask user what to do with attachments in MSG If MSG is nil use the message returned by `message-at-point'. @@ -1495,6 +1503,8 @@ attachments) in response to a (mu4e~proc-extract 'temp ... )." (setq buffer-read-only t)) ((string= what "diary") (icalendar-import-file path diary-file)) + ((string= what "gpg") + (epa-import-keys path)) (t (mu4e-error "Unsupported action %S" what)))) ;;; View Utilities