Skip to content

Commit 83fd594

Browse files
author
Thomas G. Lockhart
committed
Add short chapter in developer's guide on formatting source code.
1 parent 6454ae3 commit 83fd594

File tree

3 files changed

+86
-3
lines changed

3 files changed

+86
-3
lines changed

doc/src/sgml/postgres.sgml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<!entity page SYSTEM "page.sgml">
9292
<!entity protocol SYSTEM "protocol.sgml">
9393
<!entity signals SYSTEM "signals.sgml">
94+
<!entity sources SYSTEM "sources.sgml">
9495
]>
9596
<!-- entity manpages SYSTEM "man/manpages.sgml" subdoc -->
9697
<Book Id="postgres">
@@ -268,6 +269,7 @@ Your name here...
268269
suggestions for future development.
269270
</Para>
270271
</PartIntro>
272+
&sources;
271273
&arch-dev;
272274
&options;
273275
&geqo;

doc/src/sgml/programmer.sgml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/programmer.sgml,v 1.20 1999/12/06 16:37:11 thomas Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/programmer.sgml,v 1.21 2000/02/02 16:25:04 thomas Exp $
33

44
Postgres Programmer's Guide.
55

66
$Log: programmer.sgml,v $
7+
Revision 1.21 2000/02/02 16:25:04 thomas
8+
Add short chapter in developer's guide on formatting source code.
9+
710
Revision 1.20 1999/12/06 16:37:11 thomas
811
Remove references to PostgreSQL as "public-domain" since that has a
912
specific meaning wrt copyright (or lack thereof).
@@ -81,6 +84,7 @@ Make new file current.sgml to hold release info for the current release.
8184
<!entity page SYSTEM "page.sgml">
8285
<!entity protocol SYSTEM "protocol.sgml">
8386
<!entity signals SYSTEM "signals.sgml">
87+
<!entity sources SYSTEM "sources.sgml">
8488
]>
8589

8690
<book id="programmer">
@@ -187,6 +191,7 @@ Disable it until we put in some info.
187191

188192
<!-- development -->
189193

194+
&sources;
190195
&arch-dev;
191196
&options;
192197
&geqo;
@@ -214,7 +219,7 @@ Disable it until we put in some info.
214219

215220
<!-- Keep this comment at the end of the file
216221
Local variables:
217-
mode: sgml
222+
mode:sgml
218223
sgml-omittag:nil
219224
sgml-shorttag:t
220225
sgml-minimize-attributes:nil
@@ -224,7 +229,7 @@ sgml-indent-data:t
224229
sgml-parent-document:nil
225230
sgml-default-dtd-file:"./reference.ced"
226231
sgml-exposed-tags:nil
227-
sgml-local-catalogs:"/usr/lib/sgml/CATALOG"
232+
sgml-local-catalogs:("/usr/lib/sgml/CATALOG")
228233
sgml-local-ecat-files:nil
229234
End:
230235
-->

doc/src/sgml/sources.sgml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<chapter>
2+
<title>Postgres Source Code</title>
3+
4+
<sect1>
5+
<title>Formatting</title>
6+
7+
<para>
8+
Source code formatting uses a 4 column tab spacing, currently with
9+
tabs preserved (i.e. tabs are not expanded to spaces).
10+
</para>
11+
12+
<para>
13+
For emacs, add the following (or something similar)
14+
to your <filename>~/.emacs</filename>
15+
initialization file:
16+
17+
<programlisting>
18+
;; check for files with a path containing "postgres" or "pgsql"
19+
(setq auto-mode-alist (cons '("\\(postgres\\|pgsql\\).*\\.[ch]\\'" . pgsql-c-mode) auto-mode-alist))
20+
(setq auto-mode-alist (cons '("\\(postgres\\|pgsql\\).*\\.cc\\'" . pgsql-c-mode) auto-mode-alist))
21+
22+
(defun pgsql-c-mode ()
23+
;; sets up formatting for Postgres C code
24+
(interactive)
25+
(c-mode)
26+
(setq-default tab-width 4)
27+
(c-set-style "bsd") ; set c-basic-offset to 4, plus other stuff
28+
(c-set-offset 'case-label '+) ; tweak case indent to match PG custom
29+
(setq indent-tabs-mode t)) ; make sure we keep tabs when indenting
30+
</programlisting>
31+
</para>
32+
33+
<para>
34+
For <application>vi</application>, your
35+
<filename>~/.vimrc</filename> or equivalent file should contain
36+
the following:
37+
38+
<programlisting>
39+
set tabstop=4
40+
</programlisting>
41+
42+
or equivalently from within vi, try
43+
44+
<programlisting>
45+
:set ts=4
46+
</programlisting>
47+
</para>
48+
49+
<para>
50+
The text browsing tools <application>more</application> and
51+
<application>less</application> can be invoked as
52+
53+
<programlisting>
54+
more -x4
55+
less -x4
56+
</programlisting>
57+
</para>
58+
</sect1>
59+
</chapter>
60+
61+
<!-- Keep this comment at the end of the file
62+
Local variables:
63+
mode:sgml
64+
sgml-omittag:nil
65+
sgml-shorttag:t
66+
sgml-minimize-attributes:nil
67+
sgml-always-quote-attributes:t
68+
sgml-indent-step:1
69+
sgml-indent-data:t
70+
sgml-parent-document:nil
71+
sgml-default-dtd-file:"./reference.ced"
72+
sgml-exposed-tags:nil
73+
sgml-local-catalogs:("/usr/lib/sgml/CATALOG")
74+
sgml-local-ecat-files:nil
75+
End:
76+
-->

0 commit comments

Comments
 (0)