| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk> |
| Cc: | "'Bruce Momjian'" <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org> |
| Subject: | Re: [HACKERS] Source code format votes |
| Date: | 1999-12-24 15:06:36 |
| Message-ID: | 12151.946047996@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | 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)))
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.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | DWalker | 1999-12-24 15:27:59 | database replication |
| Previous Message | Mateus Cordeiro Inssa | 1999-12-24 11:55:15 | Error "vacuum pg_proc" |