Scope used for :tree command
Bram Moolenaar <[email protected]>
| Newsgroups | gmane.comp.tools.aap.devel |
|---|---|
| Message-ID | <[email protected]> |
I was looking into how the :tree command works. You can see the docs
here:
http://www.a-a-p.org/exec/ref-commands.html#cmd-tree
Currently the commands for the :tree command are executed in a new
scope. Thus if you want to add files to a variable you would need to do
something like this:
source =
:tree . {filename = .*\.c}
_caller.source += $name
:print $source
That looks weird, using the _caller scope.
Would there be an objection against using the current scope for the
commands? Then you can do:
source =
:tree . {filename = .*\.c}
source += $name
:print $source
This looks more like it's a "for name in list" command.
A side effect is that any variables set in the :tree commands overwrite
existing variables in the surrounding scope. For example, $name is
changed. And the _caller scope is no longer available. Thus this is
incompatible with previous versions.
Opinions?
--
Save the plankton - eat a whale.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
\\\ Project leader for A-A-P -- http://www.A-A-P.org ///
\\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf