Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattn
Created December 29, 2015 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/8761f00f2b8ba0dcce84 to your computer and use it in GitHub Desktop.
Save mattn/8761f00f2b8ba0dcce84 to your computer and use it in GitHub Desktop.
diff --git a/autoload/twitvim.vim b/autoload/twitvim.vim
index e5b3677..e9af6e1 100644
--- a/autoload/twitvim.vim
+++ b/autoload/twitvim.vim
@@ -57,6 +57,29 @@ function! s:get_api_root()
return svc == '' ? s:default_api_root : s:service_info[svc]['api_root']
endfunction
+try
+ call vimproc#version()
+ let s:has_vimproc = 1
+catch
+ let s:has_vimproc = 0
+endtry
+
+function! s:shell_error()
+ if s:has_vimproc
+ return vimproc#get_last_status()
+ else
+ return v:shell_error
+ endif
+endfunction
+
+function! s:system(...)
+ if s:has_vimproc
+ return call('vimproc#system', a:000)
+ else
+ return call('system', a:000)
+ endif
+endfunction
+
" Service display name.
function! s:get_svc_disp_name()
return s:service_info[s:cur_service]['dispname']
@@ -806,8 +829,8 @@ endfunction
" Compute HMAC-SHA1 digest by running openssl command line utility.
function! s:openssl_hmac_sha1_digest(key, str)
- let output = system('openssl dgst -binary -sha1 -hmac "'.a:key.'" | openssl base64', a:str)
- if v:shell_error != 0
+ let output = s:system('openssl dgst -binary -sha1 -hmac "'.a:key.'" | openssl base64', a:str)
+ if s:shell_error() != 0
call s:errormsg("Error running openssl command: ".output)
return ""
endif
@@ -1203,14 +1226,14 @@ function! s:curl_curl(url, login, proxy, proxylogin, parms)
if got_json
let curlcmd .= '-H "Content-Type: application/json" '
endif
-
+
let curlcmd .= '-H "User-Agent: '.s:user_agent.'" '
let curlcmd .= '"'.a:url.'"'
- let output = system(curlcmd)
+ let output = s:system(curlcmd)
let errormsg = s:xml_get_element(output, 'error')
- if v:shell_error != 0
+ if s:shell_error() != 0
let error = output
elseif errormsg != ''
let error = errormsg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment