2006-09-07 02:10:46 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;;
|
|
|
|
;;; This file contains several examples of how to set up emacs and/or xemacs
|
|
|
|
;;; to edit PostgreSQL code.
|
|
|
|
;;;
|
|
|
|
;;; Whichever set you choose would go in your .emacs file or equivalent.
|
|
|
|
;;;
|
|
|
|
;;; You only need one of these.
|
|
|
|
;;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2012-08-31 03:40:31 +02:00
|
|
|
;;; Mode for C files to match src/tools/pgindent/pgindent formatting
|
|
|
|
|
2006-09-07 02:10:46 +02:00
|
|
|
;;; This set is known to work with old versions of emacs
|
|
|
|
|
|
|
|
(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
|
2011-04-22 23:39:45 +02:00
|
|
|
(setq fill-column 79) ; matches what pgindent does
|
2006-09-07 02:10:46 +02:00
|
|
|
(setq indent-tabs-mode t)) ; make sure we keep tabs when indenting
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
;;; Similar approach, known to work with xemacs
|
|
|
|
;;; Use of a named style makes it easy to use the style elsewhere
|
|
|
|
|
|
|
|
(c-add-style "pgsql"
|
|
|
|
'("bsd"
|
2011-04-22 23:39:45 +02:00
|
|
|
(fill-column . 79)
|
2006-09-07 02:10:46 +02:00
|
|
|
(indent-tabs-mode . t)
|
|
|
|
(c-basic-offset . 4)
|
|
|
|
(tab-width . 4)
|
|
|
|
(c-offsets-alist .
|
|
|
|
((case-label . +)))
|
|
|
|
)
|
|
|
|
nil ) ; t = set this mode, nil = don't
|
|
|
|
|
|
|
|
(defun pgsql-c-mode ()
|
|
|
|
(c-mode)
|
|
|
|
(c-set-style "pgsql")
|
|
|
|
)
|
|
|
|
|
|
|
|
(setq auto-mode-alist
|
|
|
|
(cons '("\\(postgres\\|pgsql\\).*\\.[chyl]\\'" . pgsql-c-mode)
|
|
|
|
auto-mode-alist))
|
|
|
|
(setq auto-mode-alist
|
|
|
|
(cons '("\\(postgres\\|pgsql\\).*\\.cc\\'" . pgsql-c-mode)
|
|
|
|
auto-mode-alist))
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
;;; Slightly different approach - use a hook instead of a mode
|
|
|
|
|
|
|
|
(add-hook 'c-mode-hook
|
|
|
|
(function
|
2010-11-23 21:27:50 +01:00
|
|
|
(lambda nil
|
2011-04-22 23:44:45 +02:00
|
|
|
(if (string-match "postgresql" buffer-file-name)
|
2006-09-07 02:10:46 +02:00
|
|
|
(progn
|
|
|
|
(c-set-style "bsd")
|
2010-11-23 21:27:50 +01:00
|
|
|
(setq c-basic-offset 4)
|
2006-09-07 02:10:46 +02:00
|
|
|
(setq tab-width 4)
|
|
|
|
(c-set-offset 'case-label '+)
|
2011-04-22 23:39:45 +02:00
|
|
|
(setq fill-column 79)
|
2006-09-07 02:10:46 +02:00
|
|
|
(setq indent-tabs-mode t)
|
|
|
|
)
|
|
|
|
))))
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2009-05-18 14:47:44 +02:00
|
|
|
|
2012-08-31 03:40:31 +02:00
|
|
|
;;; Mode for Perl files to match src/tools/pgindent/perltidyrc formatting
|
|
|
|
|
|
|
|
(defun pgsql-perl-style ()
|
|
|
|
"Perl style adjusted for PostgreSQL project"
|
|
|
|
(interactive)
|
|
|
|
(setq tab-width 4)
|
|
|
|
(setq perl-indent-level 4)
|
|
|
|
(setq perl-continued-statement-offset 4)
|
|
|
|
(setq perl-continued-brace-offset 4)
|
|
|
|
(setq perl-brace-offset 0)
|
|
|
|
(setq perl-brace-imaginary-offset 0)
|
|
|
|
(setq perl-label-offset -2))
|
|
|
|
|
|
|
|
(add-hook 'perl-mode-hook
|
|
|
|
(lambda ()
|
|
|
|
(if (string-match "postgresql" buffer-file-name)
|
|
|
|
(pgsql-perl-style))))
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2009-05-18 14:47:44 +02:00
|
|
|
;;; To work on the documentation, the following (or a variant, as above)
|
|
|
|
;;; can be helpful.
|
|
|
|
|
|
|
|
(defun pgsql-sgml-mode ()
|
|
|
|
"SGML mode adjusted for PostgreSQL project"
|
|
|
|
(interactive)
|
|
|
|
(sgml-mode)
|
|
|
|
|
2009-07-21 21:07:24 +02:00
|
|
|
(setq indent-tabs-mode nil)
|
2009-05-18 14:47:44 +02:00
|
|
|
(setq sgml-basic-offset 1)
|
|
|
|
)
|
|
|
|
|
|
|
|
(setq auto-mode-alist
|
2009-05-21 01:51:24 +02:00
|
|
|
(cons '("\\(postgres\\|pgsql\\).*\\.sgml\\'" . pgsql-sgml-mode)
|
2009-05-18 14:47:44 +02:00
|
|
|
auto-mode-alist))
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|