Monday, May 23, 2011

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

>> First, note that it doesn't behave as you claim. I saved your example
>> into a file, sourced your :set commands then did :cfile on the file
>> saved earlier, and I got this in the quickfix window:
>>
>> || filepath1,123, Warning 3: this is a warning message 3 for filepath1
>> || filepath1, 432, Info 4: this is an info message 4 for filepath1
>>
>> When I changed your example data to this:
>>
>> "filepath1",123 Warning 3: this is a warning message 3 for filepath1
>> "filepath1",432 Info 4: this is an info message 4 for filepath1
>>
>> I could get your results. It would be helpful if you could take a bit
>> more care to post data that truly does work as you claim in future--i.e.
>> test it before you push send!
>>
>> I think the problem is your first :set. The %C rule, being early,
>> defines Info to be a continuation of a previous message. What are you
>> trying to achieve with the ~ stuff? It works without it, i.e. with:
>>
>> set errorformat=%I\"%f\"\\,%l%\\s%\\+Info\ %n:\ %m,%Z " lint info
>> set errorformat+=%W\"%f\"\\,%l%\\s%\\+Warning\ %n:\ %m,%Z " lint warnings
>> set errorformat+=%E\"%f\"\\,%l%\\s%\\+Error\ %n:\ %m,%Z " lint errors
>>
>> Cheers,
>>
>> Ben.
>
> ben, my apologies for not posting a complete error. and it seems i
> have to apologize for not explaining why there is a ~ in the error
> format.
> the lint tool has two formats for info messages:
>
> info type 1
>
> some line of code
> ~
> "filepath1", 432, Info 4: this is an info message 4 for filepath1
>
> info type 2
> "filepath2", 123, Info 5: this is an info message 4 for filepath1

These still don't look right. Is there really a comma after the line
number? I tried that earlier and it didn't work.

> ~ shows the column of the line where error/info/warning occurred.
> the following errorformat supposed to catch info message with a ~ in
> it.
> set errorformat=%I%p~,%C\"%f\"\\,%l%\\s%\\+Info\ %n:\ %m,%Z

It is indeed a bit awkward. Maybe reordering it and using %> would work,
as Vim will always match the first rule unless you use something like %>
to restrict that.

set errorformat=%E\"%f\"\\,%l%\\s%\\+Error\ %n:\ %m,%Z " lint errors
set errorformat+=%W\"%f\"\\,%l%\\s%\\+Warning\ %n:\ %m,%Z " lint warnings
set errorformat+=%I\"%f\"\\,%l%\\s%\\+Info\ %n:\ %m,%Z " lint info
set errorformat+=%I%>%p~,%C\"%f\"\\,%l%\\s%\\+Info\ %n:\ %m,%Z " lint info

There's a bunch more in there than you need, e.g. you only need a single
%Z, not one for each multiline rule, because every pattern in the
errorformat is independent and active, really; Vim doesn't read them in
'blocks'. Actually you could probably combine almost all of them and use
%A with %t to match them. Or indeed, not even use %A, since
you actually have nothing multi-line in there except when you use %p.
So, perhaps this will work:

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 haven't tested it, as your test data still isn't really adequate (e.g.
don't know if there are blank lines between messages, whether there's
any standard prologue, whether a blank line begins the output, whether
that comma is really there, whether the message with the filename can
overflow onto a second line, etc.). Hopefully these ideas get you
started to solve it, though.

Ben.

--
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: