Hi Pavol
On 2015-07-24 Friday at 10:42 -0700 Pavol Juhas wrote:
> On Thursday, July 23, 2015 at 2:11:05 PM UTC-4, Roland Eggner wrote:
> > Hi Bram
> ...
> > v4:
> > Further improvements based on imput from Pavol Juhas (mail thread “Issue
> > 385 in
> > vim: expansion of environment variables fails in Vim backtick expression”).
> ...
>
> > diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
> > --- a/runtime/doc/cmdline.txt
> > +++ b/runtime/doc/cmdline.txt
> >
> > ...
> >
> > +If the expression contains an unquoted environment variable reference
> > without
> > +call to |expand()|, the value of this variable -- not only its name -- is
> > +evaluated as a Vim expression (3rd and 4th example below). Single or
> > double
> > +quotes can be used to avoid this effect (5th and 6th example below). See
> > also
> > +|expr-env-expand|.
> > +Some examples illustrate possible usages:
> > + :edit ``=tempname()``
> > + :edit `=expand('$HOME') . '/.vimrc'`
> > + :let home = 2
> > + :let user = 3 " assuming $HOME == '/home/user'
> > + :edit `=36 $HOME . '/.vimrc'` " creates a buffer '6/.vimrc'
> > + :edit `=$Hquoted . '/.vimrc'` " assuming $Hquoted == '"/home/user"'
>
>
> Hi Roland,
>
> I don't think this is a good solution. It would be much better to fix the
> buggy behavior of environment variables inside the `={expr}` expressions
> rather than declaring it a feature -- and having to describe all the
> unexpected side effects
> [can anyone possibly expect that `=36 $HOME` expands to 6?]
> and convoluted quotations that mask up the bug.
My intent is just to help users and patch contributors in both cases of Bram's
decision “bug or feature”. Consider how much of your and my time could have
been saved, if my patch had been merged already (thanks to Bram for merging
the essential parts of v1 in runtime file update 2015-07-21).
> If there was a similar problem for the command
>
> :let v = $HOME . '/.vimrc'
>
> should it be handled by updating the :let documents?
Good question. The answer depends on Bram's decision: bug or feature, and
how to cope with the regarding inconsistencies.
> On another page, I propose that an invalid expression in
>
> :e `=invalid expression`
>
> should raise "E79: Cannot expand wildcards" without opening any new buffer.
> This would be consistent with the handling of errors in regular backticks,
> such as
>
> :e `/not/a/command`
Agreed. Error messages should provide a solution, or at least guide to
initial steps for a way to a solution. This could be “:h E…” if the error
documentation would be more specific than current “:h E15”, e.g. as “:h E15_`”
provided with my patch merged, just with another, specific error number. With
this considerations I put the focus in my patch on _working_ examples usable
as templates for real life solutions.
> I am very busy these days, but hopefully in few weeks I can put
> some time into fixing the `= expansion.
Looking forward :)
Just for the records a few more inconsistencies:
:e `='$HOME/filename with spaces + "ugly" % | # characters 1'`
:e `=expand('$HOME') . '/filename with spaces + "ugly" % | # characters
2'`
both work, as already written, whereas from the following variants, 3 (special
surprise) and 4 take the tilde literally (message “[New DIRECTORY]”), and
5 and 6 raise “E15” and “E79”:
:e `=expand('~') . '/filename with spaces + "ugly" % | # characters 3'`
"~/filename with spaces + "ugly" % | # characters 3" [New DIRECTORY]
:e `='~/filename with spaces + "ugly" % | # characters 4'`
"~/filename with spaces + "ugly" % | # characters 4" [New DIRECTORY]
:e `=~'/filename with spaces + "ugly" % | # characters 5'`
E15: Invalid expression: ~'/filename with spaces + "ugly" % | # characters 5'`
E15: Invalid expression: ~'/filename with spaces +
E79: Cannot expand wildcards
"`=~'/filename with spaces +" [New DIRECTORY]
:e `=~/'filename with spaces + "ugly" % | # characters 6'`
E15: Invalid expression: ~/'filename with spaces + "ugly" % | # characters 6'`
E15: Invalid expression: ~/'filename with spaces +
E79: Cannot expand wildcards
"`=~/'filename with spaces +" [New DIRECTORY]
:ls
1 "~/filename with spaces + "ugly" % | # characters 1" line 1
2 "~/filename with spaces + "ugly" % | # characters 2" line 1
3 "~/filename with spaces + "ugly" % | # characters 3" line 1
4 "~/filename with spaces + "ugly" % | # characters 4" line 1
5 # "`=~'/filename with spaces +" line 1
6 %a "`=~/'filename with spaces +" line 1
--
Best regards,
Roland Eggner
--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.
pgpKLvbUTYa5P.pgp
Description: PGP signature
