Skip to content

Commit

Permalink
Support :Start -wait=...
Browse files Browse the repository at this point in the history
  • Loading branch information
tpope committed Jul 25, 2015
1 parent c935be9 commit 69fea41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions autoload/dispatch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ function! dispatch#prepare_start(request, ...) abort
let exec .= 'sleep 1; '
endif
let exec .= a:0 ? a:1 : a:request.expanded
let wait = a:0 > 1 ? a:1 : get(a:request, 'wait', 'error')
let pause = "(printf '\e[1m--- Press ENTER to continue ---\e[0m\\n' $?; exec head -1)"
if a:0 < 2 || a:2 =~# 'always\|error\|[1-9]'
if wait == 'always'
let exec .= '; ' . pause
elseif wait !=# 'never'
let exec .= "; test $? = 0 -o $? = 130 || " . pause
endif
let callback = dispatch#callback(a:request)
Expand Down Expand Up @@ -235,7 +238,7 @@ function! s:extract_opts(command) abort
endif
if opt ==# 'dir' || opt ==# 'directory'
let opts.directory = fnamemodify(expand(val), ':p:s?[^:]\zs[\\/]$??')
elseif index(['compiler', 'title'], opt) >= 0
elseif index(['compiler', 'title', 'wait'], opt) >= 0
let opts[opt] = substitute(val, '\\\(\s\)', '\1', 'g')
endif
let command = substitute(command, '^-\w\+\%(=\%(\\.\|\S\)*\)\=\s*', '', '')
Expand Down
4 changes: 3 additions & 1 deletion autoload/dispatch/windows.vim
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ function! dispatch#windows#start(request) abort
let exec = dispatch#prepare_start(a:request)
else
let pidfile = a:request.file.'.pid'
let pause = get({'always': ' & pause', 'never': ''},
\ get(a:request, 'wait'), ' || pause')
let exec =
\ s:pid . pidfile .
\ ' & ' . a:request.command .
\ ' || pause ' .
\ pause .
\ ' & del ' . pidfile
endif

Expand Down
2 changes: 2 additions & 0 deletions doc/dispatch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ COMMANDS *dispatch-commands*

-dir=... run command in given directory
-title=... short label for supported adapters
-wait=... when to display press enter prompt:
"always", "never", or "error"

:Start! [options] {command}
Start a process in a new, unfocused window. If
Expand Down

1 comment on commit 69fea41

@NLKNguyen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I had been longing for this.

Please sign in to comment.