File: source.html

package info (click to toggle)
pgadmin3 1.4.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 29,796 kB
  • ctags: 10,758
  • sloc: cpp: 55,356; sh: 6,164; ansic: 1,520; makefile: 576; sql: 482; xml: 100; perl: 18
file content (85 lines) | stat: -rw-r--r-- 3,598 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter44.PostgreSQL Coding Conventions</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="internals.html" title="PartVII.Internals">
<link rel="prev" href="protocol-changes.html" title="43.6.Summary of Changes since Protocol 2.0">
<link rel="next" href="error-message-reporting.html" title="44.2.Reporting Errors Within the Server">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter" lang="en" id="source">
<div class="titlepage"><div><div><h2 class="title">
<a name="source"></a>Chapter44.PostgreSQL Coding Conventions</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="sect1"><a href="source.html#source-format">44.1. Formatting</a></span></dt>
<dt><span class="sect1"><a href="error-message-reporting.html">44.2. Reporting Errors Within the Server</a></span></dt>
<dt><span class="sect1"><a href="error-style-guide.html">44.3. Error Message Style Guide</a></span></dt>
</dl>
</div>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="source-format"></a>44.1.Formatting</h2></div></div></div>
<p>    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.
   </p>
<p>    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
    <span class="application">pgindent</span>, so there's no point in making it look nice
    under some other set of formatting conventions.
   </p>
<p>    For <span class="productname">Emacs</span>, add the following (or
    something similar) to your <code class="filename">~/.emacs</code> 
    initialization file:

</p>
<pre class="programlisting">;; 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</pre>
<p>
   </p>
<p>    For <span class="application">vi</span>, your
    <code class="filename">~/.vimrc</code> or equivalent file should contain
    the following:

</p>
<pre class="programlisting">set tabstop=4</pre>
<p>

    or equivalently from within <span class="application">vi</span>, try

</p>
<pre class="programlisting">:set ts=4</pre>
<p>
   </p>
<p>    The text browsing tools <span class="application">more</span> and
    <span class="application">less</span> can be invoked as
</p>
<pre class="programlisting">more -x4
less -x4</pre>
<p>
    to make them show tabs appropriately.
   </p>
</div>
</div></body>
</html>