@@ -178,19 +178,26 @@ endfunction
178
178
" }}}1
179
179
" :Start, :Spawn {{{1
180
180
181
- function ! s: extract_title (command ) abort
181
+ function ! s: extract_opts (command ) abort
182
182
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]
189
195
endfunction
190
196
191
197
function ! 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)
194
201
return ' '
195
202
endfunction
196
203
@@ -199,12 +206,13 @@ function! dispatch#start_command(bang, command) abort
199
206
if empty (command ) && type (get (b: , ' start' , [])) == type (' ' )
200
207
let command = b: start
201
208
endif
202
- let [command , title ] = s: extract_title (command )
209
+ let [command , opts] = s: extract_opts (command )
210
+ let opts.background = a: bang
203
211
if command = ~# ' ^:.'
204
212
unlet ! g: dispatch_last_start
205
213
return substitute (command , ' \>' , get (a: 0 ? a: 1 : {}, ' background' , 0 ) ? ' !' : ' ' , ' ' )
206
214
endif
207
- call dispatch#start (command , { ' background ' : a: bang , ' title ' : title } )
215
+ call dispatch#start (command , opts )
208
216
return ' '
209
217
endfunction
210
218
@@ -428,14 +436,17 @@ function! dispatch#compile_command(bang, args, count) abort
428
436
elseif args = ~# ' ^:.'
429
437
return (a: count > 0 ? a: count : ' ' ).substitute (args [1 :-1 ], ' \>' , (a: bang ? ' !' : ' ' ), ' ' )
430
438
endif
439
+
440
+ let [args , request] = s: extract_opts (args )
441
+
431
442
let executable = matchstr (args , ' \S\+' )
432
443
433
- let request = {
444
+ call extend ( request, {
434
445
\ ' action' : ' make' ,
435
446
\ ' background' : a: bang ,
436
447
\ ' file' : tempname (),
437
448
\ ' format' : ' %+I%.%#'
438
- \ }
449
+ \ }, ' keep ' )
439
450
440
451
if executable == # ' _'
441
452
let request.args = matchstr (args , ' _\s*\zs.*' )
0 commit comments