On Mar 11, 2014 11:53 PM, "Gary Johnson" <garyj...@spocom.com> wrote:
>
> On 2014-03-11, Nikolay Pavlov wrote:
> >
> > On Mar 11, 2014 9:51 PM, "Charles Campbell" wrote:
> > >
> > > Ingo Karkat wrote:
> > >>
> > >> On 11-Mar-2014 15:14 +0100, Ben Fritz wrote:
> > >>
> > >>> <snip>
> > >>>
> > >>> Isn't this situation what shellescape() is designed for?
> > >>>
> > >>> That's not saying shellescape() will work, but I think it's supposed
> > >>> to work, unlike using a bare % which should always work for internal
> > >>> Vim commands but will only work by accident in external commands.
> > >>
> > >> No, shellescape() would be used in a mapping / command, like this:
> > >> shellescape(expand('%'), 1). With the 1 flag (for use with :!), a
> > >> literal % is properly escaped to \% so that Vim's special handling
does
> > >> not apply.
> > >>
> > >> % is handy for interactive use, like :!perl %
> > >>
> > > shellescape() is for use in a shell command argument being
> > > passed to the shell.  The documentation even shows an example of
> > > using a filter.  fnameescape() is for internal-vim use involving
> > > filenames (ie. avoid having % have magic with exe when you don't
> > > want it to).
> > > %  is replaced with the current file name, just as it is typed.
> > > (see :he _%).
> > >
> > > So, if the current filename contains spaces, that's what you can
> > > expect to see with the expansion.
> > > The right way to do what the OP wants:
> > >
> > > :exe "w !diff ".shellescape(expand("%"))
> >
> > After my patch was included you can use (mentioned in second or
> > third message in this thread)
> >
> >     :w !diff %:S
>
> Appending :S is easy enough to be a good solution.  However, it
> doesn't handle parentheses any better than "%", at least not with
> Vim 7.4.193 on Linux.
>
>     $ vim -N -u NONE 'foo bar()'
>     :w
>     :!file %:S
>     foo bar\(\): ERROR: cannot open `foo bar\(\)' (No such file or
directory)

Ha! I have tested braces, figure brackets, dollar, quotes, backticks, per
cant, hash, newline: they all work. But not parenthesis. Good catch.

Though :S modifier is not responsible for this: :echo expand('%:S') is
correct. Will check whether I can disable unneeded escaping for :S.

>
> Regards,
> Gary
>
> --
> --
> 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.

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