On Oct 24, 2011, at 6:06 PM, erik wrote:

> Can you have a look again. Let's see what surprises will pop up.

The indent now works perfectly on several of my large scripts including the one 
I sent you.  The only difference is the alignment of continuation lines in the 
original.  I personally stopped aligning things long time ago and prefer your 
choice of a fixed indentation amount relative to the previous line. Perhaps the 
amount of indent could be made configurable similar to C-indent (0.5s, 1s, 
etc.), but, it's not necessary.

Those are good news.
I was really happy to see it work on the large awk program so well.

I didn't have time to look deeply over all of my awk programs.
A quick comparison of some smaller programs has uncovered couple of issues.

1. It seems that side comments are still confusing the indent.
   For example:

        if (comment && $0 ~ comment_expr || in_comment) {
                if ($0 ~ /:[ ]*$/) {    # the last line ends in : not :\
                        in_comment = 0
                } else {
                        in_comment = 1
                }
                $0 = "#" $0
        } 

   was indented as:

        if (comment && $0 ~ comment_expr || in_comment) {
                if ($0 ~ /:[ ]*$/) { # the last line ends in : not :\
                        in_comment = 0
        } else {
                in_comment = 1
        }
        $0 = "#" $0
        } 

   If the side comment is deleted it indents correctly.

2. A backslash on the line that is **not** a line continuation, confuses 
   the indent and it treats the next line as a continuation.
   For example:

        split($1, line, /[ \t]/)        # line: *** 321,52 ****
        split(line[2], start, /,/)

   was indented as:

        split($1, line, /[ \t]/)        # line: *** 321,52 ****
                split(line[2], start, /,/)

   Again, if the side comment is removed, the line is indented
   correctly.  So, perhaps this will be fixed by fixing 1.

3. In a quick, one-off try, this:

        if (c > 0) name = substr(narr[1], 1, c-1)
        else name = narr[1]
        if (k > 1) {
                ...
        }
        ...

   was indented as:

        if (c > 0) name = substr(narr[1], 1, c-1)
        else name = narr[1]
                if (k > 1) {
                        ...
                }
                ...

   We could argue that this style is bad. I would not use it.
   But there is awk code written in this style out there and the indent
   seems to be confused by the one-liners.


As I get some time I'll look and compare with my other programs, but I probably 
will not have time for that before the weekend.

Best regards,

        Zvezdan

 

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

Raspunde prin e-mail lui