2013-08-14 02:08:44 +02:00
|
|
|
;; -*- mode: emacs-lisp -*-
|
|
|
|
|
|
|
|
;; This file contains code to set up Emacs to edit PostgreSQL source
|
|
|
|
;; code. Copy these snippets into your .emacs file or equivalent, or
|
|
|
|
;; use load-file to load this file directly.
|
|
|
|
;;
|
|
|
|
;; Note also that there is a .dir-locals.el file at the top of the
|
|
|
|
;; PostgreSQL source tree, which contains many of the settings shown
|
|
|
|
;; here (but not all, mainly because not all settings are allowed as
|
|
|
|
;; local variables). So for light editing, you might not need any
|
|
|
|
;; additional Emacs configuration.
|
|
|
|
|
|
|
|
|
|
|
|
;;; C files
|
|
|
|
|
|
|
|
;; Style that matches the formatting used by
|
|
|
|
;; src/tools/pgindent/pgindent. Many extension projects also use this
|
|
|
|
;; style.
|
|
|
|
(c-add-style "postgresql"
|
|
|
|
'("bsd"
|
|
|
|
(c-auto-align-backslashes . nil)
|
|
|
|
(c-basic-offset . 4)
|
|
|
|
(c-offsets-alist . ((case-label . +)
|
|
|
|
(label . -)
|
|
|
|
(statement-case-open . +)))
|
|
|
|
(fill-column . 78)
|
|
|
|
(indent-tabs-mode . t)
|
|
|
|
(tab-width . 4)))
|
2006-09-07 02:10:46 +02:00
|
|
|
|
|
|
|
(add-hook 'c-mode-hook
|
2013-08-14 02:08:44 +02:00
|
|
|
(defun postgresql-c-mode-hook ()
|
|
|
|
(when (string-match "/postgres\\(ql\\)?/" buffer-file-name)
|
|
|
|
(c-set-style "postgresql"))))
|
2006-09-07 02:10:46 +02:00
|
|
|
|
2009-05-18 14:47:44 +02:00
|
|
|
|
2013-08-14 02:08:44 +02:00
|
|
|
;;; Perl files
|
2012-08-31 03:40:31 +02:00
|
|
|
|
2013-08-14 02:08:44 +02:00
|
|
|
;; Style that matches the formatting used by
|
|
|
|
;; src/tools/pgindent/perltidyrc.
|
2012-08-31 03:40:31 +02:00
|
|
|
(defun pgsql-perl-style ()
|
|
|
|
"Perl style adjusted for PostgreSQL project"
|
|
|
|
(interactive)
|
|
|
|
(setq perl-brace-imaginary-offset 0)
|
2013-08-14 02:08:44 +02:00
|
|
|
(setq perl-brace-offset 0)
|
|
|
|
(setq perl-continued-brace-offset 4)
|
|
|
|
(setq perl-continued-statement-offset 4)
|
|
|
|
(setq perl-indent-level 4)
|
|
|
|
(setq perl-label-offset -2)
|
|
|
|
(setq tab-width 4))
|
2012-08-31 03:40:31 +02:00
|
|
|
|
|
|
|
(add-hook 'perl-mode-hook
|
2013-08-14 02:08:44 +02:00
|
|
|
(defun postgresql-perl-mode-hook ()
|
|
|
|
(when (string-match "/postgres\\(ql\\)?/" buffer-file-name)
|
|
|
|
(pgsql-perl-style))))
|
2012-08-31 03:40:31 +02:00
|
|
|
|
|
|
|
|
2013-08-14 02:08:44 +02:00
|
|
|
;;; documentation files
|
2009-05-18 14:47:44 +02:00
|
|
|
|
2013-08-14 02:08:44 +02:00
|
|
|
(add-hook 'sgml-mode-hook
|
|
|
|
(defun postgresql-sgml-mode-hook ()
|
|
|
|
(when (string-match "/postgres\\(ql\\)?/" buffer-file-name)
|
|
|
|
(setq fill-column 78)
|
|
|
|
(setq indent-tabs-mode nil)
|
|
|
|
(setq sgml-basic-offset 1))))
|
2009-05-18 14:47:44 +02:00
|
|
|
|
|
|
|
|
2013-08-14 02:08:44 +02:00
|
|
|
;;; Makefiles
|
2009-05-18 14:47:44 +02:00
|
|
|
|
2013-08-14 02:08:44 +02:00
|
|
|
;; use GNU make mode instead of plain make mode
|
|
|
|
(add-to-list 'auto-mode-alist '("/postgres\\(ql\\)?/.*Makefile.*" . makefile-gmake-mode))
|
|
|
|
(add-to-list 'auto-mode-alist '("/postgres\\(ql\\)?/.*\\.mk\\'" . makefile-gmake-mode))
|