Re: Coding standards

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bryce Nesbitt <bryce2(at)obviously(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Coding standards
Date: 2008-04-18 15:27:11
Message-ID: 20080418152711.GC4850@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Bryce Nesbitt wrote:
> Alvaro Herrera wrote:
>> People [are] complaining here that we don't teach people here anyway, so
>> hopefully my comments were still useful :-)
>>
> Yes they are useful. As a new patcher, where should I look for coding
> standards? How about a little FAQ at the
> top of the CVS source tree?

The developer's FAQ is supposed to contain this kind of thing, but I
think it's rather thin on actual details. (Some time ago it was
proposed to create a "style guide", but people here thought it was a
waste of time and "it will not cover what's really important", so we're
stuck with repeating the advice over and over.)

> Though, darn it, I sure like //
>
> And my vi is set to:
> set sw=4
> set ts=4
> set expandtab
> Because my corporate projects require spaces not tabs.

I use this:

:if match(getcwd(), "/home/alvherre/Code/CVS/pgsql") == 0
: set cinoptions=(0
: set tabstop=4
: set shiftwidth=4
: let $CSCOPE_DB=substitute(getcwd(), "^\\(.*/pgsql/source/[^/]*\\)/.*", "\\1", "")
: let &tags=substitute(getcwd(), "^\\(.*/pgsql/source/[^/]*\\)/.*", "\\1", "") . "/tags"
: let &path=substitute(getcwd(), "^\\(.*/pgsql/source/[^/]*\\)/.*", "\\1", "") . "/src/include"
:endif

Of course, you need to adjust the paths. The cscope, tags and path
things let me quickly navigate through the files, but they don't affect
the editor behavior.

I never set expandtab so it's not a problem for me, but I guess you can
do ":set noexpandtab" in that block to reset it for Postgres use.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2008-04-18 15:36:53 Re: Lessons from commit fest
Previous Message Bryce Nesbitt 2008-04-18 14:42:13 Re: Proposed patch - psql wraps at window width

Browse pgsql-patches by date

  From Date Subject
Next Message Chris Browne 2008-04-18 15:46:07 Re: Coding standards
Previous Message Bryce Nesbitt 2008-04-18 14:42:13 Re: Proposed patch - psql wraps at window width