On 09/14/2014 02:30 PM, Alexander Monakov wrote:
On Thu, 11 Sep 2014, Yury Gribov wrote:
Ok, it tooks some time. Basically we want brace symbol to behave differently
in two contexts:

1) not add any additional offset when not following control flow operator:
void
f ()
{
   int x;
   {
   }
}

Note that GCC commonly uses custom iteration macros, e.g.:

   FOR_EACH_BB_FN(bb, fn)
     {
       do_stuff;
     }

and cinoptions that get the braces-in-switch case wrong should get constructs
like the above right.

Right, looks like a fair tradeoff.

(to get gnu-style autoindent in Vim, I've been using
http://www.vim.org/scripts/script.php?script_id=575 and would adjust braces in
switch by hand if need arose; the script is probably very close to one of
approaches posted in this thread, but I haven't checked)

Thanks for sharing, these Vim configs just keep popping up. Here are results of quick analysis.

Plugin's pros:
* KR-style parameters are 4 chars instead of 5 (not sure that's important for GCC but matters in e.g. zlib so makes sense to borrow; I'll update next version of patch with this)
* explicitly set f0 in cino (again makes sense to borrow)

And cons:
* sets formatting globally for all *.c files
* only works for C sources and headers so e.g. won't work for libstdc++
* does not know about C++ formatting (e.g. public:, etc.)
* continuation line is indented by 1 char instead of GCC's 2

And also some stuff which we probably don't care about:
* plugin does not use softtabstop so Tab inserts a real tab character
* better formatting of special type of comments:
/* Start
 * Middle
 */
* sets up browsefilter on MS platforms

-Y

Reply via email to