Re: [HACKERS] Indent

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bernard Frankpitt <frankpit(at)pop(dot)dn(dot)net>
Cc: hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Indent
Date: 1999-11-11 02:03:21
Message-ID: 13150.942285801@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bernard Frankpitt <frankpit(at)pop(dot)dn(dot)net> writes:
> I have the following lines in my .emacs file
> ;;; Set tab-width in c-mode to 4 spaces
> (add-hook 'c-mode-hook
> (function (lambda () (set tab-width 4))))
> I think that there are some other small differences between emacs c-mode
> formatting and the indent formatting that PostgreSQL uses, but the
> 8-space tab is the only one that I have fixed.

I think I've mentioned this before, but I have the following function
for adapting emacs to the Postgres code-formatting conventions:

; Cmd to set tab stops &etc for working with PostgreSQL code
(defun pgsql-mode ()
"Set PostgreSQL C indenting conventions in current buffer."
(interactive)
(c-mode) ; ensure we're in electric-C mode
(setq tab-width 4)
(c-set-style "bsd")
(c-set-offset 'case-label '+)
)

Currently I invoke this command by hand when looking at a Postgres file.
I've been meaning to set up a load-time hook to invoke it automatically
upon visiting a .c or .h file within my ~postgres directory tree, but
haven't got round to that yet.

As far as I've noticed, the only significant shortcoming of this mode
definition is that it doesn't know that "foreach" should be treated as a
block-beginning keyword. This is also fixable with a little elisp
hacking, but that hasn't got to the top of the to-do list either. For
now I just remember to manually unindent the "{" right below "foreach",
and then it carries on correctly for the rest of the block.

ObFlameBait: Personally I think we should switch over to standard
8-column tabs, but Bruce is apparently still using some medieval editor
in which physical tab widths dictate logical indent levels :-(

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-11-11 02:26:07 Re: [HACKERS] Arrays broken on temp tables
Previous Message Frederick Cheeseborough 1999-11-11 00:15:09 Re: [HACKERS] Indent