<q-args>

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

<q-args>

Charles E Campbell Jr
Hello, Bram!

When there are no arguments, <f-args> will create no arguments.
That appears not to be the case for <q-args>, as shown by sourcing

fun! Problem(...)
  echomsg " ----- "
  echomsg " a:0=".a:0
  if a:0 > 0
   echomsg " a:1<".a:1.">"
  endif
endfun
com -nargs=? PRBLM call Problem(<q-args>)
PRBLM

Its not clear from the documentation (at least, not to me) that <q-args>
should have this behavior of inventing an argument (I assume its "")
when there are none provided.

Just thought I'd point it out.

Regards,
Chip Campbell

Reply | Threaded
Open this post in threaded view
|

Re: <q-args>

A.J.Mechelynck
Charles E. Campbell, Jr. wrote:

> Hello, Bram!
>
> When there are no arguments, <f-args> will create no arguments.
> That appears not to be the case for <q-args>, as shown by sourcing
>
> fun! Problem(...)
>  echomsg " ----- "
>  echomsg " a:0=".a:0
>  if a:0 > 0
>   echomsg " a:1<".a:1.">"
>  endif
> endfun
> com -nargs=? PRBLM call Problem(<q-args>)
> PRBLM
>
> Its not clear from the documentation (at least, not to me) that <q-args>
> should have this behavior of inventing an argument (I assume its "")
> when there are none provided.
>
> Just thought I'd point it out.
>
> Regards,
> Chip Campbell
>
>
>
>

The way I read it, the help for <q-args> means that it always produces
exactly one quoted string containing all the arguments (I presume that
if there are none, the null string is used). <f-args>, OTOH, produces
(IIUC) a comma-separated list of (zero or more) quoted arguments.

I'm looking at:

*map.txt*       For Vim version 7.0aa.  Last change: 2005 Mar 29
lines 1031 sqq.

*map.txt*       For Vim version 6.3.  Last change: 2004 May 21
lines 1033 sqq.


Best regards,
Tony.

Reply | Threaded
Open this post in threaded view
|

Re: <q-args>

Bram Moolenaar
In reply to this post by Charles E Campbell Jr

Charles -

> When there are no arguments, <f-args> will create no arguments.
> That appears not to be the case for <q-args>, as shown by sourcing
>
> fun! Problem(...)
>   echomsg " ----- "
>   echomsg " a:0=".a:0
>   if a:0 > 0
>    echomsg " a:1<".a:1.">"
>   endif
> endfun
> com -nargs=? PRBLM call Problem(<q-args>)
> PRBLM
>
> Its not clear from the documentation (at least, not to me) that <q-args>
> should have this behavior of inventing an argument (I assume its "")
> when there are none provided.
>
> Just thought I'd point it out.

I think we can add a remark in the docs that <q-args> is an empty string
when there are no arguments.  I don't see a good reason to change the
behavior.  As it is now it also works for a function that takes one
argument.  It would fails if <q-args> doesn't produce an empty string
when there is no argument.

- Bram

--
How To Keep A Healthy Level Of Insanity:
16. Have your coworkers address you by your wrestling name, Rock Hard Kim.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///