Summary: parsing %f with errorformat depends on isfname. It
probably shouldn't.
Assume we want to parse an error message like this:
[W302] some_file: 13/5
That's easy, setting errorformat to '[%t%n] %f: %l/%c' works:
let &errorformat = '[%t%n] %f: %l/%c'
cgetexpr ['[W302] some_file: 13/5']
cc
Output:
"some_file" [New file] --No lines in buffer--
(1 of 1) warning 302:
It keeps working even when the filename contains special characters:
let &errorformat = '[%t%n] %f: %l/%c'
cgetexpr ['[W302] so''m"e fi*le: 13/5']
cc
Output:
"so'm"e fi*le" [New File]
(1 of 1) warning 302:
Now let's try to make a small change:
[W302] some_file, 13/5
that is, replace ':' with ','. This no longer works:
let &errorformat = '[%t%n] %f\, %l/%c'
cgetexpr ['[w302] so''m"e fi*le, 13/5']
cc
Output:
(1 of 1): [w302] so'm"e fi*le, 13/5
There's no filename, the entire string is parsed as an invalid message.
Looking at the sources, this happens because '%f:' is parsed as
'.\{-1,}:', while '%f\,' is parsed as '\f\+,'. More preciseley:
let pat = 'so'm"e fi*le:'
echo matchlist(pat, '^\m.\{-1,}:')
outputs
['so'm"e fi*le:', ', '', '', '', '', '', '', '', '']
while
let pat = 'so''m"e fi*le,'
echo matchlist(pat, '^\f\+,')
outputs an empty list. In turn, that's because of isfname. According
to the manual:
: Think twice before adding white space to this option. Although a
: space may appear inside a file name, the effect will be that Vim
: doesn't know where a file name starts or ends when doing completion.
And indeed, adding the corresponding junk to isfname makes
errorformat work again:
set isfname+=',\",32,*
let &errorformat = '[%t%n] %f\, %l/%c'
cgetexpr ['[W302] so''m"e fi*le, 13/5']
cc
Output:
"so'm"e fi*le" [New File]
(1 of 1) warning 302:
This is inconsistent at best. There is no reason for the result
of parsing errors with errorformat to depend on isfname. There is no
danger of confusing anything if special characters appear in filenames
in error messages.
/lcd
--
--
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.