RE: Changing the C Indent style

2009-03-12 Thread Gene Kwiecinski
>>Might be academic at this point, but for a single *statement* (not line) >>following a for(), if(), while(), etc., enclosing braces are *not* >>required.  So >I realise this, but all C software that I write must be compliant with >the MISRA-C guidelines for the use of the C language in critical

Re: Changing the C Indent style

2009-03-12 Thread A. S. Budden
2009/3/12 Ben Schmidt : > func! MyCindent(l)   let extra = match(getline(prevnonblank(a:l-1)),'^\s*{.*}$')==-1?0:-&sw   let extra += match(getline(a:l),'^\s*{.*}$')==-1?0:&sw   return cindent(a:l)+extra endfunc :let &l:indentexpr='MyCindent(v:lnum)' :setlocal cin

Re: Changing the C Indent style

2009-03-12 Thread Ben Schmidt
>>> func! MyCindent(l) >>> let extra = match(getline(prevnonblank(a:l-1)),'^\s*{.*}$')==-1?0:-&sw >>> let extra += match(getline(a:l),'^\s*{.*}$')==-1?0:&sw >>> return cindent(a:l)+extra >>> endfunc >>> :let &l:indentexpr='MyCindent(v:lnum)' >>> :setlocal cinkeys+=} Hmm. It still doesn't se

Re: Changing the C Indent style

2009-03-12 Thread Ben Schmidt
A. S. Budden wrote: > 2009/3/12 Ben Schmidt : >>> Yes, but it's clearer (to me) than >>> >>> for (;;) >>> {CallFunction();} >> It looks like you resort to: >> >> func! MyCindent(l) >> let extra = match(getline(prevnonblank(a:l-1)),'^\s*{.*}$')==-1?0:-&sw >> let extra += match(getline(a:l),'^\s

Re: Changing the C Indent style

2009-03-12 Thread A. S. Budden
2009/3/12 Ben Schmidt : > >> Yes, but it's clearer (to me) than >> >> for (;;) >> {CallFunction();} > > It looks like you resort to: > > func! MyCindent(l) >   let extra = match(getline(prevnonblank(a:l-1)),'^\s*{.*}$')==-1?0:-&sw >   let extra += match(getline(a:l),'^\s*{.*}$')==-1?0:&sw >   retu

Re: Changing the C Indent style

2009-03-12 Thread A. S. Budden
2009/3/11 Gene Kwiecinski : > >>>His indentation of opening braces is inconsistent. > >>Yes, but it's clearer (to me) than >>for (;;) >>{CallFunction();} > > Might be academic at this point, but for a single *statement* (not line) > following a for(), if(), while(), etc., enclosing braces are *not

Re: Changing the C Indent style

2009-03-12 Thread Ben Schmidt
> Yes, but it's clearer (to me) than > > for (;;) > {CallFunction();} It looks like you resort to: func! MyCindent(l) let extra = match(getline(prevnonblank(a:l-1)),'^\s*{.*}$')==-1?0:-&sw let extra += match(getline(a:l),'^\s*{.*}$')==-1?0:&sw return cindent(a:l)+extra endfunc :let &l:

Re: Changing the C Indent style

2009-03-11 Thread Ben Fritz
On Mar 11, 11:16 am, "Gene Kwiecinski" wrote: > > Ooh..  Quick example:  Why bother with a rather ghastly > >         >                 >                         >                                 Caution >                         >                 >                 >                    

RE: Changing the C Indent style

2009-03-11 Thread Gene Kwiecinski
>>His indentation of opening braces is inconsistent. >Yes, but it's clearer (to me) than >for (;;) >{CallFunction();} Might be academic at this point, but for a single *statement* (not line) following a for(), if(), while(), etc., enclosing braces are *not* required. So for(;;)

Re: Changing the C Indent style

2009-03-11 Thread Ben Fritz
On Mar 11, 1:47 am, Gary Johnson wrote: > > I don't think there's any way to use those options to do what he > wants to do, though.  His indentation of opening braces is > inconsistent. > Yeah, I guess not. Looks like it is time to write your own function for use in an indentexpr. You can ha

Re: Changing the C Indent style

2009-03-11 Thread A. S. Budden
2009/3/11 Gary Johnson : > > On 2009-03-10, Ben Fritz wrote: >> On Mar 10, 10:02 am, "A. S. Budden" wrote: >> >> >> > I was wondering whether it is possible to make a (minor) change to the >> > indent style used for C code.  Generally I like the style and I don't >> > want to change much.  The on

Re: Changing the C Indent style

2009-03-10 Thread Gary Johnson
On 2009-03-10, Ben Fritz wrote: > On Mar 10, 10:02 am, "A. S. Budden" wrote: > > > > I was wondering whether it is possible to make a (minor) change to the > > indent style used for C code.  Generally I like the style and I don't > > want to change much.  The only exception that I'd like to add

Re: Changing the C Indent style

2009-03-10 Thread Ben Fritz
On Mar 10, 10:02 am, "A. S. Budden" wrote: > I was wondering whether it is possible to make a (minor) change to the > indent style used for C code.  Generally I like the style and I don't > want to change much.  The only exception that I'd like to add is such > that the following code is inde

Re: Changing the C Indent style

2009-03-10 Thread pansz
A. S. Budden 写道: > for (;;) > { > /* This is indented correctly: I don't want to change this */ > CallFunction1(); > CallFunction2(); > } > > for (;;) > {CallFunction();} /* This is what I'd like to support for single > lines with open and close braces */ > > for (;;) > {CallFunc

Changing the C Indent style

2009-03-10 Thread A. S. Budden
Dear all, I was wondering whether it is possible to make a (minor) change to the indent style used for C code. Generally I like the style and I don't want to change much. The only exception that I'd like to add is such that the following code is indented as shown (I've changed tabs to spaces fo