Emacs: Crypto: How to get automatic encryption?

Antoine Beaupré anarcat at anarcat.ath.cx
Mon Jan 16 20:48:36 PST 2012


Jumping in here, I have modified the previously posted code here to
provide me with a more complete solution.

With the attach code, I can:

 * automatically encrypt mails if all recipients have a *valid* public
   key. The previous patch allowed encryption if a key existed but was
   revoked, which cause a weird UX issue where the user would be
   bothered with "No public key for..."

 * not have specify if i want to encrypt the mail or not: it is
   encrypted if possible

 * try to autodetect (by running the function directly) if the mail will
   be crypted and signed or just signed before sending

 * explicitely request the mail to be encrypted or just signed, if I
   want to, using the usual keybindings (ie. the existing #secure tags
   are respected)

So basically, this replaces the common hook:

(add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)

with this:

(add-hook 'message-send-hook 'anarcat/message-set-encryption)

The rationale behind this technique is that the setup-hook runs when
recipients are not yet defined so it will always set the mail to be only
signed, even though your final recipients should be crypted. 

An alternative would be for notmuch to prompt the To: header before
setting up the buffer ("à la" Mutt), but I didn't feel like going that
way.

Code is attached. Obviously, those function names would change if they
would be to integrate into notmuch. ;)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: notmuch-opportunistic.el
Type: application/emacs-lisp
Size: 1839 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20120117/63fd06ae/attachment.bin>
-------------- next part --------------

Opportunistic encryption, here we go.

a.

-- 
Evil exists to glorify the good. Evil is negative good.
It is a relative term. Evil can be transmuted into good.
What is evil to one at one time,
becomes good at another time to somebody else.
                        - Sivananda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20120117/63fd06ae/attachment.pgp>


More information about the notmuch mailing list