-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop setting g:GPGPreferArmor in GPGInit
When the user hasn't explicity let g:GPGPreferArmor, the value is supposed to be determined by the filename. Instead of letting g:GPGPreferArmor, lazily determine what should be done when actually doing the encryption. Signed-off-by: James McCoy <[email protected]>
- Loading branch information
Showing
1 changed file
with
8 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
" Name: gnupg.vim | ||
" Last Change: 2015 Dec 17 | ||
" Maintainer: James McCoy <vega.james@gmail.com> | ||
" Last Change: 2016 Apr 24 | ||
" Maintainer: James McCoy <jamessan@jamessan.com> | ||
" Original Author: Markus Braun <[email protected]> | ||
" Summary: Vim plugin for transparent editing of gpg encrypted files. | ||
" License: This program is free software; you can redistribute it and/or | ||
|
@@ -175,7 +175,7 @@ | |
if (exists("g:loaded_gnupg") || &cp || exists("#GnuPG")) | ||
finish | ||
endif | ||
let g:loaded_gnupg = '2.5' | ||
let g:loaded_gnupg = '2.6' | ||
let s:GPGInitRun = 0 | ||
|
||
" check for correct vim version {{{2 | ||
|
@@ -296,16 +296,6 @@ function s:GPGInit(bufread) | |
let g:GPGPreferSymmetric = 0 | ||
endif | ||
|
||
" check if armored files are preferred | ||
if (!exists("g:GPGPreferArmor")) | ||
" .asc files should be armored as that's what the extension is used for | ||
if expand('<afile>') =~ '\.asc$' | ||
let g:GPGPreferArmor = 1 | ||
else | ||
let g:GPGPreferArmor = 0 | ||
endif | ||
endif | ||
|
||
" check if signed files are preferred | ||
if (!exists("g:GPGPreferSign")) | ||
let g:GPGPreferSign = 0 | ||
|
@@ -670,6 +660,7 @@ function s:GPGEncrypt() | |
return | ||
endif | ||
|
||
let filename = resolve(expand('<afile>')) | ||
" initialize GPGOptions if not happened before | ||
if (!exists("b:GPGOptions") || empty(b:GPGOptions)) | ||
let b:GPGOptions = [] | ||
|
@@ -679,7 +670,10 @@ function s:GPGEncrypt() | |
else | ||
let b:GPGOptions += ["encrypt"] | ||
endif | ||
if (exists("g:GPGPreferArmor") && g:GPGPreferArmor == 1) | ||
" Fallback to preference by filename if the user didn't indicate | ||
" their preference. | ||
let preferArmor = get(g:, 'GPGPreferArmor', -1) | ||
if (preferArmor >= 0 && preferArmor) || filename =~ '\.asc$' | ||
let b:GPGOptions += ["armor"] | ||
endif | ||
if (exists("g:GPGPreferSign") && g:GPGPreferSign == 1) | ||
|
@@ -738,7 +732,6 @@ function s:GPGEncrypt() | |
return | ||
endif | ||
|
||
let filename = resolve(expand('<afile>')) | ||
if rename(destfile, filename) | ||
" Rename failed, so clean up the tempfile | ||
call delete(destfile) | ||
|