Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8dc8f44

Browse files
committed
Update Emacs/vim editor info.
1 parentc84db61 commit8dc8f44

File tree

4 files changed

+103
-40
lines changed

4 files changed

+103
-40
lines changed

‎doc/src/FAQ/FAQ_DEV.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ <H3 id="item1.9">1.9) What tools are available for
370370
less:
371371
less -x4
372372
</PRE>
373-
<P>The<I>tools</I> directory of the latest sources contains sample
373+
<P>The<I>tools/editors</I> directory of the latest sources contains sample
374374
settings that can be used with the<I>emacs, xemacs</I> and<I>vim</I>
375375
editors, that assist in keeping to PostgreSQL coding standards.
376376
</P>

‎doc/src/sgml/sources.sgml

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/sources.sgml,v 2.17 2006/03/10 19:10:49 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/sources.sgml,v 2.18 2006/09/07 00:10:46 momjian Exp $ -->
22

33
<chapter id="source">
44
<title>PostgreSQL Coding Conventions</title>
@@ -21,44 +21,11 @@
2121
</para>
2222

2323
<para>
24-
For <productname>Emacs</productname>, add the following (or
25-
something similar) to your <filename>~/.emacs</filename>
26-
initialization file:
27-
28-
<programlisting>
29-
;; check for files with a path containing "postgres" or "pgsql"
30-
(setq auto-mode-alist
31-
(cons '("\\(postgres\\|pgsql\\).*\\.[ch]\\'" . pgsql-c-mode)
32-
auto-mode-alist))
33-
(setq auto-mode-alist
34-
(cons '("\\(postgres\\|pgsql\\).*\\.cc\\'" . pgsql-c-mode)
35-
auto-mode-alist))
36-
37-
(defun pgsql-c-mode ()
38-
;; sets up formatting for PostgreSQL C code
39-
(interactive)
40-
(c-mode)
41-
(setq-default tab-width 4)
42-
(c-set-style "bsd") ; set c-basic-offset to 4, plus other stuff
43-
(c-set-offset 'case-label '+) ; tweak case indent to match PG custom
44-
(setq indent-tabs-mode t)) ; make sure we keep tabs when indenting
45-
</programlisting>
46-
</para>
47-
48-
<para>
49-
For <application>vi</application>, your
50-
<filename>~/.vimrc</filename> or equivalent file should contain
51-
the following:
52-
53-
<programlisting>
54-
set tabstop=4
55-
</programlisting>
56-
57-
or equivalently from within <application>vi</application>, try
58-
59-
<programlisting>
60-
:set ts=4
61-
</programlisting>
24+
The <filename>src/tools</filename> directory contains sample settings
25+
files that can be used with the <productname>emacs</productname>,
26+
<productname>xemacs</productname> or <productname>vim</productname>
27+
editors to help ensure that they formatcode according to these
28+
conventions.
6229
</para>
6330

6431
<para>

‎src/tools/editors/emacs.samples

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2+
;;;
3+
;;; This file contains several examples of how to set up emacs and/or xemacs
4+
;;; to edit PostgreSQL code.
5+
;;;
6+
;;; Whichever set you choose would go in your .emacs file or equivalent.
7+
;;;
8+
;;; You only need one of these.
9+
;;;
10+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11+
12+
13+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14+
15+
;;; This set is known to work with old versions of emacs
16+
17+
(setq auto-mode-alist
18+
(cons '("\\(postgres\\|pgsql\\).*\\.[ch]\\'" . pgsql-c-mode)
19+
auto-mode-alist))
20+
(setq auto-mode-alist
21+
(cons '("\\(postgres\\|pgsql\\).*\\.cc\\'" . pgsql-c-mode)
22+
auto-mode-alist))
23+
24+
(defun pgsql-c-mode ()
25+
;; sets up formatting for PostgreSQL C code
26+
(interactive)
27+
(c-mode)
28+
(setq-default tab-width 4)
29+
(c-set-style "bsd") ; set c-basic-offset to 4, plus other stuff
30+
(c-set-offset 'case-label '+) ; tweak case indent to match PG custom
31+
(setq indent-tabs-mode t)) ; make sure we keep tabs when indenting
32+
33+
34+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35+
36+
;;; Similar approach, known to work with xemacs
37+
;;; Use of a named style makes it easy to use the style elsewhere
38+
39+
(c-add-style "pgsql"
40+
'("bsd"
41+
(indent-tabs-mode . t)
42+
(c-basic-offset . 4)
43+
(tab-width . 4)
44+
(c-offsets-alist .
45+
((case-label . +)))
46+
)
47+
nil ) ; t = set this mode, nil = don't
48+
49+
(defun pgsql-c-mode ()
50+
(c-mode)
51+
(c-set-style "pgsql")
52+
)
53+
54+
(setq auto-mode-alist
55+
(cons '("\\(postgres\\|pgsql\\).*\\.[chyl]\\'" . pgsql-c-mode)
56+
auto-mode-alist))
57+
(setq auto-mode-alist
58+
(cons '("\\(postgres\\|pgsql\\).*\\.cc\\'" . pgsql-c-mode)
59+
auto-mode-alist))
60+
61+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
62+
63+
;;; Slightly different approach - use a hook instead of a mode
64+
65+
(add-hook 'c-mode-hook
66+
(function
67+
(lambda nil
68+
(if (string-match "pgsql" buffer-file-name)
69+
(progn
70+
(c-set-style "bsd")
71+
(setq c-basic-offset 4)
72+
(setq tab-width 4)
73+
(c-set-offset 'case-label '+)
74+
(setq indent-tabs-mode t)
75+
)
76+
))))
77+
78+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

‎src/tools/editors/vim.samples

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3+
"
4+
" These settings are appropriate for editing PostgreSQL code with vim
5+
"
6+
" You would copy this into your .vimrc or equivalent
7+
"
8+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
9+
10+
:if match(getcwd(), "/pgsql") >=0 || match(getcwd(), "/postgresql") >= 0
11+
12+
: set cinoptions=(0
13+
: set tabstop=4
14+
: set shiftwidth=4
15+
16+
:endif
17+
18+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp