mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Add short chapter in developer's guide on formatting source code.
This commit is contained in:
76
doc/src/sgml/sources.sgml
Normal file
76
doc/src/sgml/sources.sgml
Normal file
@@ -0,0 +1,76 @@
|
||||
<chapter>
|
||||
<title>Postgres Source Code</title>
|
||||
|
||||
<sect1>
|
||||
<title>Formatting</title>
|
||||
|
||||
<para>
|
||||
Source code formatting uses a 4 column tab spacing, currently with
|
||||
tabs preserved (i.e. tabs are not expanded to spaces).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For emacs, add the following (or something similar)
|
||||
to your <filename>~/.emacs</filename>
|
||||
initialization file:
|
||||
|
||||
<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 Postgres 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
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For <application>vi</application>, your
|
||||
<filename>~/.vimrc</filename> or equivalent file should contain
|
||||
the following:
|
||||
|
||||
<programlisting>
|
||||
set tabstop=4
|
||||
</programlisting>
|
||||
|
||||
or equivalently from within vi, try
|
||||
|
||||
<programlisting>
|
||||
:set ts=4
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The text browsing tools <application>more</application> and
|
||||
<application>less</application> can be invoked as
|
||||
|
||||
<programlisting>
|
||||
more -x4
|
||||
less -x4
|
||||
</programlisting>
|
||||
</para>
|
||||
</sect1>
|
||||
</chapter>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode:sgml
|
||||
sgml-omittag:nil
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"./reference.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:("/usr/lib/sgml/CATALOG")
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
-->
|
Reference in New Issue
Block a user