Christian Brabandt <[email protected]> wrote:
> Am 2016-09-01 07:41, schrieb Dominique Pellé:
>>
>> Manuel Ortega <[email protected]> wrote:
>>
>>> The docs at :h file-pattern don't mention it, but I seem to be able to
>>> use
>>> "\=" just fine in autocmd patterns, and it seems to mean what it means in
>>> :h
>>> pattern-overview ("zero or one").
>>>
>>> For instance, `au SomeGroup *.[xgb]z2\= some_command` will fire on files
>>> with any of the following extensions:
>>>
>>> .xz
>>> .gz
>>> .bz2
>>> .bz
>>>
>>> Maybe this a fluke and it's not supposed to work this way. But if it is
>>> supposed to work this way it should be in the docs at :h file-pattern
>>>
>>> -Manny
>>
>>
>> I think that it's not expected and I see it a bug.
>> glob2regpat() gives what look like unexpected
>> results for:
>>
>> :echo glob2regpat('a\=')
>> Actual: ^a\=$
>> Expected: ^a\\=$
>>
>> :echo glob2regpat('a\+')
>> Actual: ^a\+$
>> Expected: ^a\\+$
>>
>> :echo glob2regpat('a\d')
>> Actual: ^a\d$
>> Expected: ^a\\d$
>>
>> And many probably many other cases
>> where \ is special in regexp, but not special
>> in glob special characters.
>
>
> I believe this is not true. The documentation mentions this:
> ,----[ :h file-pattern ]-
> | *file-pattern*
> | The pattern is interpreted like mostly used in file names:
> | * matches any sequence of characters; Unusual: includes path
> | [...]
> | \ special meaning like in a |pattern|
> | [...]
> `----
>
> So one can expect '\=' to work like a regexp pattern.
Ah, I misunderstood that then. Sorry.
But still, help files could still be improved in my opinion:
- :help glob links to :help wildcard which does not have
much information, and does not link to file-pattern
which has more information, even if it's also not complete.
- there is an overlap between information in :help wildcard
and :help file-pattern.I t's not clear to me what's different.
- a few examples in help files would be useful.
- we can add test cases for things like
glob2regpat('a\=') -> ^a\=$ in src/testdir/test_glob2regpat.vim
if that's indeed the expected behavior.
- Apparently 'magic' option is ignored by glob2regpat(), which
is fine, but it deserves to be documented.
- do character * and ? keep their special meaning inside [...]?
Trying...
:echo glob2regpat('a[*]')
^a[.*]$
That does not look right. It will only match dots and stars.
It would make more sense if glob special char * and ? lose
their special meaning inside [...] so the result would be:
^a[*]$ or its equivalent to ^a\*'
Similarly:
:echo glob2regpat('a[.]')
^a[\.]$
... will match backslashes and dots which seems wrong.
Cheers
Dominique
--
--
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.