Set WeberTrivia.com to be my default homepage.   Suggest a Question                                               

Suggest A Question : :  Frequently Asked Questions : :  Search : :  Relevant Manuals : : 
PHP Questions : :  Linux Questions : :  MySQL Questions : : 
home  [ Login ] 

Chapter 45. PostgreSQL Coding Conventions

45.1. Formatting

Source code formatting uses 4 column tab spacing, with tabs preserved (i.e. tabs are not expanded to spaces). Each logical indentation level is one additional tab stop. Layout rules (brace positioning, etc) follow BSD conventions.

While submitted patches do not absolutely have to follow these formatting rules, it's a good idea to do so. Your code will get run through pgindent, so there's no point in making it look nice under some other set of formatting conventions.

For Emacs, add the following (or something similar) to your ~/.emacs initialization file:

;; check for files with a path containing "postgres" or "pgsql" (setq auto-mode-alist   (cons '("\\(postgres\\|pgsql\\).*\\.[ch]\\'" . pgsql-c-mode)         auto-mode-alist)) (setq auto-mode-alist   (cons '("\\(postgres\\|pgsql\\).*\\.cc\\'" . pgsql-c-mode)         auto-mode-alist))  (defun pgsql-c-mode ()   ;; sets up formatting for PostgreSQL C code   (interactive)   (c-mode)   (setq-default tab-width 4)   (c-set-style "bsd")             ; set c-basic-offset to 4, plus other stuff   (c-set-offset 'case-label '+)   ; tweak case indent to match PG custom   (setq indent-tabs-mode t))      ; make sure we keep tabs when indenting

For vi, your ~/.vimrc or equivalent file should contain the following:

set tabstop=4

or equivalently from within vi, try

:set ts=4

The text browsing tools more and less can be invoked as

more -x4 less -x4

to make them show tabs appropriately.

Who's Online
Guest Users: 5
Google
Web
WeberTrivia
WeberDev
WeberForums
 Free Sample Chapters  Free Sample Chapters
  Deliver First Class Web Sites: 101 Essential Checklists
Want to learn how to make your web sites usable and accessible? Want to ensure that your sites meet current best practice, without spending hours trawling through incomprehensible specifications and recommendations from dozens of different books, research papers, and web sites? Want to make sure that the sites you build are "right the first time," requiring no costly redevelopments?

More Sample Chapters

PHP General