On 16-Jun-2012 01:18:24 +0900, Yasuhiro MATSUMOTO wrote:

> No. Currentry, `=foo` is a just only way that can specify argument
> without escaping, and can specify non-valid filename. This is usefull
> to make buffer with especially name. ex: "[##My Buffer##]".

fnameescape() will properly escape that. The problem is that when specifying a
name that can be interpreted as a glob, like [a-z], it is opened as that literal
text when the glob doesn't yield a match, but will open a file (e.g. "q") if
such a match exists. (Or, in the case of single-argument commands like :edit and
multiple matches, will even complain about too many filenames!)

> I think, fnameescape() is not best way to specify argument for any
> commands. Because edit command treat argument as pattern.

Though all those filenames that can be interpreted as a glob are rare and
therefore can be categorized as pathological cases, I tend to agree. The problem
is that the help for fnameescape() in particular recommends its use for such 
cases:
#v+
                Example: >
                        :let fname = '+some str%nge|name'
                        :exe "edit " . fnameescape(fname)
<               results in executing: >
                        edit \+some\ str\%nge\|name
#v-

I have seen most plugins use fnameescape() in this way. In fact, some
(especially older) plugins use no or some DIY escaping, yet there seem to be few
complaints. Are we really talking about an actual issue here? Should we continue
recommending the use of fnameescape(), even though it's slightly broken? I think
the help for fnameescape() should mention the backtick-expansion alternative,
and give clear guidelines when to use what. This is complex stuff, and we can't
expect plugin authors to find out and learn about the intricacies all on their
own! See, I have been using fnameescape() and thought I was safe, you used the
backtick-expansion trick and didn't know about the effect of 'wildignore'.

> :e [a-z]
> 
> If fnameescape() escape this,
> 
> :e \[a-z\]
> 
> When you run below on windows:
> 
> mkdir C:\[a-
> mkdir C:\[a-\]
> 
> How to specify argument to edit this?

For me, fnameescape('[a-z]') yields "[a-z]" on Windows and "\[a-z]" on Linux,
but never "\[a-z\]". I guess this is because Windows doesn't understand the
glob, so it doesn't need to be escaped. Strangely, :e [a-z] will edit an
existing file named q. Does Vim perform this globbing?


While fiddling around, I think I also found a bug in backtick-expansion:
    :edit `='*'`
On Linux (Vim 7.3.535, BIG version with GTK2 GUI), this correctly edits a new
file named "*".
On Windows (GVIM 7.3.540, HUGE version with GUI, taken from Cream), I get:
    E480: No match: `='*'`
Shouldn't the backtick-expansion result always be taken literally? It looks like
it mistakenly performs a glob here!

-- regards, ingo

PS: Please bottom-post on this list.

-- 
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

Raspunde prin e-mail lui