From 89253464f19630f24f8fe823b287f4587e0bcc8a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 29 Sep 2015 19:23:19 -0400 Subject: [PATCH] Use `:language` command to force C locale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In non-Windows environments, the gpg command is prepended with “LANG=C LC_ALL=C” to ensure gpg's output is consistent to allow for parsing the information. However, that doesn't work in Windows and won't necessarily work if we ever remove the code forcing use of /bin/sh. Since Vim already knows how to influence the environment, use its “:language message …” command to set/restore the locale before/after running the gpg command. Closes jamessan/vim-gnupg#45 Signed-off-by: James McCoy --- plugin/gnupg.vim | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugin/gnupg.vim b/plugin/gnupg.vim index b0bcd5c..3faadcc 100644 --- a/plugin/gnupg.vim +++ b/plugin/gnupg.vim @@ -1,5 +1,5 @@ " Name: gnupg.vim -" Last Change: 2015 Jul 26 +" Last Change: 2015 Sep 29 " Maintainer: James McCoy " Original Author: Markus Braun " Summary: Vim plugin for transparent editing of gpg encrypted files. @@ -320,7 +320,6 @@ function s:GPGInit(bufread) let s:shellredir = ">%s 2>&1" let s:shell = '/bin/sh' let s:stderrredirnull = '2>/dev/null' - let s:GPGCommand = "LANG=C LC_ALL=C " . s:GPGCommand else " windows specific settings let s:shellredir = '>%s' @@ -1279,16 +1278,29 @@ function s:GPGIDToName(identity) return uid endfunction +" Function: s:GPGPreCmd() {{{2 +" +" Setup the environment for running the gpg command +" function s:GPGPreCmd() let &shellredir = s:shellredir let &shell = s:shell let &shelltemp = s:shelltemp + " Force C locale so GPG output is consistent + let s:messages = v:lang + language messages C endfunction + +" Function: s:GPGPostCmd() {{{2 +" +" Restore the user's environment after running the gpg command +" function s:GPGPostCmd() let &shellredir = s:shellredirsave let &shell = s:shellsave let &shelltemp = s:shelltempsave + execute 'language messages' s:messages " Workaround a bug in the interaction between console vim and " pinentry-curses by forcing Vim to re-detect and setup its terminal " settings