From 32360c8f20a91564dbb0b9b59343248acddc7b42 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 11 Feb 2019 23:23:14 -0500 Subject: [PATCH] Define GPGEdit{Options,Recipients} autocmd in their own group This allows them to be properly cleared only when the buffer is re-created/loaded. This fixes the handling of the autocmds when the Edit buffer is saved, but not hidden or deleted. The autocmd remains in place, rather than having an acwrite buffer with no autocmd set. Signed-off-by: James McCoy --- autoload/gnupg.vim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/autoload/gnupg.vim b/autoload/gnupg.vim index afae8cd..5d43bdf 100644 --- a/autoload/gnupg.vim +++ b/autoload/gnupg.vim @@ -680,8 +680,11 @@ function gnupg#edit_recipients() endif if s:NewInputBuffer('GPGRecipients') - " add a autocommand to regenerate the recipients after a write - autocmd BufHidden,BufUnload,BufWriteCmd call s:GPGFinishRecipientsBuffer() + augroup GPGRecipients + au! * + " add a autocommand to regenerate the recipients after a write + autocmd BufHidden,BufUnload,BufWriteCmd call s:GPGFinishRecipientsBuffer() + augroup END " put some comments to the scratch buffer silent put ='GPG: ----------------------------------------------------------------------' @@ -767,9 +770,6 @@ function s:GPGFinishRecipientsBuffer() execute 'silent! ' . bufwinnr(expand(":p")) . "wincmd w" endif - " delete the autocommand - autocmd! * - " get the recipients from the scratch buffer let recipients = [] let lines = getline(1,"$") @@ -856,8 +856,11 @@ function gnupg#edit_options() " only do this if it isn't already a GPGOptions_* buffer if s:NewInputBuffer('GPGOptions') - " add a autocommand to regenerate the options after a write - autocmd BufHidden,BufUnload,BufWriteCmd call s:GPGFinishOptionsBuffer() + augroup GPGOptions + au! * + " add a autocommand to regenerate the options after a write + autocmd BufHidden,BufUnload,BufWriteCmd call s:GPGFinishOptionsBuffer() + augroup END " put some comments to the scratch buffer silent put ='GPG: ----------------------------------------------------------------------' @@ -916,9 +919,6 @@ function s:GPGFinishOptionsBuffer() let options = [] let unknownOptions = [] - " delete the autocommand - autocmd! * - " get the options from the scratch buffer let lines = getline(1, "$") for option in lines