On Sun, Apr 24, 2011 at 06:25:44PM -0700, Ernie Rael wrote:
> On 4/24/2011 4:39 PM, Zvezdan Petkovic wrote:
> >On Apr 24, 2011, at 5:18 PM, Lech Lorens wrote:
> >
> >>Vim, when 'cino' is set to "(0,ts", will incorrectly indent
> >>the following function:
> >>#v+
> >>static
> >>void func(int a
> >>#if defined(FOO)
> >>        , int b
> >>        , int c
> >>#endif
> >>        )
> >>
> >>
> >
> >Also, I've never seen commas positioned as they are in your example.
> >Style rules are simple.  Write as you write in English.
> >Comma is placed next to the word _before_ it, and has a space _after_ it.
> >
> >
> Considering the "#if defined(FOO)" , what you suggest doesn't work well. 
> I've seen this style, and use it myself, when the comma handling is an 
> issue with included/excluded lines. Now if parsers allowed a trailing 
> comma...

You are right.
I overlooked that the comma was moved there because of the pre-processor
directive.  This case is clearly a justified exception to comma
placement due to pre-processing.
However, that was just a side comment.

My comment about the style of the return type is still valid though.
Position of commas does not change the indenting if cinoptions=(0,t0

#v+
static void
func(int a
#if defined(FOO)
     , int b
     , int c
#endif
    )
{
}
#v-

Even the OP's style indents as he expects with cinoptions=(0,t0

#v+
static
void func(int a
#if defined(FOO)
          , int b
          , int c
#endif
         )
{
}
#v-

So, the issue here is the style of return type indentation.
If OP wants the indenting as shown above, then he needs to use "t0" in
the cinoptions.

I was just pointing out that OP's use of "ts" required Vim to indent
that way.  It indented the return type by a shiftwidth ("ts") and
aligned the content in parentheses as requested by "(0".
IOW, Vim behaved as requested.

Unfortunately, there might be something wrong with "ts" indentation and
it seems to be unrelated to pre-processing directives.
Experimenting with this a little, I found out that this does not indent
as requested by cinoptions=(0,ts and described in Vim help:

/* Just to have a line before it */
static void
func(int a,
     int b,
     int c
    )
{
}

This indents as requested by "ts":

/* Just to have a line before it */
        static void
func(int a, int b, int c)
{
}

It seems that when parameters are not on the same line the "ts" is not
processed as documented.

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