I am writing a plugin to launch shell command in background by using jobs.

How can I escape and expand '%' in <q-args> in my command ?
just like replace_makeprg does, 

Currently, I split command args by using <f-args> and check each argument, if a 
argument starts with '%' it needs to be expanded by calling `expand()`.

It's a little stupid, this will work in '!':
:!gcc "hello 1 2 3.c" 

but if I use <f-args> in command, arguments in 
:MyRunAsyncCmd gcc "hello 1 2 3.c" 

will be splited into:
[ 'gcc', '"hello ', '1', '2', '3.c"' ]

so I must write like this to ensure <f-args> works correctly:
:MyRunAsyncCmd gcc hello\ 1\ 2\ 3.c

Which is complete a different user experience from '!'.

I wish to use <q-args> directly and pass it to 
job_start(['sh', '-c', '?'], ...)

so that it will work just like '!'

but macros like '%' will not get replaced. after checking the vim source, I 
found a replace_makeprg is very close to this.

So, how can vimscript invoke replace_makeprg or something like that to expands 
'%' in a string ?

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui