Configuring Autocrypt in Emacs/Gnus
I was asked about this on Lemmy, but there's a bit more to it than a short message.
After learning several "standard" UIs that subsequently disappeared, I try to do client-side things in Emacs if it seems sensible. Reading email is one such task, since I personally rarely need anything other than plain text support. Here I describe my general Gnus configuration, and later the parts relevant to autocrypt.
If the previous paragraph bamboozled you, here is a quick glossary:
- A User Interface (UI) is a way for a human to perform input/output to/from a computer in order to do a task.
- Emacs is a venerable text editor that has gradually expanded to be more of an app platform, where editing text is one such app.
- Gnus is another such app for reading USENET and email (there are several alternatives). Gnus is bundled with core Emacs.
- Autocrypt is a protocol to enable opportunistic encryption over email. Also marketed as an instant messenger, but I'm not sure whether or not that is a good idea.
I don't *think* it's very important for the contents of this post, but I do use emacs-bedrock as a starter kit for configuring Emacs.
Having written this, it really is a path for lazy people who can't be bothered learning a new interaction style or email package every few years. I suspect Emacs will be able to do almost anything you want, no matter how many years into the future, with some minor customization. One exception I think is graphics-heavy work, which is better in a Web browser but browsers are many times more heavyweight.
Gnus
I use Posteo as an email provider. Translation to Google or someone else should be straightforward. Add the following to ~/.emacs.d/init.el:
(setq gnus-select-method '(nnimap "posteo.de")) (setq user-mail-address "nobody@example.com") ;; Obviously change this
Now you'll have to customize some variables, e.g. using `M-x customize-variable`:
- send-mail-function := smtpmail-send-it
- smtpmail-smtp-server := "posteo.de"
- smtpmail-smtp-service := 465
- smtpmail-stream-type := ssl
This should take care of basic IMAP & SMTP.
Autocrypt
This requires packages that are *not* part of core Emacs. In particular, you'll need autocrypt and pinentry. I use MELPA and `M-x list-packages `to install packages like this. You'll also need to install GnuPG outside Emacs in your OS, I used the Homebrew package manage to do this on macOS. Then you'll need to add the following to your init.el:
(pinentry-start) (add-hook 'gnus-mode-hook #'autocrypt-mode) (add-hook 'message-mode-hook #'autocrypt-mode)
and the following variables must be customized:
- epg-gpg-program := "/opt/homebrew/bin/gpg"
- epg-gpgconf-program := "/opt/homebrew/bin/gpgconf"
- epg-gpgsm-program := "/opt/homebrew/bin/gpgsm"
- epg-pinentry-mode := loopback
Now I only did it once so I'm not 100% sure, but I think you don't need to create a GnuPG key from the command line as usual. Instead, autocrypt can do it using `M-x autocrypt-create-account`, and this will also add an autocrypt-accounts custom variable.
That's it, from then on you can just run `M-x gnus` and read the comprehensive Info-format documentation for this package. Seems like a bit of work, but as I said at the start, this is likely to work until you retire or die and you won't have to learn a different way.
Source