Hi, Peter Eisentraut <pete...@gmx.net> writes: > 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.
Thanks for doing that! > 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. I've tested that on a new git clone and with the `emacs -q` command so as not to load any of my local setup. While the indentation seemed ok, the placement of the comments seems way off: Compare what you see using those commands: emacs -q src/backend/commands/extension.c emacs -q -l ../emacs.samples src/backend/commands/extension.c (When using macosx, you might have to replace the 'emacs' binary location with /Applications/Emacs.app/Contents/MacOS/Emacs). I did also test on doc/src/sgml/extend.sgml and some Makefile, only with using the emacs.samples file content though. > 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. A couple of notes about your emacs.sample file: - Name the lambda used in the hook for easier removing / reference - A fresh git clone will create a directory named postgres, so I did change your /postgresql/ regex to /postgres/ in my attached version > I think together this setup would be significantly simpler and more > practical. Agreed. -- Dimitri Fontaine http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
;; -*- 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 (defun postgresql-c-mode-hook () (when (string-match "/postgres/" buffer-file-name) (c-set-style "postgresql")))) ;;; documentation files (add-hook 'sgml-mode-hook (defun postgresql-sgml-mode-hook () (when (string-match "/postgres/" 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 '("/postgres/.*Makefile.*" . makefile-gmake-mode)) (add-to-list 'auto-mode-alist '("/postgres/.*\\.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