@@ -178,19 +178,26 @@ endfunction
178178" }}}1
179179" :Start, :Spawn {{{1
180180
181- function ! s: extract_title (command ) abort
181+ function ! s: extract_opts (command ) abort
182182 let command = a: command
183- let title = matchstr (command , ' -title=\zs\%(\\.\|\S\)*' )
184- if ! empty (title )
185- let command = command [strlen (title ) + 8 : -1 ]
186- endif
187- let title = substitute (title , ' \\\(\s\)' , ' \1' , ' g' )
188- return [command , title ]
183+ let opts = {}
184+ while command = ~# ' ^-\%(\w\+\)\%([= ]\|$\)'
185+ let opt = matchstr (command , ' ^-\zs\w\+' )
186+ if command = ~ ' ^-\w\+='
187+ let val = matchstr (command , ' ^-\w\+=\zs\%(\\.\|\S\)*' )
188+ else
189+ let val = 1
190+ endif
191+ let opts[opt ] = substitute (val, ' \\\(\s\)' , ' \1' , ' g' )
192+ let command = substitute (command , ' ^-\w\+\%(=\%(\\.\|\S\)*\)\=\s*' , ' ' , ' ' )
193+ endwhile
194+ return [command , opts]
189195endfunction
190196
191197function ! dispatch#spawn_command (bang , command ) abort
192- let [command , title ] = s: extract_title (a: command )
193- call dispatch#spawn (command , {' background' : a: bang , ' title' : title })
198+ let [command , opts] = s: extract_opts (a: command )
199+ let opts.background = a: bang
200+ call dispatch#spawn (command , opts)
194201 return ' '
195202endfunction
196203
@@ -199,12 +206,13 @@ function! dispatch#start_command(bang, command) abort
199206 if empty (command ) && type (get (b: , ' start' , [])) == type (' ' )
200207 let command = b: start
201208 endif
202- let [command , title ] = s: extract_title (command )
209+ let [command , opts] = s: extract_opts (command )
210+ let opts.background = a: bang
203211 if command = ~# ' ^:.'
204212 unlet ! g: dispatch_last_start
205213 return substitute (command , ' \>' , get (a: 0 ? a: 1 : {}, ' background' , 0 ) ? ' !' : ' ' , ' ' )
206214 endif
207- call dispatch#start (command , { ' background ' : a: bang , ' title ' : title } )
215+ call dispatch#start (command , opts )
208216 return ' '
209217endfunction
210218
@@ -428,14 +436,17 @@ function! dispatch#compile_command(bang, args, count) abort
428436 elseif args = ~# ' ^:.'
429437 return (a: count > 0 ? a: count : ' ' ).substitute (args [1 :-1 ], ' \>' , (a: bang ? ' !' : ' ' ), ' ' )
430438 endif
439+
440+ let [args , request] = s: extract_opts (args )
441+
431442 let executable = matchstr (args , ' \S\+' )
432443
433- let request = {
444+ call extend ( request, {
434445 \ ' action' : ' make' ,
435446 \ ' background' : a: bang ,
436447 \ ' file' : tempname (),
437448 \ ' format' : ' %+I%.%#'
438- \ }
449+ \ }, ' keep ' )
439450
440451 if executable == # ' _'
441452 let request.args = matchstr (args , ' _\s*\zs.*' )
0 commit comments