Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 36549421181 for ; Tue, 17 Jan 2012 07:36:59 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KTkQBpbIThds for ; Tue, 17 Jan 2012 07:36:58 -0800 (PST) Received: from mail-gw3.nixu.fi (mail-gw3.nixu.fi [193.209.237.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 56C23429E3B for ; Tue, 17 Jan 2012 07:36:58 -0800 (PST) Received: from pps.filterd (mail-gw3 [127.0.0.1]) by mail-gw3.nixu.fi (8.14.4/8.14.4) with SMTP id q0HFatZ8010226; Tue, 17 Jan 2012 17:36:55 +0200 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31]) by mail-gw3.nixu.fi with ESMTP id 114cs180p2-1 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 17 Jan 2012 17:36:55 +0200 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31]) by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q0HFarfx032298; Tue, 17 Jan 2012 17:36:53 +0200 From: Tomi Ollila To: David Bremner , Subject: Re: [PATCH 1/2] uncrustify.cfg: initial support for notmuch coding style In-Reply-To: <1326197228-10356-2-git-send-email-david@tethera.net> References: <1324135695-15487-1-git-send-email-david@tethera.net> <1326197228-10356-1-git-send-email-david@tethera.net> <1326197228-10356-2-git-send-email-david@tethera.net> User-Agent: Notmuch/0.11+71~gefa5d6c (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.5.7110, 1.0.211, 0.0.0000 definitions=2012-01-17_06:2012-01-17, 2012-01-17, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=2 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=6.0.2-1012030000 definitions=main-1201170127 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jan 2012 15:36:59 -0000 On Tue, 10 Jan 2012 08:07:07 -0400, David Bremner wrote: > From: David Bremner > > Uncrustify is a free (as in GPL2+) tool that indents and beautifies > C/C++ code. It is similar to GNU indent in functionality although > probably more configurable (in fairness, indent has better > documentation). Uncrustify does not have the indent mis-feature of > needing to have every typedef'ed type defined in the > configuration (even standard types like size_t). > > This configuration starts with the linux-kernel style from the > uncrustify config, disables aggressive re-indenting of structs, > and fine tunes the handling 'else' and braces. > > In an ideal situation, running uncrustify on notmuch code would be > NOP; currently this is not true for all files because 1) the > configuration is not perfect 2) the coding style of notmuch is not > completely consistent; in particular the treatment of braces after > e.g. for (_) is not consistent. > --- > uncrustify.cfg | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Good stuff: while testing I did these changes: --- uncrustify.cfg0 2012-01-17 16:20:18.686489325 +0200 +++ uncrustify.cfg 2012-01-17 17:02:39.664512588 +0200 @@ -21 +20,0 @@ - @@ -60,0 +60,4 @@ +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove + @@ -62 +65 @@ -sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)" +sp_sizeof_paren = force # "sizeof (int)" vs "sizeof(int)" @@ -93 +96 @@ -align_right_cmt_span = 0 +align_right_cmt_span = 1 # 0 -> 1 -- just to fix some alignments The first three: +sp_before_ptr_star = force +sp_between_ptr_star = remove +sp_after_ptr_star = remove are important and pretty uncontroversial; fixes more than breaks (if anything) +sp_sizeof_paren = force # "sizeof (int)" vs "sizeof(int)" adds space after sizeof; do 'grep sizeof *.c' and you see this is prevalent in the code. I think this is the right way (especially) as sizeof is an operator... +align_right_cmt_span = 1 # 0 -> 1 -- just to fix some alignments This fixes, for example, comment alignment in g_mime_filter_headers_get_type() (in gmime-filter-headers.c). I also tested using this change: @@ -66 +69 @@ -sp_after_cast = force # "(int) a" vs "(int)a" +sp_after_cast = remove # "(int) a" vs "(int)a" But this changes basically all the casts in code not to have space after cast. I'd prefer this but it is not the prevalent style. Note that just running uncrustify --replace -c uncrustify.cfg notmuch-show.c does this: format_part_start_json (unused (GMimeObject * part), I.e. there is space after '*' and 'part'. This is probably the old known problem: uncrustify thinks unused is function which takes int parameter and there is multiplication to be done. If there is way to tell uncrustify that GMimeObject is type then this change would not take place. I run for f in *.c; do uncrustify --replace -c uncrustify.cfg $f; done in notmuch source root directory and the output is pretty good, in addition to the above problem there are these format_* structure initialization changes: Quoting Austin: "The good news is that that structure is on its way out." So, it would be good to get devel/uncrustify.cfg in place so developers can start playing with it... Tomi