[PATCH] STYLE: Initial draft of coding style document
authorDavid Bremner <david@tethera.net>
Fri, 27 Jan 2012 23:46:58 +0000 (19:46 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:25 +0000 (09:43 -0800)
ba/43bd83f9c3f1543df86f377f196148a9ad7800 [new file with mode: 0644]

diff --git a/ba/43bd83f9c3f1543df86f377f196148a9ad7800 b/ba/43bd83f9c3f1543df86f377f196148a9ad7800
new file mode 100644 (file)
index 0000000..b118f3c
--- /dev/null
@@ -0,0 +1,155 @@
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id C284F431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 27 Jan 2012 15:47:19 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id FgTAohoPEYM0 for <notmuch@notmuchmail.org>;\r
+       Fri, 27 Jan 2012 15:47:19 -0800 (PST)\r
+Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 1369B431FAE\r
+       for <notmuch@notmuchmail.org>; Fri, 27 Jan 2012 15:47:18 -0800 (PST)\r
+Received: from zancas.localnet\r
+       (fctnnbsc36w-156034071197.pppoe-dynamic.High-Speed.nb.bellaliant.net\r
+       [156.34.71.197]) (authenticated bits=0)\r
+       by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id q0RNlClT020517\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
+       Fri, 27 Jan 2012 19:47:14 -0400\r
+Received: from bremner by zancas.localnet with local (Exim 4.77)\r
+       (envelope-from <bremner@tethera.net>)\r
+       id 1RqvVg-0000IP-In; Fri, 27 Jan 2012 19:47:12 -0400\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] STYLE: Initial draft of coding style document\r
+Date: Fri, 27 Jan 2012 19:46:58 -0400\r
+Message-Id: <1327708018-1107-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.8.3\r
+Cc: David Bremner <bremner@debian.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 27 Jan 2012 23:47:19 -0000\r
+\r
+From: David Bremner <bremner@debian.org>\r
+\r
+This was edited by (at least) Austin, Tomi, and myself.\r
+---\r
+ devel/STYLE |   87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 files changed, 87 insertions(+), 0 deletions(-)\r
+ create mode 100644 devel/STYLE\r
+\r
+diff --git a/devel/STYLE b/devel/STYLE\r
+new file mode 100644\r
+index 0000000..7ef3209\r
+--- /dev/null\r
++++ b/devel/STYLE\r
+@@ -0,0 +1,87 @@\r
++C/C++ coding style\r
++==================\r
++\r
++Tools\r
++-----\r
++\r
++There is a file uncrustify.cfg in this directory that can be used to\r
++approximate the prevailing code style. You can run it with e.g.\r
++\r
++   uncrustify --replace -c devel/uncrustify.cfg foo.c\r
++\r
++You still have to use your judgement about accepting or rejecting the\r
++changes uncrustify makes. With a nice git frontend, you can add the\r
++lines you agree with and reject the rest.\r
++\r
++For Emacs users, the file .dir-locals.el in the top level source\r
++directory will configure c-mode to automatically meet most of the\r
++basic layout rules.  I\r
++\r
++Indentation, Whitespace, and Layout\r
++-----------------------------------\r
++\r
++The following nonsense code demonstrates many aspects of the style:\r
++\r
++static some_type\r
++function (param_type param, param_type param)\r
++{\r
++   int i;\r
++\r
++   for (i = 0; i < 10; i++) {\r
++       int j;\r
++\r
++       j = i + 10;\r
++\r
++       some_other_func (j, i);\r
++   }\r
++}\r
++\r
++* Indent is 4 spaces with mixed tabs/spaces and a tab width of 8.\r
++  Tabs should be only at the beginning of the line.\r
++\r
++* Use copious whitespace.  In particular\r
++   - there is a space between the function name and the open paren in a call.\r
++   - likewise, there is a space following keywords such as if and while\r
++   - every binary operator should have space on either side.\r
++\r
++* No trailing whitespace. Please enable the standard pre-commit hook\r
++  in git (or an equivalent hook).\r
++\r
++* The name in a function prototype should start at the beginning of a line.\r
++\r
++* Opening braces "cuddle" (they are on the same line as the\r
++  if/for/while test) and are preceded by a space. The opening brace of\r
++  functions is the exception, and starts on a new line.\r
++\r
++* Comments are always C-style /* */ block comments.  They should start\r
++  with a capital letter and generally be written in complete\r
++  sentences.  Public library functions are documented immediately\r
++  before their prototype in lib/notmuch.h.  Internal functions are\r
++  typically documented immediately before their definition.\r
++\r
++* Code lines should be less than 80 columns and comments should be\r
++  wrapped at 70 columns.\r
++\r
++Naming\r
++------\r
++\r
++* Use lowercase_with_underscores for function, variable, and type\r
++  names.\r
++\r
++* All structs should be typedef'd to a name ending with _t.  If the\r
++  struct has a tag, it should be the same as the typedef name, minus\r
++  the trailing _t.\r
++\r
++libnotmuch conventions\r
++----------------------------------\r
++\r
++* Functions starting with notmuch_ in lib/notmuch.h are public and are\r
++  automatically exported from the shared library.  Private library\r
++  functions should generally either be static or, if they are shared\r
++  between compilation units, start with _notmuch.\r
++\r
++* Functions in libnotmuch must not access user configuration files\r
++  (i.e. .notmuch-config)\r
++\r
++* Code which needs to be accessed from both the CLI and from\r
++  libnotmuch should be factored out into libutil (under util/).\r
+-- \r
+1.7.8.3\r
+\r