2013-09-30 04:19:31 -04:00
|
|
|
" vim: et sw=2 sts=2
|
|
|
|
|
2013-08-19 11:36:16 -04:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
2013-07-17 06:30:58 -04:00
|
|
|
" Function: #escape {{{1
|
|
|
|
function! sy#util#escape(path) abort
|
|
|
|
if exists('+shellslash')
|
|
|
|
let old_ssl = &shellslash
|
2013-11-30 08:33:47 -05:00
|
|
|
if fnamemodify(&shell, ':t') == 'cmd.exe'
|
|
|
|
set noshellslash
|
|
|
|
else
|
|
|
|
set shellslash
|
|
|
|
endif
|
2013-07-17 06:30:58 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
let path = shellescape(a:path)
|
|
|
|
|
|
|
|
if exists('old_ssl')
|
|
|
|
let &shellslash = old_ssl
|
|
|
|
endif
|
|
|
|
|
|
|
|
return path
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Function: #separator {{{1
|
|
|
|
function! sy#util#separator() abort
|
|
|
|
return !exists('+shellslash') || &shellslash ? '/' : '\'
|
|
|
|
endfunction
|
2014-01-30 23:03:55 -05:00
|
|
|
|
|
|
|
" Function: #run_in_dir {{{1
|
|
|
|
function! sy#util#run_in_dir(dir, cmd) abort
|
|
|
|
let chdir = haslocaldir() ? 'lcd' : 'cd'
|
2014-10-04 09:55:49 -04:00
|
|
|
let cwd = getcwd()
|
|
|
|
|
2014-01-30 23:03:55 -05:00
|
|
|
try
|
2014-10-04 09:55:49 -04:00
|
|
|
execute chdir fnameescape(fnamemodify(a:dir, ':p'))
|
|
|
|
let ret = system(a:cmd)
|
2014-01-30 23:03:55 -05:00
|
|
|
finally
|
2014-10-04 09:55:49 -04:00
|
|
|
execute chdir fnameescape(cwd)
|
2014-01-30 23:03:55 -05:00
|
|
|
endtry
|
2014-10-04 09:55:49 -04:00
|
|
|
|
|
|
|
return ret
|
2014-01-30 23:03:55 -05:00
|
|
|
endfunction
|
2014-11-02 09:57:50 -05:00
|
|
|
|
|
|
|
" Function: #refresh_windows {{{1
|
|
|
|
function! sy#util#refresh_windows() abort
|
|
|
|
let winnr = winnr()
|
|
|
|
windo if exists('b:sy') | call sy#start() | endif
|
|
|
|
execute winnr .'wincmd w'
|
|
|
|
endfunction
|