I think the suggested emacs configuration snippets in src/tools/editors/emacs.samples no longer represent current best practices. I have come up with some newer things that I'd like to propose for review.
First, I propose adding a .dir-locals.el file to the top-level directory with basic emacs settings. These get applied automatically. This especially covers the particular tab and indentation settings that PostgreSQL uses. With this, casual developers will not need to modify any of their emacs settings. (In the attachment, .dir-locals.el is called _dir-locals.el so that it doesn't get lost. To clarify, it goes into the same directory that contains configure.in.) With that, emacs.samples can be shrunk significantly. The only real reason to keep is that that c-offsets-alist and (more dubiously) sgml-basic-offset cannot be set from .dir-locals.el because they are not "safe". I have also removed many of the redundant examples and settled on a hook-based solution. I think together this setup would be significantly simpler and more practical.
((c-mode . ((c-basic-offset . 4) (fill-column . 79) (indent-tabs-mode . t) (tab-width . 4))) (dsssl-mode . ((indent-tabs-mode . nil))) (nxml-mode . ((indent-tabs-mode . nil))) (perl-mode . ((perl-indent-level . 4) (perl-continued-statement-offset . 4) (perl-continued-brace-offset . 4) (perl-brace-offset . 0) (perl-brace-imaginary-offset . 0) (perl-label-offset . -2) (tab-width . 4))) (sgml-mode . ((fill-column . 79) (indent-tabs-mode . nil))))
;; -*- 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. 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-basic-offset . 4) (c-offsets-alist . ((case-label . +))) (fill-column . 79) (indent-tabs-mode . t) (tab-width . 4))) (add-hook 'c-mode-hook (lambda () (when (string-match "/postgresql/" buffer-file-name) (c-set-style "postgresql")))) ;;; documentation files (add-hook 'sgml-mode-hook (lambda () (when (string-match "/postgresql/" buffer-file-name) (setq fill-column 79) (setq indent-tabs-mode nil) (setq sgml-basic-offset 1)))) ;;; Makefiles ;; use GNU make mode instead of plain make mode (add-to-list 'auto-mode-alist '("/postgresql/.*Makefile.*" . makefile-gmake-mode)) (add-to-list 'auto-mode-alist '("/postgresql/.*\\.mk\\'" . makefile-gmake-mode))
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers