use variable for fnameescape(expand('<afile>:r'))

Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
Simon Ruderich 2015-10-03 16:27:17 +02:00 committed by James McCoy
parent 39bc3f96c1
commit 842622cbc0
No known key found for this signature in database
GPG Key ID: DFE691AE331BA3DB

View File

@ -447,13 +447,16 @@ function s:GPGDecrypt(bufread)
endif endif
let b:GPGOptions = [] let b:GPGOptions = []
" file name minus extension
let autocmd_filename = fnameescape(expand('<afile>:r'))
" File doesn't exist yet, so nothing to decrypt " File doesn't exist yet, so nothing to decrypt
if !filereadable(filename) if !filereadable(filename)
" Allow the user to define actions for GnuPG buffers " Allow the user to define actions for GnuPG buffers
silent doautocmd User GnuPG silent doautocmd User GnuPG
" call the autocommand for the file minus .gpg$ " call the autocommand for the file minus .gpg$
silent execute ':doautocmd BufNewFile ' . fnameescape(expand('<afile>:r')) silent execute ':doautocmd BufNewFile ' . autocmd_filename
call s:GPGDebug(2, 'called BufNewFile autocommand for ' . fnameescape(expand('<afile>:r'))) call s:GPGDebug(2, 'called BufNewFile autocommand for ' . autocmd_filename)
" This is a new file, so force the user to edit the recipient list if " This is a new file, so force the user to edit the recipient list if
" they open a new file and public keys are preferred " they open a new file and public keys are preferred
@ -536,11 +539,11 @@ function s:GPGDecrypt(bufread)
endif endif
if a:bufread if a:bufread
silent execute ':doautocmd BufReadPre ' . fnameescape(expand('<afile>:r')) silent execute ':doautocmd BufReadPre ' . autocmd_filename
call s:GPGDebug(2, 'called BufReadPre autocommand for ' . fnameescape(expand('<afile>:r'))) call s:GPGDebug(2, 'called BufReadPre autocommand for ' . autocmd_filename)
else else
silent execute ':doautocmd FileReadPre ' . fnameescape(expand('<afile>:r')) silent execute ':doautocmd FileReadPre ' . autocmd_filename
call s:GPGDebug(2, 'called FileReadPre autocommand for ' . fnameescape(expand('<afile>:r'))) call s:GPGDebug(2, 'called FileReadPre autocommand for ' . autocmd_filename)
endif endif
" check if the message is armored " check if the message is armored
@ -585,12 +588,12 @@ function s:GPGDecrypt(bufread)
$mark ] $mark ]
let &undolevels = levels let &undolevels = levels
" call the autocommand for the file minus .gpg$ " call the autocommand for the file minus .gpg$
silent execute ':doautocmd BufReadPost ' . fnameescape(expand('<afile>:r')) silent execute ':doautocmd BufReadPost ' . autocmd_filename
call s:GPGDebug(2, 'called BufReadPost autocommand for ' . fnameescape(expand('<afile>:r'))) call s:GPGDebug(2, 'called BufReadPost autocommand for ' . autocmd_filename)
else else
" call the autocommand for the file minus .gpg$ " call the autocommand for the file minus .gpg$
silent execute ':doautocmd FileReadPost ' . fnameescape(expand('<afile>:r')) silent execute ':doautocmd FileReadPost ' . autocmd_filename
call s:GPGDebug(2, 'called FileReadPost autocommand for ' . fnameescape(expand('<afile>:r'))) call s:GPGDebug(2, 'called FileReadPost autocommand for ' . autocmd_filename)
endif endif
" Allow the user to define actions for GnuPG buffers " Allow the user to define actions for GnuPG buffers
@ -619,8 +622,11 @@ function s:GPGEncrypt()
let auType = 'FileWrite' let auType = 'FileWrite'
endif endif
silent exe ':doautocmd '. auType .'Pre '. fnameescape(expand('<afile>:r')) " file name minus extension
call s:GPGDebug(2, 'called '. auType .'Pre autocommand for ' . fnameescape(expand('<afile>:r'))) let autocmd_filename = fnameescape(expand('<afile>:r'))
silent exe ':doautocmd '. auType .'Pre '. autocmd_filename
call s:GPGDebug(2, 'called '. auType .'Pre autocommand for ' . autocmd_filename)
" store encoding and switch to a safe one " store encoding and switch to a safe one
if (&fileencoding != &encoding) if (&fileencoding != &encoding)
@ -714,8 +720,8 @@ function s:GPGEncrypt()
setl nomodified setl nomodified
endif endif
silent exe ':doautocmd '. auType .'Post '. fnameescape(expand('<afile>:r')) silent exe ':doautocmd '. auType .'Post '. autocmd_filename
call s:GPGDebug(2, 'called '. auType .'Post autocommand for ' . fnameescape(expand('<afile>:r'))) call s:GPGDebug(2, 'called '. auType .'Post autocommand for ' . autocmd_filename)
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()") call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEncrypt()")
endfunction endfunction