Обсуждение: RE: [HACKERS] Source code format votes
I'd prefer 8-space tabs, mainly because I have to set emacs to 4-space every time I enter a source file :-) Peter -- Peter Mount Enterprise Support Maidstone Borough Council Any views stated are my own, and not those of Maidstone Borough Council. -----Original Message----- From: Bruce Momjian [mailto:pgman@candle.pha.pa.us] Sent: Thursday, December 23, 1999 9:41 PM To: PostgreSQL-development Subject: [HACKERS] Source code format votes OK I have:8-space tabs: Tom Lane, Peter, Vince, Massimo4-space tabs: Bruce, Andreasopen bracket on if () line -yes: Massimo, Peterno: Bruce More votes? -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 ************
Peter Mount <petermount@it.maidstone.gov.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
Current vote totals:
(7) 8-space tabs: Tom Lane, Peter E., Massimo, Jan, Hiroshi, Peter M., Michael
(5) 4-space tabs: Bruce, Andreas, Vince, Vadim, D'Arcy
open bracket on if () line -
(5) yes: Massimo, Peter, Vince, Tom Lane, Peter M.
(6) no: Bruce, Vadim, D'Arcy, Jan, Hiroshi, Michael M.
-- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610)
853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill,
Pennsylvania19026
> Peter Mount <petermount@it.maidstone.gov.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@candle.pha.pa.us | (610)
853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill,
Pennsylvania19026
D'Arcy, your signature fits here very well, I think... On Fri, 24 Dec 1999, Bruce Momjian wrote: > Current vote totals: > > (7) 8-space tabs: Tom Lane, Peter E., Massimo, Jan, Hiroshi, Peter M., > Michael > (5) 4-space tabs: Bruce, Andreas, Vince, Vadim, D'Arcy > > > open bracket on if () line - > (5) yes: Massimo, Peter, Vince, Tom Lane, Peter M. > (6) no: Bruce, Vadim, D'Arcy, Jan, Hiroshi, Michael M. Oleg. ---- Oleg Broytmann http://members.xoom.com/phd2/ phd2@earthling.net Programmers don't die, they justGOSUB without RETURN.
Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> 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.
Yes, I notice Thomas has all of the .sgml files set up with
Local-variables settings. I think that adding a pgsql-sgml-mode
along the same lines as I just illustrated would be a much better
way of handling it.
> 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?
I don't think so. If there were, it'd have the same kinds of security
risks as Local-variables has (visit someone else's file, auto-execute
someone else's code ... not cool).
regards, tom lane
On 24-Dec-99 Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.us> writes: >>> 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. > > Yes, I notice Thomas has all of the .sgml files set up with > Local-variables settings. I think that adding a pgsql-sgml-mode > along the same lines as I just illustrated would be a much better > way of handling it. Umm.. That might've been me. I reformatted all the sgml files last year and added the missing close tags. I seem to recall having some problems with saving files and my preferences - too new to xemacs at the time. Vince. -- ========================================================================== Vince Vielhaber -- KA8CSH email: vev@michvhf.com http://www.pop4.net 128K ISDN: $24.95/mo or less - 56K Dialup: $17.95/moor less at Pop4 Online Campground Directory http://www.camping-usa.com Online Giftshop Superstore http://www.cloudninegifts.com ==========================================================================
I'm indifferent on the tabs, but like seeing the open bracket on the if
and else lines ...
if {
} else {
}
Marc G. Fournier scrappy@hub.org
Systems Administrator @ hub.org
scrappy@{postgresql|isc}.org ICQ#7615664
On Fri, 24 Dec 1999, Bruce Momjian wrote:
> Current vote totals:
>
> (7) 8-space tabs: Tom Lane, Peter E., Massimo, Jan, Hiroshi, Peter M.,
> Michael
> (5) 4-space tabs: Bruce, Andreas, Vince, Vadim, D'Arcy
>
>
> open bracket on if () line -
> (5) yes: Massimo, Peter, Vince, Tom Lane, Peter M.
> (6) no: Bruce, Vadim, D'Arcy, Jan, Hiroshi, Michael M.
>
>
> --
> Bruce Momjian | http://www.op.net/~candle
> maillist@candle.pha.pa.us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
>
> ************
>
>
> >> OK. I just know some developers added them on their own, so it
> >> certainly is an issue for them.
> > Yes, I notice Thomas has all of the .sgml files set up with
> > Local-variables settings. I think that adding a pgsql-sgml-mode
> > along the same lines as I just illustrated would be a much better
> > way of handling it.
Yeah, probably. So far it hasn't been a problem for the large number
of sgml doc writers (note heavy sarcasm ;)
> Umm.. That might've been me. I reformatted all the sgml files last
> year and added the missing close tags. I seem to recall having some
> problems with saving files and my preferences - too new to xemacs at
> the time.
Nope, they've been there from the beginning...
- Thomas
--
Thomas Lockhart lockhart@alumni.caltech.edu
South Pasadena, California