Eric Leenman wrote:
Hi,

I have a file big log like with plenty warnings.
They start with the text WARNING somewhere in the line.
The end with WARNING ENDED also somewhere in the line
These WARNING and WARNING ENDED is unique in the log, and are used as open and closing marks,
like { and } in C-functions.

Before and after can appear all ASCII-characters, meaning a till z, A till Z and [EMAIL PROTECTED]&*()_+.
So the following are all valid:

WARNING
WARNING aaa
WARNING aaa [EMAIL PROTECTED]&*()_+

   WARNING
   WARNING aaa
   WARNING aaa [EMAIL PROTECTED]&*()_+


aaa [EMAIL PROTECTED]&*()_+ WARNING
[EMAIL PROTECTED]&*()_+ WARNING aaa
[EMAIL PROTECTED]&*()_+ WARNING aaa ###
[EMAIL PROTECTED]&*()_+ WARNING aaa ### %%%

   aaa [EMAIL PROTECTED]&*()_+ WARNING
       [EMAIL PROTECTED]&*()_+ WARNING aaa
       [EMAIL PROTECTED]&*()_+ WARNING aaa ###
       [EMAIL PROTECTED]&*()_+ WARNING aaa ### %%%


This warnings is at least two lines, but can be longer.
For example when 16 bits of bus is not connected, like:

Three examples here :

WARNING 200 about DBUS(16:0)
+-- DBUS(9) is not connected, connected it to ground !
+-- DBUS(10) is not connected, connected it to ground !
+-- DBUS(11) is not connected, connected it to ground !
+-- DBUS(12) is not connected, connected it to ground !
+-- DBUS(13) is not connected, connected it to ground !
+-- DBUS(14) is not connected, connected it to ground !
+-- DBUS(15) is not connected, connected it to ground !
WARNING ENDED

U1:submodule U2: WARNING 301 : Input clock is floating
U1:submodule U2: WARNING ENDED 301 => Critical warning.


   WARNING 56 : Nothing connected sout(0,1) and sout(2)
   WARNING ENDED 56

Many of these warnings are known and not a problem.
But what I want is to fold them to one line to have a more clear overview so that the new ones are easier spotted.
So that the above appears as

+-- 8 lines: WARNING 200 about DBUS(16:0)
+-- 2 lines: U1:submodule U2: WARNING 301 : Input clock is floating
+-- 2 lines:     WARNING 56 : Nothing connected sout(0,1) and sout(2)


I tried the suggestions earlier this week, but fail to get this working.

Thanks anyway.
Best regards,
Eric

Folding by marker wont't work because the endmaker is part of the start-marker. You might try folding by expression (I don't guarantee it'll be fast):

        :set foldmethod=expr
        :set foldexpr=(getline(v:lnum)\ =~\ '\\<WARNING\\>')\ ?
                \\ (getline(v:lnum)\ =~\ '\\<WARNING\ ENDED\\>')\ ?
                \\ 's1'\ :\ 'a1'\ :\ '='

I hope I didn't goof in constructing the expression: it should evaluate to 's1' if the line to be evaluated contains 'WARNING ENDED' (between word boundaries), else to 'a1' if the line contains 'WARNING' (between word boundaries), else to '='. Remember that when storing the operand of a ":set" instruction, spaces and backslashes must be backslash-escaped, and that a backslash as the first nonblank in a line (in 'nocompatible' mode) marks the start of a continuation line.

This asumes that WARNING (start of message) and WARNING ENDED won't appear on the same line. If they may, but WARNING (other than WARNING ENDED) is always followed by a space and a digit, there might still be a possibility. Implementing it is left as an exercise to the student.

Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
145. You e-mail your boss, informing him you'll be late.

Reply via email to