Re: Incorrect expansion of %?

2014-03-11 Thread Ben Fritz
On Tuesday, March 4, 2014 1:15:40 AM UTC-6, Gary Johnson wrote:
>
> 
> Using a GUI file manager, I opened this file with gvim.  I made some
> 
> changes to it, then tried comparing the changed buffer with the
> 
> copy on disk with this command which I have used for years:
> 
> 
> 
> :w !diff "%" -
> 
> 
> 
> The result surprised me.
> 
> 
> 
> diff: Dropbox/vimfiles/filetype \(toucan's conflicted copy 
> 2014-03-01\).vim: No such file or directory
> 
> 
> 
> shell returned 2
> 
> 
> 
> However, if instead I typed
> 
> 
> 
> :w !diff "^R%" -
> 
> 
> 
> where ^R means Ctrl-R, the command became
> 
> 
> 
> :w !diff "Dropbox/vimfiles/filetype (toucan's conflicted copy 
> 2014-03-01).vim" -
> 
> 
> 
> and worked fine.
> 
> 
> 

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.

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


Re: Incorrect expansion of %?

2014-03-11 Thread Ingo Karkat
On 11-Mar-2014 15:14 +0100, Ben Fritz wrote:

> On Tuesday, March 4, 2014 1:15:40 AM UTC-6, Gary Johnson wrote:
>>
>>
>> Using a GUI file manager, I opened this file with gvim.  I made some
>>
>> changes to it, then tried comparing the changed buffer with the
>>
>> copy on disk with this command which I have used for years:
>>
>>
>>
>> :w !diff "%" -
>>
>>
>>
>> The result surprised me.
>>
>>
>>
>> diff: Dropbox/vimfiles/filetype \(toucan's conflicted copy 
>> 2014-03-01\).vim: No such file or directory
>>
>>
>>
>> shell returned 2
>>
>>
>>
>> However, if instead I typed
>>
>>
>>
>> :w !diff "^R%" -
>>
>>
>>
>> where ^R means Ctrl-R, the command became
>>
>>
>>
>> :w !diff "Dropbox/vimfiles/filetype (toucan's conflicted copy 
>> 2014-03-01).vim" -
>>
>>
>>
>> and worked fine.
>>
>>
>>
> 
> 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 %

-- regards, ingo

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


Re: [patch] doc/eval.txt and doc/map.txt: small fixes

2014-03-11 Thread Cade Forester
> In the example the function is called s:SID, and that's what is being
> matched.  I don't think this needs to change 

If somebody copy this code and rename function, pattern will not match.
Since the function name can't contain angle brackets, not necessarily
appending it to pattern.

> It's good to give a hint that it may be a function name, however adding
> too much text causes the line to wrap and that spoils the looks of the
> table.

I add few sentences and example:

-- 
-- 
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.
diff -r c2098c3095e7 runtime/doc/eval.txt
--- a/runtime/doc/eval.txt  Sat Mar 08 18:38:28 2014 +0100
+++ b/runtime/doc/eval.txt  Tue Mar 11 23:34:31 2014 +0700
@@ -2841,6 +2841,19 @@
"~/" expanded into the path of the home directory: >
:echo expand(expand(""))
 <
+   Expanding of "" is context depended. In global scope it
+   returns file name of sources file (|:source|), Inside function
+   it returns function name (|:|). Sourcing of file
+   with lines >
+   :function s:foo()
+   :  return expand( '' )
+   :endfunction
+   :echo expand( '' )
+   :echo s:foo()
+<  will output text like >
+   /tmp/script.vim
+   function 12_foo
+<
There cannot be white space between the variables and the
following modifier.  The |fnamemodify()| function can be used
to modify normal file names.
diff -r c2098c3095e7 runtime/doc/map.txt
--- a/runtime/doc/map.txt   Sat Mar 08 18:38:28 2014 +0100
+++ b/runtime/doc/map.txt   Tue Mar 11 23:34:31 2014 +0700
@@ -1105,7 +1105,7 @@
 If you need to get the script number to use in a complicated script, you can
 use this function: >
function s:SID()
- return matchstr(expand(''), '\zs\d\+\ze_SID$')
+ return matchstr(expand(''), '\zs\d\+\ze_')
endfun
 
 The "" will be shown when listing functions and mappings.  This is useful


Re: Incorrect expansion of %?

2014-03-11 Thread Charles Campbell

Ingo Karkat wrote:

On 11-Mar-2014 15:14 +0100, Ben Fritz wrote:



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("%"))

Regards,
Chip Campbell

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


Re: [patch] doc/eval.txt and doc/map.txt: small fixes

2014-03-11 Thread Nikolay Pavlov
On Mar 11, 2014 9:26 PM, "Cade Forester"  wrote:
>
> > In the example the function is called s:SID, and that's what is being
> > matched.  I don't think this needs to change
>
> If somebody copy this code and rename function, pattern will not match.
> Since the function name can't contain angle brackets, not necessarily
> appending it to pattern.

function :()
echo 'It works!'
endfunction
echo (:()+1)
" echoes "It works!", then 1

is a valid VimL code.

>
> > It's good to give a hint that it may be a function name, however adding
> > too much text causes the line to wrap and that spoils the looks of the
> > table.
>
> I add few sentences and example:
>
> --
> --
> 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.


Re: Incorrect expansion of %?

2014-03-11 Thread Nikolay Pavlov
On Mar 11, 2014 9:51 PM, "Charles Campbell" 
wrote:
>
> Ingo Karkat wrote:
>>
>> On 11-Mar-2014 15:14 +0100, Ben Fritz wrote:
>>
>>> 
>>>
>>> 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

. Note that what you posted here is *not* the right way: you forgot second
argument to shellescape().

>
> Regards,
> Chip Campbell
>
>
> --
> --
> 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.


Re: Incorrect expansion of %?

2014-03-11 Thread Gary Johnson
On 2014-03-11, Charles Campbell wrote:
> Ingo Karkat wrote:
> >On 11-Mar-2014 15:14 +0100, Ben Fritz wrote:
> >
> >>
> >>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 _%).

Not true.  Try this:

:file foo\ bar()
:!echo %

You will see the command as

:!echo foo bar\(\)

> 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("%"))

That's certainly a workaround, but I wouldn't call it the "right
way".  For one thing, it's way too much to type when you just want
to run a shell command on the current file.  For another, there are
several examples in Vim's help (":helpgrep :!.*%") that show that %
is expected to "just work" in a shell command.  Further, as I just
discovered, this bug was reported twice previously and has this
comment in todo.txt:

When the file name has parenthesis, e.g., "foo (bar).txt", ":!ls
'%'" has the parenthesis escaped but not the space.  That's
inconsistent.  Either escape neither or both.  No escaping might
be best, because it doesn't depend on particularities of the
shell. (Zvi Har'El, 2007 Nov 10) (Teemu Likonen, 2008 Jun 3)
However, for backwards compatibility escaping might be
necessary.  Check if the user put quotes around the expanded
item?

Finally, it is clear from the code in ex_docmd.c that the intended
behavior of % in a shell command is for any special characters to be
escaped as % is expanded.

Granted, your proposed solution is a good one for the immediate
problem of that diff command, which I have bound to  so I don't
really care what it looks like.  However, in this new age of people
using all sorts of wacky characters in file names, it would be nice
if either % or "%" just worked.

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.


Re: Incorrect expansion of %?

2014-03-11 Thread Gary Johnson
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:
> >>
> >>> 
> >>>
> >>> 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)

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.


Re: Incorrect expansion of %?

2014-03-11 Thread Nikolay Pavlov
On Mar 11, 2014 11:53 PM, "Gary Johnson"  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:
> > >>
> > >>> 
> > >>>
> > >>> 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.


Issue 205 in vim: Undo file broken

2014-03-11 Thread vim

Status: New
Owner: 
Labels: Type-Defect Priority-Medium

New issue 205 by rickywu1...@gmail.com: Undo file broken
http://code.google.com/p/vim/issues/detail?id=205

Vim 7.4 on Windows 8/8.1

If I set undofile, after some operations the edited file and undofile both  
are broken, edited file beceomes one long line only contains  
^@(); also get error that undofile is not correct.


This problem never happend if I use Windows 7 in the past.


--
You received this message because this project is configured to send all  
issue notifications to this address.

You may adjust your notification preferences at:
https://code.google.com/hosting/settings

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


Issue 206 in vim: Concealed characters cause cursor to give wide jumps

2014-03-11 Thread vim

Status: New
Owner: 
Labels: Type-Defect Priority-Medium

New issue 206 by obl...@gmail.com: Concealed characters cause cursor to  
give wide jumps

http://code.google.com/p/vim/issues/detail?id=206

What steps will reproduce the problem?
1. set virtualedit=all
2. set conceallevel=2
3. set concealcursor=vin
4. syn region placeHolder
 \matchgroup=placeHolderMark start=+\$`+
 \matchgroup=placeHolderMark end=+`+ concealends
5. Paste: $`1`$`2`$`3`$`4`$`5`
6. When the cursor moves past the text, it'll give a wide jump.
7. This is annoying for completion plugins that make use of conceal feature
   when entering text.

What is the expected output? What do you see instead?

I expect concealed text doesn't make the cursor jump randomly.


What version of the product are you using? On what operating system?

Latest Vim built from sources under Ubuntu.



--
You received this message because this project is configured to send all  
issue notifications to this address.

You may adjust your notification preferences at:
https://code.google.com/hosting/settings

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