Tuesday, May 24, 2011

Re: quick fix doesn't process info and warning messages correctly

>> set errorformat=\"%f\"\\,%l%*\\s%t%*\\a\ %n:\ %m " lint
>> set efm+=%I%>%p~ " lint multiline start
>> set efm+=%C\"%f\"\\,%l%*\\s%t%*\\a\ %n:\ %m,%Z " lint multiline later
>
> i tried reading more about the %> in vim help but i can't quite
> understand what it means. would you be able to explain?. btw the
> formats you gave worked.

Well, Vim tries each line of the :make output against each pattern in
turn. The patterns in 'errorformat' after running the above commands
are:

Pattern 1: "%f",%l%*\s%t%*\a %n: %m
Pattern 2: %I%>%p~
Pattern 3: %C"%f",%l%*\s%t%*\a %n: %m
Pattern 4: %Z

Now consider this output:

Line 1: some line of code
Line 2: ~
Line 3: "filepath1", 432 Info 4: this is an info message 4 for filepath1
Line 4:

First Vim looks at line 1. None of the patterns match, so it ignores it.

Then Vim looks at line 2, pattern 1 does not match, but pattern 2 does.
It starts a multi-line info message. Since pattern 2 matched and
contains %>, Vim remembers to start at pattern 2 for the next line.

So Vim looks at line 3. It does not try pattern 1, because of the %> in
the previous match; pattern 1 would have matched and messed things up,
but the %> stopped that from happening. Vim starts at pattern 2 but it
doesn't match, so then it tries pattern 3, which does, continuing the
multi-line message.

Then Vim moves on to line 4. It tries patterns 1, 2 and 3 (there is no
%> in effect this time) and none of them match, so finally it tries
pattern 4, and it does, and ends the multi-line message.

Hope this helps,

Ben.

P.S. Actually, pattern 2 could probably use %A rather than %I and it
would still work, as well as work if the ~ thing occurred for errors or
warnings.

--
You received this message from the "vim_use" 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

No comments: