Hari Krishna Dara wrote:
The help on glob() or globpath() don't indicate what type of
metacharacters are accepted, but there is a separate section called
|file-pattern| that describes the metacharacters used for filename
matching for autocommands. I don't know if these are applicable for
glob() and globpath() as well, but a lot of these don't seem to work as
described. Is there a different section that I am missing to see, or is
it completely left out? Are the metacharacters predictable, or dependent
on the platform and environment? If so, is there a base set that could
work on all?
The reason I am asking is that I would like to translate a
filename-pattern to a Vim regex-pattern such that I can highlight the
part of the filename that matched the filename-pattern, after getting
the results from glob() or globpath(), so I need to know all the
supported chars.
After a little search through the source, it seems that the expansion
for f_glob() [the C function which provides the Vim-script glob()
function] is done by ExpandOne() which (at least in some cases) calls
mch_expand_wildcards(), which (except on VMS) invokes the shell to do
the expansion. So it could be at least partly platform-specific. I may
have missed something, since I only see the definition of
mch_expand_wildcards() for RiscOS (where it always fails), Unix and VMS.
Yet I have the full unix+extra+lang sources. Maybe the function is
defined in a non-Vim library for these OSes (including OS2 where I see
"always use mch_expand_wildcards" in a comment to a #define
ExpandOne() is called from various places in the code, not only from
glob(), which makes me believe that filename wildcard expansion is done
in a uniform manner. But here also, I may have missed something.
Best regards,
Tony.