You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature request: extend the GPG support to include signing and encrypting, as well as the current decrypting/verification.
This would be a convenience function that structures the email correctly per convention, and encrypts / signs the body and attachments (and not the header).
The text was updated successfully, but these errors were encountered:
Here's a horrible, horrible hack -- when I started this, I didn't know how to declare functions in vim, so this will probably break your computer. It does not encrypt attachments; it does not handle multiple To: recipients; it does not handle CC: or BCC: recipients. If you even put more than one person in the To: it'll probably croak. If you have a really unique email address, it'll fail. In fact, there are probably more fail cases than there are success cases, and you should probably stop reading and go have a soda and read some Calvin and Hobbes. It could do all of these things, but as I said, it's a hack, suitable only for desperate people.
What it does do (when it works) is grab the To: and From: addresses, and encrypt everything after the Attach: line with those two keys. It then replaces the body with the ASCII armored result. It also signs, because why not. The snippet below binds the function to e.
I have this at the end of my .config/nvim/init.vim file; you could have it in your .vimrc. I tried sticking it in notmuch.vim and lost interest when I hit my first error. As I said, desperate ugly solution for desperate (but beautiful) people.
" Encryption for NotMuch
function! ComposeEncrypt()
let l:email = '[A-Za-z0-9._%+-]\+@[A-Za-z0-9.-]\+\.[A-Za-z]\+'
norm 1G
norm /^From:/
let l:from = matchstr(getline('.'), l:email)
norm /^To:/
let l:to = matchstr(getline('.'), l:email)
let l:command = "gpg -ase --recipient " . l:from . " --recipient " . l:to . " --trust-model always"
norm /^Attach:/
norm j
norm ma
exec '.,$yank a'
let @x = system(l:command, @a)
norm 'a
normal VGd
normal "xp
normal :g/^gpg: /d
endfunction
map <Leader>e :call ComposeEncrypt()<CR>
Feature request: extend the GPG support to include signing and encrypting, as well as the current decrypting/verification.
This would be a convenience function that structures the email correctly per convention, and encrypts / signs the body and attachments (and not the header).
The text was updated successfully, but these errors were encountered: