Added variables g:GPGPreferSymmetric and g:GPGPreferArmor.
This commit is contained in:
parent
fc79049481
commit
eb2fb27748
@ -45,6 +45,12 @@
|
|||||||
" g:GPGUseAgent
|
" g:GPGUseAgent
|
||||||
" If set to 0 a possible available gpg-agent won't be used. Defaults to 1.
|
" If set to 0 a possible available gpg-agent won't be used. Defaults to 1.
|
||||||
"
|
"
|
||||||
|
" g:GPGPreferSymmetric
|
||||||
|
" If set to 1 symmetric encryption is preferred for new files. Defaults to 0.
|
||||||
|
"
|
||||||
|
" g:GPGPreferArmor
|
||||||
|
" If set to 1 armored data is preferred for new files. Defaults to 0.
|
||||||
|
"
|
||||||
" Credits:
|
" Credits:
|
||||||
" Mathieu Clabaut for inspirations through his vimspell.vim script.
|
" Mathieu Clabaut for inspirations through his vimspell.vim script.
|
||||||
" Richard Bronosky for patch to enable ".pgp" suffix.
|
" Richard Bronosky for patch to enable ".pgp" suffix.
|
||||||
@ -68,8 +74,9 @@ autocmd BufNewFile,BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) set viminfo=
|
|||||||
autocmd BufNewFile,BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) set noswapfile
|
autocmd BufNewFile,BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) set noswapfile
|
||||||
" Initialize the internal variables
|
" Initialize the internal variables
|
||||||
autocmd BufNewFile,BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) call s:GPGInit()
|
autocmd BufNewFile,BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) call s:GPGInit()
|
||||||
" Force the user to edit the recipient list if he opens a new file
|
" Force the user to edit the recipient list if he opens a new file and public
|
||||||
autocmd BufNewFile *.\(gpg\|asc\|pgp\) call s:GPGEditRecipients()
|
" keys are preferred
|
||||||
|
autocmd BufNewFile *.\(gpg\|asc\|pgp\) if (exists("g:GPGPreferSymmetric") && g:GPGPreferSymmetric == 0) | call s:GPGEditRecipients() | endi
|
||||||
" Switch to binary mode to read the encrypted file
|
" Switch to binary mode to read the encrypted file
|
||||||
autocmd BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) set bin
|
autocmd BufReadPre,FileReadPre *.\(gpg\|asc\|pgp\) set bin
|
||||||
autocmd BufReadPost,FileReadPost *.\(gpg\|asc\|pgp\) call s:GPGDecrypt()
|
autocmd BufReadPost,FileReadPost *.\(gpg\|asc\|pgp\) call s:GPGDecrypt()
|
||||||
@ -104,6 +111,16 @@ fun s:GPGInit()
|
|||||||
let g:GPGUseAgent = 1
|
let g:GPGUseAgent = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" check if symmetric encryption is preferred
|
||||||
|
if (!exists("g:GPGPreferSymmetric"))
|
||||||
|
let g:GPGPreferSymmetric = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
" check if armored files are preferred
|
||||||
|
if (!exists("g:GPGPreferArmor"))
|
||||||
|
let g:GPGPreferArmor = 0
|
||||||
|
endif
|
||||||
|
|
||||||
" determine if gnupg can use the gpg-agent
|
" determine if gnupg can use the gpg-agent
|
||||||
if (exists("$GPG_AGENT_INFO") && g:GPGUseAgent == 1)
|
if (exists("$GPG_AGENT_INFO") && g:GPGUseAgent == 1)
|
||||||
if (!exists("$GPG_TTY"))
|
if (!exists("$GPG_TTY"))
|
||||||
@ -255,7 +272,14 @@ fun s:GPGEncrypt()
|
|||||||
|
|
||||||
" built list of options
|
" built list of options
|
||||||
if (!exists("b:GPGOptions") || strlen(b:GPGOptions) == 0)
|
if (!exists("b:GPGOptions") || strlen(b:GPGOptions) == 0)
|
||||||
let b:GPGOptions="encrypt:"
|
if (exists("g:GPGPreferSymmetric") && g:GPGPreferSymmetric == 1)
|
||||||
|
let b:GPGOptions="symmetric:"
|
||||||
|
else
|
||||||
|
let b:GPGOptions="encrypt:"
|
||||||
|
endi
|
||||||
|
if (exists("g:GPGPreferArmor") && g:GPGPreferArmor == 1)
|
||||||
|
let b:GPGOptions=b:GPGOptions . "armor:"
|
||||||
|
endi
|
||||||
endi
|
endi
|
||||||
let field=0
|
let field=0
|
||||||
let option=s:GetField(b:GPGOptions, ":", field)
|
let option=s:GetField(b:GPGOptions, ":", field)
|
||||||
|
Loading…
Reference in New Issue
Block a user