On Friday, March 23, 2012 2:47:22 PM UTC-5, Christian Brabandt wrote:
> Hi Marcin!
> 
> On Fr, 23 M�r 2012, Marcin Szamotulski wrote:
> 
> > Hello,
> > 
> > I'm trying to make a nice interface for :call system(...). For this I made 
> > the
> > following function:
> > 
> > function! System(arg)
> >     " Expand %, %:p (all modifiers are allowed except :s?pat?sub? and
> >     " :gs?pat?sub?
> >     return system(substitute(a:arg, '\(%\%(:[p8~.htre]\)*\)', 
> > '\=expand(submatch(0))', 'g'))
> > endfunction
> > 
> > The command 
> > command! -nargs=1 System        :echo System("<args>")
> > works as expected, but when I change it to:
> 
> I am surprised, this actually works and you didn't get E176.
> 
> > 
> > command! -nargs=1 -complete=file System         :echo System("<args>")
> > 
> > and use it 
> > :System ls /tmp
> > I get the E172 error. Any ideas why?
> 
> You called the command with 2 arguments, but defined it to only accept 
> one. That's wrong use -nargs=+ and possibly instead of "<args>" you can 
> also use <q-args>
> 

That's exactly what my first thought was, but then I saw :he :command-nargs, 
"-nargs=1    Exactly one argument is require, it includes spaces". Unless I'm 
mistaken, this actually means it will always include the rest of the 
command-line (up to a " or | potentially), and include the spaces.

-- 
You received this message from the "vim_use" 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

Reply via email to