1 ;; -*- mode: emacs-lisp -*-
3 ;; This file contains code to set up Emacs to edit PostgreSQL source
4 ;; code. Copy these snippets into your .emacs file or equivalent, or
5 ;; use load-file to load this file directly.
7 ;; Note also that there is a .dir-locals.el file at the top of the
8 ;; PostgreSQL source tree, which contains many of the settings shown
9 ;; here (but not all, mainly because not all settings are allowed as
10 ;; local variables). So for light editing, you might not need any
11 ;; additional Emacs configuration.
16 ;; Style that matches the formatting used by
17 ;; src/tools/pgindent/pgindent. Many extension projects also use this
19 (c-add-style "postgresql"
21 (c-auto-align-backslashes . nil)
23 (c-offsets-alist . ((case-label . +)
25 (statement-case-open . +)))
27 (indent-tabs-mode . t)
30 (add-hook 'c-mode-hook
31 (defun postgresql-c-mode-hook ()
32 (when (string-match "/postgres\\(ql\\)?/" buffer-file-name)
33 (c-set-style "postgresql")
34 ;; Don't override the style we just set with the style in
35 ;; `dir-locals-file'. Emacs 23.4.1 needs this; it is obsolete,
36 ;; albeit harmless, by Emacs 24.3.1.
37 (set (make-local-variable 'ignored-local-variables)
38 (append '(c-file-style) ignored-local-variables)))))
43 ;; Style that matches the formatting used by
44 ;; src/tools/pgindent/perltidyrc.
45 (defun pgsql-perl-style ()
46 "Perl style adjusted for PostgreSQL project"
48 (setq perl-brace-imaginary-offset 0)
49 (setq perl-brace-offset 0)
50 (setq perl-continued-brace-offset 4)
51 (setq perl-continued-statement-offset 4)
52 (setq perl-indent-level 4)
53 (setq perl-label-offset -2)
54 (setq indent-tabs-mode t)
57 (add-hook 'perl-mode-hook
58 (defun postgresql-perl-mode-hook ()
59 (when (string-match "/postgres\\(ql\\)?/" buffer-file-name)
63 ;;; documentation files
65 (add-hook 'sgml-mode-hook
66 (defun postgresql-sgml-mode-hook ()
67 (when (string-match "/postgres\\(ql\\)?/" buffer-file-name)
69 (setq indent-tabs-mode nil)
70 (setq sgml-basic-offset 1))))
75 ;; use GNU make mode instead of plain make mode
76 (add-to-list 'auto-mode-alist '("/postgres\\(ql\\)?/.*Makefile.*" . makefile-gmake-mode))
77 (add-to-list 'auto-mode-alist '("/postgres\\(ql\\)?/.*\\.mk\\'" . makefile-gmake-mode))