mirror of
https://github.com/Ascyii/vim-gnupg.git
synced 2026-01-01 06:14:24 -05:00
Add g:GPGFilePattern to allow custom target filename patterns.
This can be really handy when using vim as an external editor for a program (via temporary files) that you'd like to be able to encrypt based on the temp file's name (for example, when using vim as an external editor for Notational Velocity).
This commit is contained in:
@@ -150,23 +150,28 @@ endif
|
|||||||
|
|
||||||
" Section: Autocmd setup {{{1
|
" Section: Autocmd setup {{{1
|
||||||
|
|
||||||
|
if (!exists("g:GPGFilePattern"))
|
||||||
|
let g:GPGFilePattern = '*.\(gpg\|asc\|pgp\)'
|
||||||
|
endif
|
||||||
|
|
||||||
augroup GnuPG
|
augroup GnuPG
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
" do the decryption
|
" do the decryption
|
||||||
autocmd BufReadCmd *.\(gpg\|asc\|pgp\) call s:GPGInit(1)
|
exe "autocmd BufReadCmd " . g:GPGFilePattern . " call s:GPGInit(1) |" .
|
||||||
autocmd BufReadCmd *.\(gpg\|asc\|pgp\) call s:GPGDecrypt(1)
|
\ " call s:GPGDecrypt(1) |" .
|
||||||
autocmd BufReadCmd *.\(gpg\|asc\|pgp\) call s:GPGBufReadPost()
|
\ " call s:GPGBufReadPost()"
|
||||||
autocmd FileReadCmd *.\(gpg\|asc\|pgp\) call s:GPGInit(0)
|
exe "autocmd FileReadCmd " . g:GPGFilePattern . " call s:GPGInit(0) |" .
|
||||||
autocmd FileReadCmd *.\(gpg\|asc\|pgp\) call s:GPGDecrypt(0)
|
\ " call s:GPGDecrypt(0)"
|
||||||
|
|
||||||
" convert all text to encrypted text before writing
|
" convert all text to encrypted text before writing
|
||||||
autocmd BufWriteCmd *.\(gpg\|asc\|pgp\) call s:GPGBufWritePre()
|
exe "autocmd BufWriteCmd " . g:GPGFilePattern . " call s:GPGBufWritePre()"
|
||||||
autocmd BufWriteCmd,FileWriteCmd *.\(gpg\|asc\|pgp\) call s:GPGInit(0)
|
exe "autocmd BufWriteCmd,FileWriteCmd " . g:GPGFilePattern .
|
||||||
autocmd BufWriteCmd,FileWriteCmd *.\(gpg\|asc\|pgp\) call s:GPGEncrypt()
|
\ " call s:GPGInit(0) |" .
|
||||||
|
\ " call s:GPGEncrypt()"
|
||||||
|
|
||||||
" cleanup on leaving vim
|
" cleanup on leaving vim
|
||||||
autocmd VimLeave *.\(gpg\|asc\|pgp\) call s:GPGCleanup()
|
exe "autocmd VimLeave " . g:GPGFilePattern . " call s:GPGCleanup()"
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Section: Constants {{{1
|
" Section: Constants {{{1
|
||||||
|
|||||||
Reference in New Issue
Block a user