Re: [HACKERS] Source code format votes

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>, PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] Source code format votes
Date: 1999-12-24 16:43:19
Message-ID: 199912241643.LAA12733@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk> writes:
> > I'd prefer 8-space tabs, mainly because I have to set emacs to 4-space
> > every time I enter a source file :-)
>
> Not if you know how to configure Emacs properly ;-)
>
> You need to put two things in your ~/.emacs. First you need a
> suitable mode-setting command, for which I use
>
> ; Cmd to set tab stops &etc for working with PostgreSQL code
> (defun pgsql-c-mode ()
> "Set PostgreSQL C indenting conventions in current buffer."
> (interactive)
> (c-mode) ; make sure major mode is right
> (setq tab-width 4) ; adjust to nonstandard tab width
> (c-set-style "bsd") ; indent conventions are BSD
> (c-set-offset 'case-label '+) ; except we indent case labels
> )
>
> Now the above can be invoked by hand, but Peter E. showed me the
> following trick for having it called automatically: add entries to your
> auto-mode-alist that match both the start and end of the pathname,
> so that pgsql-c-mode is automatically called for C files living in a
> particular region of your filesystem. Mine looks like
>
> (setq auto-mode-alist
> (cons '("\\`/home/postgres/.*\\.[chyl]\\'" . pgsql-c-mode)
> (cons '("\\`/home/tgl/pgsql/.*\\.[chyl]\\'" . pgsql-c-mode)
> auto-mode-alist)))
>

Developers FAQ updated with this macro.

> This has the effect of setting Pgsql mode automatically for any .c, .h,
> .y, or .l file underneath either /home/postgres/ or /home/tgl/pgsql/.
> Adjust to taste and never think about tabs again.
>
> BTW, Bruce suggested adding Local-variables settings to all the source
> files to push Emacs into making the right settings, but I much prefer
> doing it as above. Local-variables is an insecure feature if you ask
> me; I keep it disabled.

OK. I just know some developers added them on their own, so it
certainly is an issue for them.

Also, is there a way to add a dot-file in a directory to control default
formatting, but still allow the main .emacs to be read? .exrc is used
for vi and it controls formatting for all files edited in that
directory.

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleg Broytmann 1999-12-24 16:56:03 Re: [HACKERS] Source code format votes
Previous Message Bruce Momjian 1999-12-24 16:24:06 Re: [HACKERS] Source code format votes