Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add g:GPGFilePattern to allow custom target filename patterns #4

Merged
merged 1 commit into from
Feb 10, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions plugin/gnupg.vim
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,28 @@ endif

" Section: Autocmd setup {{{1

if (!exists("g:GPGFilePattern"))
let g:GPGFilePattern = '*.\(gpg\|asc\|pgp\)'
endif

augroup GnuPG
autocmd!

" do the decryption
autocmd BufReadCmd *.\(gpg\|asc\|pgp\) call s:GPGInit(1)
autocmd BufReadCmd *.\(gpg\|asc\|pgp\) call s:GPGDecrypt(1)
autocmd BufReadCmd *.\(gpg\|asc\|pgp\) call s:GPGBufReadPost()
autocmd FileReadCmd *.\(gpg\|asc\|pgp\) call s:GPGInit(0)
autocmd FileReadCmd *.\(gpg\|asc\|pgp\) call s:GPGDecrypt(0)
exe "autocmd BufReadCmd " . g:GPGFilePattern . " call s:GPGInit(1) |" .
\ " call s:GPGDecrypt(1) |" .
\ " call s:GPGBufReadPost()"
exe "autocmd FileReadCmd " . g:GPGFilePattern . " call s:GPGInit(0) |" .
\ " call s:GPGDecrypt(0)"

" convert all text to encrypted text before writing
autocmd BufWriteCmd *.\(gpg\|asc\|pgp\) call s:GPGBufWritePre()
autocmd BufWriteCmd,FileWriteCmd *.\(gpg\|asc\|pgp\) call s:GPGInit(0)
autocmd BufWriteCmd,FileWriteCmd *.\(gpg\|asc\|pgp\) call s:GPGEncrypt()
exe "autocmd BufWriteCmd " . g:GPGFilePattern . " call s:GPGBufWritePre()"
exe "autocmd BufWriteCmd,FileWriteCmd " . g:GPGFilePattern .
\ " call s:GPGInit(0) |" .
\ " call s:GPGEncrypt()"

" cleanup on leaving vim
autocmd VimLeave *.\(gpg\|asc\|pgp\) call s:GPGCleanup()
exe "autocmd VimLeave " . g:GPGFilePattern . " call s:GPGCleanup()"
augroup END

" Section: Constants {{{1
Expand Down