Re: [HACKERS] Source code format votes
От | Tom Lane |
---|---|
Тема | Re: [HACKERS] Source code format votes |
Дата | |
Msg-id | 12151.946047996@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | RE: [HACKERS] Source code format votes (Peter Mount <petermount@it.maidstone.gov.uk>) |
Ответы |
Re: [HACKERS] Source code format votes
Re: [HACKERS] Source code format votes |
Список | pgsql-hackers |
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
В списке pgsql-hackers по дате отправления: