Merge branch 'autochdir'
This commit is contained in:
commit
5b069789e2
@ -1,5 +1,5 @@
|
|||||||
" Name: gnupg.vim
|
" Name: gnupg.vim
|
||||||
" Last Change: 2017 May 31
|
" Last Change: 2017 Oct 22
|
||||||
" 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.
|
||||||
@ -455,7 +455,7 @@ function s:GPGDecrypt(bufread)
|
|||||||
call s:GPGDebug(3, printf(">>>>>>>> Entering s:GPGDecrypt(%d)", a:bufread))
|
call s:GPGDebug(3, printf(">>>>>>>> Entering s:GPGDecrypt(%d)", a:bufread))
|
||||||
|
|
||||||
" get the filename of the current buffer
|
" get the filename of the current buffer
|
||||||
let filename = expand("<afile>:p")
|
let filename = resolve(expand("<afile>:p"))
|
||||||
|
|
||||||
" clear GPGRecipients and GPGOptions
|
" clear GPGRecipients and GPGOptions
|
||||||
if type(g:GPGDefaultRecipients) == type([])
|
if type(g:GPGDefaultRecipients) == type([])
|
||||||
@ -469,7 +469,7 @@ function s:GPGDecrypt(bufread)
|
|||||||
let b:GPGOptions = []
|
let b:GPGOptions = []
|
||||||
|
|
||||||
" file name minus extension
|
" file name minus extension
|
||||||
let autocmd_filename = expand('<afile>:r')
|
let autocmd_filename = fnamemodify(filename, ':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)
|
||||||
@ -478,6 +478,12 @@ function s:GPGDecrypt(bufread)
|
|||||||
silent execute ':doautocmd BufNewFile ' . fnameescape(autocmd_filename)
|
silent execute ':doautocmd BufNewFile ' . fnameescape(autocmd_filename)
|
||||||
call s:GPGDebug(2, 'called BufNewFile autocommand for ' . autocmd_filename)
|
call s:GPGDebug(2, 'called BufNewFile autocommand for ' . autocmd_filename)
|
||||||
|
|
||||||
|
set buftype=acwrite
|
||||||
|
" Remove the buffer name ...
|
||||||
|
silent 0file
|
||||||
|
" ... so we can force it to be absolute
|
||||||
|
exe 'silent file' 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
|
||||||
if (g:GPGPreferSymmetric == 0)
|
if (g:GPGPreferSymmetric == 0)
|
||||||
@ -603,6 +609,10 @@ function s:GPGDecrypt(bufread)
|
|||||||
endif
|
endif
|
||||||
" Ensure the buffer is only saved by using our BufWriteCmd
|
" Ensure the buffer is only saved by using our BufWriteCmd
|
||||||
set buftype=acwrite
|
set buftype=acwrite
|
||||||
|
" Always set the buffer name to the absolute path, otherwise Vim won't
|
||||||
|
" track the correct buffer name when changing directories (due to
|
||||||
|
" buftype=acwrite).
|
||||||
|
exe 'file' filename
|
||||||
else
|
else
|
||||||
execute silent 'read' fnameescape(filename)
|
execute silent 'read' fnameescape(filename)
|
||||||
endif
|
endif
|
||||||
@ -661,7 +671,7 @@ function s:GPGEncrypt()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" file name minus extension
|
" file name minus extension
|
||||||
let autocmd_filename = expand('<afile>:r')
|
let autocmd_filename = expand('<afile>:p:r')
|
||||||
|
|
||||||
silent exe ':doautocmd '. auType .'Pre '. fnameescape(autocmd_filename)
|
silent exe ':doautocmd '. auType .'Pre '. fnameescape(autocmd_filename)
|
||||||
call s:GPGDebug(2, 'called '. auType .'Pre autocommand for ' . autocmd_filename)
|
call s:GPGDebug(2, 'called '. auType .'Pre autocommand for ' . autocmd_filename)
|
||||||
@ -675,7 +685,7 @@ function s:GPGEncrypt()
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let filename = resolve(expand('<afile>'))
|
let filename = resolve(expand('<afile>:p'))
|
||||||
" initialize GPGOptions if not happened before
|
" initialize GPGOptions if not happened before
|
||||||
if (!exists("b:GPGOptions") || empty(b:GPGOptions))
|
if (!exists("b:GPGOptions") || empty(b:GPGOptions))
|
||||||
let b:GPGOptions = []
|
let b:GPGOptions = []
|
||||||
@ -751,7 +761,10 @@ function s:GPGEncrypt()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if auType == 'BufWrite'
|
if auType == 'BufWrite'
|
||||||
setl nomodified
|
if expand('%:p') == filename
|
||||||
|
setl nomodified
|
||||||
|
endif
|
||||||
|
setl buftype=acwrite
|
||||||
let &readonly = filereadable(filename) && filewritable(filename) == 0
|
let &readonly = filereadable(filename) && filewritable(filename) == 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -938,7 +951,7 @@ function s:GPGFinishRecipientsBuffer()
|
|||||||
" go to buffer before doing work
|
" go to buffer before doing work
|
||||||
if (bufnr("%") != expand("<abuf>"))
|
if (bufnr("%") != expand("<abuf>"))
|
||||||
" switch to scratch buffer window
|
" switch to scratch buffer window
|
||||||
execute 'silent! ' . bufwinnr(expand("<afile>")) . "wincmd w"
|
execute 'silent! ' . bufwinnr(expand("<afile>:p")) . "wincmd w"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" delete the autocommand
|
" delete the autocommand
|
||||||
@ -1121,7 +1134,7 @@ function s:GPGFinishOptionsBuffer()
|
|||||||
" go to buffer before doing work
|
" go to buffer before doing work
|
||||||
if (bufnr("%") != expand("<abuf>"))
|
if (bufnr("%") != expand("<abuf>"))
|
||||||
" switch to scratch buffer window
|
" switch to scratch buffer window
|
||||||
execute 'silent! ' . bufwinnr(expand("<afile>")) . "wincmd w"
|
execute 'silent! ' . bufwinnr(expand("<afile>:p")) . "wincmd w"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" clear options and unknownOptions
|
" clear options and unknownOptions
|
||||||
|
Loading…
Reference in New Issue
Block a user