Trigger FileReadPost event after decrypting for :r

Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
James McCoy 2015-01-05 22:53:47 -05:00
parent cdf98c6af9
commit 380f05d2e9

View File

@ -186,8 +186,7 @@ augroup GnuPG
" do the decryption
exe "autocmd BufReadCmd " . g:GPGFilePattern . " call s:GPGInit(1) |" .
\ " call s:GPGDecrypt(1) |" .
\ " call s:GPGBufReadPost()"
\ " call s:GPGDecrypt(1) |"
exe "autocmd FileReadCmd " . g:GPGFilePattern . " call s:GPGInit(0) |" .
\ " call s:GPGDecrypt(0)"
@ -545,19 +544,7 @@ function s:GPGDecrypt(bufread)
return
endif
" refresh screen
redraw!
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()")
endfunction
" Function: s:GPGBufReadPost() {{{2
"
" Handle functionality specific to opening a file for reading rather than
" reading the contents of a file into a buffer
"
function s:GPGBufReadPost()
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGBufReadPost()")
if a:bufread
" In order to make :undo a no-op immediately after the buffer is read,
" we need to do this dance with 'undolevels'. Actually discarding the undo
" history requires performing a change after setting 'undolevels' to -1 and,
@ -571,12 +558,22 @@ function s:GPGBufReadPost()
1mark [
$mark ]
let &undolevels = levels
" Allow the user to define actions for GnuPG buffers
silent doautocmd User GnuPG
" call the autocommand for the file minus .gpg$
silent execute ':doautocmd BufReadPost ' . fnameescape(expand('<afile>:r'))
call s:GPGDebug(2, 'called BufReadPost autocommand for ' . fnameescape(expand('<afile>:r')))
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGBufReadPost()")
else
" call the autocommand for the file minus .gpg$
silent execute ':doautocmd FileReadPost ' . fnameescape(expand('<afile>:r'))
call s:GPGDebug(2, 'called FileReadPost autocommand for ' . fnameescape(expand('<afile>:r')))
endif
" Allow the user to define actions for GnuPG buffers
silent doautocmd User GnuPG
" refresh screen
redraw!
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGDecrypt()")
endfunction
" Function: s:GPGEncrypt() {{{2