summaryrefslogtreecommitdiffstats
path: root/src/tools/editors
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:46:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:46:48 +0000
commit311bcfc6b3acdd6fd152798c7f287ddf74fa2a98 (patch)
tree0ec307299b1dada3701e42f4ca6eda57d708261e /src/tools/editors
parentInitial commit. (diff)
downloadpostgresql-15-311bcfc6b3acdd6fd152798c7f287ddf74fa2a98.tar.xz
postgresql-15-311bcfc6b3acdd6fd152798c7f287ddf74fa2a98.zip
Adding upstream version 15.4.upstream/15.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/editors')
-rw-r--r--src/tools/editors/emacs.samples91
-rw-r--r--src/tools/editors/vim.samples17
2 files changed, 108 insertions, 0 deletions
diff --git a/src/tools/editors/emacs.samples b/src/tools/editors/emacs.samples
new file mode 100644
index 0000000..529c98a
--- /dev/null
+++ b/src/tools/editors/emacs.samples
@@ -0,0 +1,91 @@
+;; -*- 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)))
+
+(add-hook 'c-mode-hook
+ (defun postgresql-c-mode-hook ()
+ (when (string-match "/postgres\\(ql\\)?/" buffer-file-name)
+ (c-set-style "postgresql")
+ ;; Don't override the style we just set with the style in
+ ;; `dir-locals-file'. Emacs 23.4.1 needs this; it is obsolete,
+ ;; albeit harmless, by Emacs 24.3.1.
+ (set (make-local-variable 'ignored-local-variables)
+ (append '(c-file-style) ignored-local-variables)))))
+
+
+;;; Perl files
+
+;; Style that matches the formatting used by
+;; src/tools/pgindent/perltidyrc.
+(defun pgsql-perl-style ()
+ "Perl style adjusted for PostgreSQL project"
+ (interactive)
+ (setq perl-brace-imaginary-offset 0)
+ (setq perl-brace-offset 0)
+ (setq perl-continued-statement-offset 2)
+ (setq perl-continued-brace-offset (- perl-continued-statement-offset))
+ (setq perl-indent-level 4)
+ (setq perl-label-offset -2)
+ ;; Next two aren't marked safe-local-variable, so .dir-locals.el omits them.
+ (setq perl-indent-continued-arguments 4)
+ (setq perl-indent-parens-as-block t)
+ (setq indent-tabs-mode t)
+ (setq tab-width 4))
+
+(add-hook 'perl-mode-hook
+ (defun postgresql-perl-mode-hook ()
+ (when (string-match "/postgres\\(ql\\)?/" buffer-file-name)
+ (pgsql-perl-style))))
+
+
+;;; documentation files
+
+;; *.sgml files are actually XML
+(add-to-list 'auto-mode-alist '("/postgres\\(ql\\)?/.*\\.sgml\\'" . nxml-mode))
+
+(add-hook 'nxml-mode-hook
+ (defun postgresql-xml-mode-hook ()
+ (when (string-match "/postgres\\(ql\\)?/" buffer-file-name)
+ (setq fill-column 78)
+ (setq indent-tabs-mode nil))))
+
+;; The *.xsl files use 2-space indent, which is consistent with
+;; docbook-xsl sources and also the nxml-mode default. But the *.sgml
+;; files use 1-space indent, mostly for historical reasons at this
+;; point.
+(add-hook 'nxml-mode-hook
+ (defun postgresql-xml-src-mode-hook ()
+ (when (string-match "/postgres\\(ql\\)?/.*\\.sgml\\'" buffer-file-name)
+ (setq nxml-child-indent 1))))
+
+
+;;; Makefiles
+
+;; 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))
diff --git a/src/tools/editors/vim.samples b/src/tools/editors/vim.samples
new file mode 100644
index 0000000..ccbc93f
--- /dev/null
+++ b/src/tools/editors/vim.samples
@@ -0,0 +1,17 @@
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+"
+" These settings are appropriate for editing PostgreSQL code with vim
+"
+" You would copy this into your .vimrc or equivalent
+"
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+:if match(getcwd(), "/pgsql") >=0 || match(getcwd(), "/postgresql") >= 0
+
+: set cinoptions=(0
+: set tabstop=4
+: set shiftwidth=4
+
+:endif
+
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""