On Sep 30, 2011, at 8:45 AM, erik wrote:

> I think I have this issue is fixed, as well as every other pending
> complaint.


Not all issues yet. :-)


> May I ask all involved in this thread to evaluate?


Gladly.


> You can find the indenter here: http://dl.dropbox.com/u/26176183/awk.vim


Thanks for providing this.


> Tested with vim 7.3 and 6.3, on several awk programs. It works fine on
> 7.3. It fails on vim 6.3 because imho cursor( v:lnum, 1) does not work
> (at least during indent).
> 
> Hope you like it.

First, the good news: It works much better than before.

The following doesn't work.

1. This may be a matter of preference but I think the continued lines
   are not aligned correctly.  For example, the code I aligned as this:

        vcard_tr_palm = "ADR;WORK ADR;HOME ADR " \
                        "TEL;WORK TEL;FAX " \
                        ...

   is aligned by awk.vim as this:

        vcard_tr_palm = "ADR;WORK ADR;HOME ADR " \
                      "TEL;WORK TEL;FAX " \
                      ...

   IOW, I believe that continued lines should be aligned either:

        (a) fixed amount (e.g. one shiftwidth), or
        (b) under the first line part to the right of equal sign

   The awk.vim indents it exactly under the = sign.
  
   Solution: If you move it two spaces further from = sign it would get
             aligned under the first line text.

   Another example:

        param_regex = (options["v2"] || options["v2e"]) ? ptext_regex : \
                      name_regex "=" pvalue_regex "(," pvalue_regex ")*"      


2. This remaining ones are definitely bugs.
   This code (my alignment):

        if ($i !~ ldif_regex &&
            $i !~ /^mozilla_AimScreenName:[:<]? */) {
                print "Ignoring badly formed line: " $i >"/dev/stderr"
                continue                                              
        }                                                            
        if (attr != "") {                                            
                if (base64)     value = decode(value)                
                parse_and_store_ldif_value(attr, value)              
        }
        ...

   is aligned by awk.vim as this.

        if ($i !~ ldif_regex &&
            $i !~ /^mozilla_AimScreenName:[:<]? */) {
                    print "Ignoring badly formed line: " $i >"/dev/stderr"
                    continue                                              
            }                                                            
            if (attr != "") {                                            
                    if (base64) value = decode(value)                
                    parse_and_store_ldif_value(attr, value)              
            }
            ...

   So, everything is indented wrongly additional four spaces because
   the condition of the if statement is broken in two lines.
   The indentation is relative to the second line of the condition.
   The closing brace "}" is wrongly indented, and then everything below
   that brace as well (the next if statement).

   It seems that every continued condition in my code was indented
   wrongly as shown above.  Some of them were broken after && and some
   after || operator.

   Solution: Indent relative to the line where if statement starts.
             Similarly for other statements (e.g., while, for, ...)


3. The following is not indented correctly (my alignment first):

        if (!(a in ab_a)) {
                if (toupper(a) in ab_a)
                        move_value(a, toupper(a))                    
                else
                        delete person[a]
        }

   It was indented by awk.vim as follows:

        if (!(a in ab_a)) {
                if (toupper(a) in ab_a)
                move_value(a, toupper(a))                    
                else
                        delete person[a]
        }

   The line below if without the brace is not indented relative to if.

   Solution: Indent it relative to if.
             Similarly for if statement without braces surrounded by
             while or for statement with the braces.

 
4. In a long if-else if-else if ... else statement:

        } else if (backend == "mutt" || backend == "mailrc") {
                a = attr " " value
        } else {                                # mh
                a = value                                                    
        }

   awk.vim indents as follows:

        } else if (backend == "mutt" || backend == "mailrc") {
                a = attr " " value
        } else {                                # mh
        a = value                                                    
        }

   The statement inside else is not indented correctly (perhaps because
   of that # mh comment? or because it's a cuddled "} else {"
   [standard style])

   Solution: Indent it even if the comment follows cuddled "} else {".


5. The following code gets incorrect indentation and after that
   everything is so broken that looking at the diff becomes useless.

   My indentation first.  (The standard awk style is to declare input
   arguments for the function first, then several spaces or TAB, then
   the local variables.  Since this function has a lot of local
   variables, they couldn't all fit on a line with that TAB separator.)

function format_alias(fmt, quote, sep,
                      i, n, q, a, m, s, name, email) {
        if (!("n" in person && "sn" in person && "nickname" in person) &&
            !("member" in person && "nickname" in person)) {
                if ("email" in person) {
                        print "Missing name, surname, or nickname for " \
                              person["email"]
                }
                return
        }
        ...
}

   This was indented by awk.vim as follows:

function format_alias(fmt, quote, sep,
                      i, n, q, a, m, s, name, email) {
                              if (!("n" in person && "sn" in person && 
"nickname" in person) &&
                                     !("member" in person && "nickname" in 
person)) {
                                             if ("email" in person) {
                                                     print "Missing name, 
surname, or nickname for " \
                                                           person["email"]
                                             }
                                             return
                                      }
                                      ...
                      }

   Obviously, this is just a more pronounced example of continued
   parenthesized expression (e.g., condition or argument/variable list)
   gone wrong.  Notice also that a continued condition in the first
   if statement is indented 7 spaces instead of a full shiftwidth.
   Is that because of "!"?  It should be simply aligned as shown in
   the original.

   Solution:  Indent based on the line that starts the function
              (with the function keyword).


Erik, I hope this helps.

I'm quite sure that if you fix the continued parenthesized line
handling everything will pretty much fall into place.
The alignment of continued assignments should be an easy fix.
I don't know what is causing that cuddled else problem,
but that would be the only remaining thing to fix.

If you don't have my large awk program any more,
I can send it off the list.

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