Skip to content

Commit 6394219

Browse files
committed
Reuse tempname in isolate
1 parent 9b819d2 commit 6394219

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

autoload/dispatch.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function! dispatch#set_title(request) abort
195195
\ a:request.expanded)
196196
endfunction
197197

198-
function! dispatch#isolate(keep, ...) abort
198+
function! dispatch#isolate(request, keep, ...) abort
199199
let keep = ['SHELL'] + a:keep
200200
let command = ['cd ' . shellescape(getcwd())]
201201
for line in split(system('env'), "\n")
@@ -209,7 +209,7 @@ function! dispatch#isolate(keep, ...) abort
209209
endif
210210
endfor
211211
let command += a:000
212-
let temp = tempname()
212+
let temp = type(a:request) == type({}) ? a:request.file . '.dispatch' : tempname()
213213
call writefile(command, temp)
214214
return 'env -i ' . join(map(copy(keep), 'v:val."=\"$". v:val ."\" "'), '') . &shell . ' ' . temp
215215
endfunction

autoload/dispatch/iterm.vim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ function! dispatch#iterm#spawn(command, request, activate) abort
5151
endfunction
5252

5353
function! dispatch#iterm#spawn2(command, request, activate) abort
54-
let script = dispatch#isolate([], dispatch#set_title(a:request), a:command)
54+
let script = dispatch#isolate(a:request, [],
55+
\ dispatch#set_title(a:request), a:command)
5556
return s:osascript(
5657
\ 'if application "iTerm" is not running',
5758
\ 'error',
@@ -71,7 +72,8 @@ function! dispatch#iterm#spawn2(command, request, activate) abort
7172
endfunction
7273

7374
function! dispatch#iterm#spawn3(command, request, activate) abort
74-
let script = dispatch#isolate([], dispatch#set_title(a:request), a:command)
75+
let script = dispatch#isolate(a:request, [],
76+
\ dispatch#set_title(a:request), a:command)
7577
return s:osascript(
7678
\ 'if application "iTerm" is not running',
7779
\ 'error',

autoload/dispatch/screen.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ endfunction
2222
function! dispatch#screen#spawn(command, request) abort
2323
let command = 'screen -ln -fn -t '.dispatch#shellescape(a:request.title)
2424
\ . ' ' . &shell . ' ' . &shellcmdflag . ' '
25-
\ . shellescape('exec ' . dispatch#isolate(['STY', 'WINDOW'],
26-
\ dispatch#set_title(a:request), a:command))
25+
\ . shellescape('exec ' . dispatch#isolate(a:request,
26+
\ ['STY', 'WINDOW'], dispatch#set_title(a:request), a:command))
2727
silent execute '!' . escape(command, '!#%')
2828
if a:request.background || a:request.action !=# 'start' && !has('gui_running')
2929
silent !screen -X other

autoload/dispatch/tmux.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function! dispatch#tmux#handle(request) abort
3030
let command .= ' -d'
3131
endif
3232
let command .= ' ' . shellescape('exec ' . dispatch#isolate(
33-
\ ['TMUX', 'TMUX_PANE'],
33+
\ a:request, ['TMUX', 'TMUX_PANE'],
3434
\ dispatch#set_title(a:request),
3535
\ dispatch#prepare_start(a:request)))
3636
call system(command)
@@ -42,7 +42,7 @@ function! dispatch#tmux#make(request) abort
4242
let pipepane = (&shellpipe ==# '2>&1| tee' || &shellpipe ==# '|& tee')
4343
\ && a:request.format !~# '%\\[er]'
4444
let session = get(g:, 'tmux_session', '')
45-
let script = dispatch#isolate(['TMUX', 'TMUX_PANE'],
45+
let script = dispatch#isolate(a:request, ['TMUX', 'TMUX_PANE'],
4646
\ call('dispatch#prepare_make', [a:request] +
4747
\ (pipepane ? [a:request.expanded . '; echo ' . dispatch#status_var()
4848
\ . ' > ' . a:request.file . '.complete'] : [])))

0 commit comments

Comments
 (0)