Chapter 1. PostgreSQL 源代码

1.1. 格式

代码格式使用每个制表符(tab)4列的空白, 目前是保留制表符状态(也就是说制表符不被展开为空白)。

对于使用 Emacs 的人,把下面行(或者类似的东西)增加到你的 ~/.emacs 初始化文件里面去:

;; 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

对于 vi,你的 ~/.vimrc 或者相当的文件应该包含下面的东西:

set tabstop=4

或者在 vi 里面键入

:set ts=4

文本浏览工具 moreless 可以用下面命令调用

more -x4
less -x4