Clear GPGOptions/GPGRecipients autocommands on BufUnload

The BufHidden autocommand will have already called the respective Finish
function.  Clearing the autocommands during BufUnload ensures they don't
inadvertently run when Vim is shutting down.

Closes jamessan/vim-gnupg#104
This commit is contained in:
James McCoy
2020-11-11 13:04:00 -05:00
parent 1537043c19
commit 6b56cdceda

View File

@@ -1,5 +1,5 @@
" Name: autoload/gnupg.vim " Name: autoload/gnupg.vim
" Last Change: 2020 Nov 09 " Last Change: 2020 Nov 11
" Maintainer: James McCoy <jamessan@jamessan.com> " Maintainer: James McCoy <jamessan@jamessan.com>
" Original Author: Markus Braun <markus.braun@krawel.de> " Original Author: Markus Braun <markus.braun@krawel.de>
" Summary: Vim plugin for transparent editing of gpg encrypted files. " Summary: Vim plugin for transparent editing of gpg encrypted files.
@@ -685,7 +685,8 @@ function gnupg#edit_recipients()
augroup GPGRecipients augroup GPGRecipients
au! * <buffer> au! * <buffer>
" add a autocommand to regenerate the recipients after a write " add a autocommand to regenerate the recipients after a write
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer() autocmd BufHidden,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
autocmd BufUnload <buffer> exe 'au! GPGRecipients * <buffer='. expand('<abuf>') .'>'
augroup END augroup END
" put some comments to the scratch buffer " put some comments to the scratch buffer
@@ -861,7 +862,8 @@ function gnupg#edit_options()
augroup GPGOptions augroup GPGOptions
au! * <buffer> au! * <buffer>
" add a autocommand to regenerate the options after a write " add a autocommand to regenerate the options after a write
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer() autocmd BufHidden,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
autocmd BufUnload <buffer> exe 'au! GPGOptions * <buffer='. expand('<abuf>') .'>'
augroup END augroup END
" put some comments to the scratch buffer " put some comments to the scratch buffer