From: Jamie Beardslee <beardsleejamie@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Gnus: Store message in PGP-decrypted form
Date: Wed, 10 Jun 2020 13:38:14 +1200 [thread overview]
Message-ID: <87lfkv4s55.fsf@gmail.com> (raw)
In-Reply-To: 87bllszmy9.fsf@guelker.eu
[-- Attachment #1: Type: text/plain, Size: 1387 bytes --]
It's not exactly what you want, but `epa-decrypt-region' usually works
for my needs. In any case, here's a little function to decrypt some
saved mail.
(defun decrypt-saved-message (file &optional save)
"Decrypt a plaintext mail FILE.
With prefix arg SAVE, save the decrypted contents."
(interactive "F\nP")
(require 'epa-mail)
(let ((buffer (get-buffer-create
(format "%s *decrypted*"
(file-name-nondirectory file)))))
(pop-to-buffer buffer)
(insert-file-contents file)
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
(setq armor-start (match-beginning 0)
armor-end (re-search-forward "^-----END PGP MESSAGE-----$"
nil t))
(unless armor-end
(error "Encryption armor beginning has no matching end"))
(goto-char armor-start)
(let* ((context (epg-make-context 'OpenPGP))
(decrypted (epg-decrypt-string
context
(buffer-substring armor-start armor-end))))
(delete-region armor-start armor-end)
(insert decrypted)))
(when (or save (y-or-n-p "Save mail in decrypted form?"))
(write-file file))))
It can be used interactively, or if you want to decrypt a bunch of saved
mails you can call it from lisp with a second argument:
(dolist (f '("~/mail1" "~/mail2" ...))
(decrypt-saved-message f t))
Surely this can be hacked a bit to make gnus decrypt the mail before
saving...
--
Jamie
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 519 bytes --]
next prev parent reply other threads:[~2020-06-10 1:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-09 8:02 Gnus: Store message in PGP-decrypted form Marvin ‘quintus’ Gülker
2020-06-10 1:38 ` Jamie Beardslee [this message]
2020-06-10 1:49 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-06-10 1:57 ` Jamie Beardslee
2020-06-10 2:05 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-06-10 8:42 ` Marvin ‘quintus’ Gülker
2020-06-10 6:50 ` Teemu Likonen
2020-06-10 8:40 ` Marvin ‘quintus’ Gülker
2020-06-10 9:12 ` Mail folders and searches Teemu Likonen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lfkv4s55.fsf@gmail.com \
--to=beardsleejamie@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.