annotate lisp/progmodes/cc-styles.el @ 27125:4b3c83c489cf

(elide-head): Add :version.
author Dave Love <fx@gnu.org>
date Tue, 04 Jan 2000 00:09:35 +0000
parents 03befb219d03
children 58d2360c8677
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; cc-styles.el --- support for styles in CC Mode
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
3 ;; Copyright (C) 1985,1987,1992-1999 Free Software Foundation, Inc.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
5 ;; Authors: 1998-1999 Barry A. Warsaw and Martin Stjernholm
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
6 ;; 1992-1997 Barry A. Warsaw
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; 1987 Dave Detlefs and Stewart Clamen
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; 1985 Richard M. Stallman
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
9 ;; Maintainer: bug-cc-mode@gnu.org
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; Created: 22-Apr-1997 (split from cc-mode.el)
20147
481af10544cc (c-initialize-builtin-style):
Karl Heuer <kwzh@gnu.org>
parents: 20136
diff changeset
11 ;; Version: See cc-mode.el
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; Keywords: c languages oop
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; This file is part of GNU Emacs.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is free software; you can redistribute it and/or modify
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; it under the terms of the GNU General Public License as published by
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; the Free Software Foundation; either version 2, or (at your option)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; any later version.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; GNU Emacs is distributed in the hope that it will be useful,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; GNU General Public License for more details.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; You should have received a copy of the GNU General Public License
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; Boston, MA 02111-1307, USA.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
31 (eval-when-compile
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
32 (let ((load-path
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
33 (if (and (boundp 'byte-compile-current-file)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
34 (stringp byte-compile-current-file))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
35 (cons (file-name-directory byte-compile-current-file)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
36 load-path)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
37 load-path)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
38 (load "cc-defs" nil t)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
39 (require 'cc-vars)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
41
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
43 ;; Warning: don't eval-defun this constant or you'll break style inheritance.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (defconst c-style-alist
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 '(("gnu"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (c-basic-offset . 2)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (c-comment-only-line-offset . (0 . 0))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (c-offsets-alist . ((statement-block-intro . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (knr-argdecl-intro . 5)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (substatement-open . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (label . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 (statement-case-open . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (statement-cont . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (arglist-intro . c-lineup-arglist-intro-after-paren)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (arglist-close . c-lineup-arglist)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
56 (inline-open . 0)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (c-special-indent-hook . c-gnu-impose-minimum)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
59 (c-block-comment-prefix . "")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ("k&r"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (c-basic-offset . 5)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (c-comment-only-line-offset . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (c-offsets-alist . ((statement-block-intro . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (knr-argdecl-intro . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (substatement-open . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (label . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (statement-cont . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ("bsd"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (c-basic-offset . 4)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (c-comment-only-line-offset . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (c-offsets-alist . ((statement-block-intro . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (knr-argdecl-intro . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (substatement-open . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (label . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (statement-cont . +)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
79 (inline-open . 0)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
80 (inexpr-class . 0)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ("stroustrup"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (c-basic-offset . 4)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (c-comment-only-line-offset . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (c-offsets-alist . ((statement-block-intro . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (substatement-open . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (label . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (statement-cont . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ("whitesmith"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (c-basic-offset . 4)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (c-comment-only-line-offset . 0)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
95 (c-offsets-alist . ((knr-argdecl-intro . +)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (label . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (statement-cont . +)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
98 (substatement-open . +)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
99 (block-open . +)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
100 (statement-block-intro . c-lineup-whitesmith-in-block)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
101 (block-close . c-lineup-whitesmith-in-block)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
102 (inline-open . +)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
103 (defun-open . +)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
104 (defun-block-intro . c-lineup-whitesmith-in-block)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
105 (defun-close . c-lineup-whitesmith-in-block)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
106 (brace-list-open . +)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
107 (brace-list-intro . c-lineup-whitesmith-in-block)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
108 (brace-entry-open . c-indent-multi-line-block)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
109 (brace-list-close . c-lineup-whitesmith-in-block)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
110 (class-open . +)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
111 (inclass . c-lineup-whitesmith-in-block)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
112 (class-close . +)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
113 (inexpr-class . 0)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
114 (extern-lang-open . +)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
115 (inextern-lang . c-lineup-whitesmith-in-block)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
116 (extern-lang-close . +)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
117 (namespace-open . +)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
118 (innamespace . c-lineup-whitesmith-in-block)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
119 (namespace-close . +)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ("ellemtel"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (c-basic-offset . 3)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (c-comment-only-line-offset . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (c-hanging-braces-alist . ((substatement-open before after)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (c-offsets-alist . ((topmost-intro . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (topmost-intro-cont . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (substatement . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (substatement-open . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (case-label . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (access-label . -)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (inclass . ++)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (inline-open . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ("linux"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (c-basic-offset . 8)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (c-comment-only-line-offset . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (c-hanging-braces-alist . ((brace-list-open)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
140 (brace-entry-open)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (substatement-open after)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (block-close . c-snug-do-while)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (c-cleanup-list . (brace-else-brace))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (c-offsets-alist . ((statement-block-intro . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (knr-argdecl-intro . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (substatement-open . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (label . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (statement-cont . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ("python"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (indent-tabs-mode . t)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
153 (fill-column . 78)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (c-basic-offset . 8)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (c-offsets-alist . ((substatement-open . 0)
19807
86412da1174b (c-style-alist) <python>:, knr-argdecl-intro == +
Richard M. Stallman <rms@gnu.org>
parents: 19376
diff changeset
156 (inextern-lang . 0)
86412da1174b (c-style-alist) <python>:, knr-argdecl-intro == +
Richard M. Stallman <rms@gnu.org>
parents: 19376
diff changeset
157 (arglist-intro . +)
86412da1174b (c-style-alist) <python>:, knr-argdecl-intro == +
Richard M. Stallman <rms@gnu.org>
parents: 19376
diff changeset
158 (knr-argdecl-intro . +)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (c-hanging-braces-alist . ((brace-list-open)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (brace-list-intro)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (brace-list-close)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
163 (brace-entry-open)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (substatement-open after)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (block-close . c-snug-do-while)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
167 (c-block-comment-prefix . "")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ("java"
20918
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
170 (c-basic-offset . 4)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (c-comment-only-line-offset . (0 . 0))
19254
81353d4e05b7 (c-styles-alist): In "java" style, set
Richard M. Stallman <rms@gnu.org>
parents: 19212
diff changeset
172 ;; the following preserves Javadoc starter lines
20918
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
173 (c-offsets-alist . ((inline-open . 0)
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
174 (topmost-intro-cont . +)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (statement-block-intro . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (knr-argdecl-intro . 5)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (substatement-open . +)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
178 (label . +)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (statement-case-open . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (statement-cont . +)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (arglist-intro . c-lineup-arglist-intro-after-paren)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (arglist-close . c-lineup-arglist)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (access-label . 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (inher-cont . c-lineup-java-inher)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (func-decl-cont . c-lineup-java-throws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 "Styles of indentation.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 Elements of this alist are of the form:
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (STYLE-STRING [BASE-STYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 where STYLE-STRING is a short descriptive string used to select a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 style, VARIABLE is any Emacs variable, and VALUE is the intended value
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 for that variable when using the selected style.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 Optional BASE-STYLE if present, is a string and must follow
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 STYLE-STRING. BASE-STYLE names a style that this style inherits from.
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
200 By default, all styles inherit from the \"user\" style, which is
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 computed at run time. Style loops generate errors.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 Two variables are treated specially. When VARIABLE is
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 `c-offsets-alist', the VALUE is a list containing elements of the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 form:
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (SYNTACTIC-SYMBOL . OFFSET)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 as described in `c-offsets-alist'. These are passed directly to
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 `c-set-offset' so there is no need to set every syntactic symbol in
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 your style, only those that are different from the default.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 When VARIABLE is `c-special-indent-hook', its VALUE is added to
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 `c-special-indent-hook' using `add-hook'. If VALUE is a list, each
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 element of the list is added with `add-hook'.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 Do not change this variable directly. Use the function `c-add-style'
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 to add new styles or modify existing styles (it is not a good idea to
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 modify existing styles -- you should create a new style that inherits
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 the existing style.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
222
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 ;; Functions that manipulate styles
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
225 (defun c-set-style-1 (conscell dont-override)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 ;; Set the style for one variable
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (let ((attr (car conscell))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (val (cdr conscell)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 ;; first special variable
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 ((eq attr 'c-offsets-alist)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (mapcar
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (function
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (lambda (langentry)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (let ((langelem (car langentry))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (offset (cdr langentry)))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
237 (unless (and dont-override
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
238 (assq langelem c-offsets-alist))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
239 (c-set-offset langelem offset))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 )))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
241 (if dont-override (reverse val) val)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 ;; second special variable
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 ((eq attr 'c-special-indent-hook)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
244 (let ((add-func (if dont-override
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
245 (lambda (func)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
246 (unless (memq func c-special-indent-hook)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
247 (add-hook 'c-special-indent-hook func t)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
248 (lambda (func)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
249 (add-hook 'c-special-indent-hook func)))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
250 (if (listp val)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
251 (mapcar add-func (if dont-override (reverse val) val))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
252 (funcall add-func val))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 ;; all other variables
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
254 (t (if (or (not dont-override)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
255 (not (memq attr c-style-variables))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
256 (eq (symbol-value attr) 'set-from-style))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
257 (set attr val))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
260 (defun c-get-style-variables (style basestyles)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
261 ;; Return all variables in a style by resolving inheritances.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (let ((vars (cdr (or (assoc (downcase style) c-style-alist)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (assoc (upcase style) c-style-alist)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (assoc style c-style-alist)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (error "Undefined style: %s" style)))))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
266 (if (string-equal style "user")
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
267 (copy-alist vars)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
268 (let ((base (if (stringp (car vars))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
269 (prog1
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
270 (downcase (car vars))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
271 (setq vars (cdr vars)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
272 "user")))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
273 (if (memq base basestyles)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
274 (error "Style loop detected: %s in %s" base basestyles))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
275 (nconc (c-get-style-variables base (cons base basestyles))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
276 (copy-alist vars))))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
277
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (defvar c-set-style-history nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 ;;;###autoload
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
281 (defun c-set-style (stylename &optional dont-override)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 "Set CC Mode variables to use one of several different indentation styles.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 STYLENAME is a string representing the desired style from the list of
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 styles described in the variable `c-style-alist'. See that variable
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 for details of setting up styles.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 The variable `c-indentation-style' always contains the buffer's current
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
288 style name.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
289
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
290 If the optional argument DONT-OVERRIDE is non-nil, no style variables
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
291 that already have values will be overridden. I.e. in the case of
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
292 `c-offsets-alist', syntactic symbols will only be added, and in the
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
293 case of all other style variables, only those set to `set-from-style'
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
294 will be reassigned.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
295
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
296 Obviously, specifying DONT-OVERRIDE is useful mainly when the initial
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
297 style is chosen for a CC Mode buffer by a major mode. Since this is
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
298 done internally by CC Mode, there's hardly ever a reason to use it."
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (interactive (list (let ((completion-ignore-case t)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (prompt (format "Which %s indentation style? "
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 mode-name)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (completing-read prompt c-style-alist nil t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (cons c-indentation-style 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 'c-set-style-history))))
19254
81353d4e05b7 (c-styles-alist): In "java" style, set
Richard M. Stallman <rms@gnu.org>
parents: 19212
diff changeset
305 (c-initialize-builtin-style)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
306 (let ((vars (c-get-style-variables stylename nil)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
307 (mapcar (lambda (elem)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
308 (c-set-style-1 elem dont-override))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
309 ;; Need to go through the variables backwards when we
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
310 ;; don't override.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
311 (if dont-override (nreverse vars) vars)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (setq c-indentation-style stylename)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (c-keep-region-active))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 ;;;###autoload
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (defun c-add-style (style descrip &optional set-p)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 "Adds a style to `c-style-alist', or updates an existing one.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 STYLE is a string identifying the style to add or update. DESCRIP is
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 an association list describing the style and must be of the form:
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 ([BASESTYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 See the variable `c-style-alist' for the semantics of BASESTYLE,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 VARIABLE and VALUE. This function also sets the current style to
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 STYLE using `c-set-style' if the optional SET-P flag is non-nil."
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (interactive
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (let ((stylename (completing-read "Style to add: " c-style-alist
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 nil nil nil 'c-set-style-history))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (description (eval-minibuffer "Style description: ")))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (list stylename description
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (y-or-n-p "Set the style too? "))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (setq style (downcase style))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (let ((s (assoc style c-style-alist)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (if s
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (setcdr s (copy-alist descrip)) ; replace
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (setq c-style-alist (cons (cons style descrip) c-style-alist))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (and set-p (c-set-style style)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
341 (defun c-evaluate-offset (offset langelem symbol)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
342 ;; offset can be a number, a function, a variable, a list, or one of
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
343 ;; the symbols + or -
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
344 (cond
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
345 ((eq offset '+) (setq offset c-basic-offset))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
346 ((eq offset '-) (setq offset (- c-basic-offset)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
347 ((eq offset '++) (setq offset (* 2 c-basic-offset)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
348 ((eq offset '--) (setq offset (* 2 (- c-basic-offset))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
349 ((eq offset '*) (setq offset (/ c-basic-offset 2)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
350 ((eq offset '/) (setq offset (/ (- c-basic-offset) 2)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
351 ((functionp offset) (setq offset (funcall offset langelem)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
352 ((listp offset)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
353 (setq offset
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
354 (let (done)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
355 (while (and (not done) offset)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
356 (setq done (c-evaluate-offset (car offset) langelem symbol)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
357 offset (cdr offset)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
358 (if (not done)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
359 (if c-strict-syntax-p
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
360 (error "No offset found for syntactic symbol %s" symbol)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
361 0)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
362 done))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
363 ((not (numberp offset)) (setq offset (symbol-value offset)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
364 )
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
365 offset)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
366
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (defun c-get-offset (langelem)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 ;; Get offset from LANGELEM which is a cons cell of the form:
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 ;; (SYMBOL . RELPOS). The symbol is matched against
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 ;; c-offsets-alist and the offset found there is either returned,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 ;; or added to the indentation at RELPOS. If RELPOS is nil, then
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 ;; the offset is simply returned.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (let* ((symbol (car langelem))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (relpos (cdr langelem))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (match (assq symbol c-offsets-alist))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (offset (cdr-safe match)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
377 (if (not match)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
378 (if c-strict-syntax-p
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
379 (error "No offset found for syntactic symbol %s" symbol)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
380 (setq offset 0
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
381 relpos 0))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
382 (setq offset (c-evaluate-offset offset langelem symbol)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (+ (if (and relpos
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (< relpos (c-point 'bol)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (goto-char relpos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (current-column))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 0)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
389 (or (and (numberp offset) offset)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
390 (and (symbolp offset) (symbol-value offset))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
391 0))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
392 ))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
394
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (defvar c-read-offset-history nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (defun c-read-offset (langelem)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 ;; read new offset value for LANGELEM from minibuffer. return a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 ;; legal value only
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
401 (let* ((oldoff (cdr-safe (or (assq langelem c-offsets-alist)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
402 (assq langelem (get 'c-offsets-alist
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
403 'c-stylevar-fallback)))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
404 (symname (symbol-name langelem))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
405 (defstr (format "(default %s): " oldoff))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
406 (errmsg (concat "Offset must be int, func, var, list, "
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
407 "or [+,-,++,--,*,/] "
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
408 defstr))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
409 (prompt (concat symname " offset " defstr))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 offset input interned raw)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (while (not offset)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (setq input (completing-read prompt obarray 'fboundp nil nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 'c-read-offset-history)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 offset (cond ((string-equal "" input) oldoff) ; default
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 ((string-equal "+" input) '+)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 ((string-equal "-" input) '-)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 ((string-equal "++" input) '++)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 ((string-equal "--" input) '--)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 ((string-equal "*" input) '*)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 ((string-equal "/" input) '/)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 ((string-match "^-?[0-9]+$" input)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (string-to-int input))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 ;; a symbol with a function binding
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 ((fboundp (setq interned (intern input)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 interned)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 ;; a lambda function
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 ((c-safe (functionp (setq raw (read input))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 raw)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 ;; a symbol with variable binding
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 ((boundp interned) interned)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 ;; error, but don't signal one, keep trying
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 ;; to read an input value
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (t (ding)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (setq prompt errmsg)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 nil))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 offset))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437
19212
024594beef65 (c-set-offset): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 18845
diff changeset
438 ;;;###autoload
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
439 (defun c-set-offset (symbol offset &optional ignored)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 "Change the value of a syntactic element symbol in `c-offsets-alist'.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 SYMBOL is the syntactic element symbol to change and OFFSET is the new
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
442 offset for that syntactic element. The optional argument is not used
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
443 and exists only for compatibility reasons."
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (interactive
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (let* ((langelem
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (intern (completing-read
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (concat "Syntactic symbol to change"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (if current-prefix-arg " or add" "")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 ": ")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (mapcar
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 #'(lambda (langelem)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 (cons (format "%s" (car langelem)) nil))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
453 (get 'c-offsets-alist 'c-stylevar-fallback))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 nil (not current-prefix-arg)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 ;; initial contents tries to be the last element
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 ;; on the syntactic analysis list for the current
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 ;; line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (let* ((syntax (c-guess-basic-syntax))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (len (length syntax))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 (ic (format "%s" (car (nth (1- len) syntax)))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (cons ic 0))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (offset (c-read-offset langelem)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 (list langelem offset current-prefix-arg)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 ;; sanity check offset
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
466 (unless (c-valid-offset offset)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
467 (error "Offset must be int, func, var, list, or in [+,-,++,--,*,/]: %s"
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
468 offset))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (let ((entry (assq symbol c-offsets-alist)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (if entry
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (setcdr entry offset)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
472 (if (assq symbol (get 'c-offsets-alist 'c-stylevar-fallback))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (setq c-offsets-alist (cons (cons symbol offset) c-offsets-alist))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
474 (error "%s is not a valid syntactic symbol" symbol))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (c-keep-region-active))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
477
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
478
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (defun c-initialize-builtin-style ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 ;; Dynamically append the default value of most variables. This is
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 ;; crucial because future c-set-style calls will always reset the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 ;; variables first to the `cc-mode' style before instituting the new
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 ;; style. Only do this once!
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
484 (unless (get 'c-initialize-builtin-style 'is-run)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
485 (put 'c-initialize-builtin-style 'is-run t)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
486 (c-initialize-cc-mode)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
487 (or (assoc "cc-mode" c-style-alist)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
488 (assoc "user" c-style-alist)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
489 (progn
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
490 (c-add-style
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
491 "user"
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
492 (mapcar
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
493 (lambda (var)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
494 (let ((val (symbol-value var)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
495 (cons var
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
496 (cond ((eq var 'c-offsets-alist)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
497 (mapcar
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
498 (lambda (langentry)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
499 (setq langentry (or (assq (car langentry) val)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
500 langentry))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
501 (cons (car langentry)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
502 (cdr langentry)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
503 (get var 'c-stylevar-fallback)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
504 ((eq var 'c-special-indent-hook)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
505 val)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
506 (t
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
507 (if (eq val 'set-from-style)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
508 (get var 'c-stylevar-fallback)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
509 val))))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
510 c-style-variables))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
511 (c-add-style "cc-mode" '("user"))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
512 (if c-style-variables-are-local-p
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 20920
diff changeset
513 (c-make-styles-buffer-local))))
19254
81353d4e05b7 (c-styles-alist): In "java" style, set
Richard M. Stallman <rms@gnu.org>
parents: 19212
diff changeset
514
20918
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
515 (defun c-make-styles-buffer-local (&optional this-buf-only-p)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 "Make all CC Mode style variables buffer local.
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
517 If you edit primarily one style of C (or C++, Objective-C, Java, etc)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
518 code, you probably want style variables to be global. This is the
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
519 default.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
521 If you edit many different styles of C (or C++, Objective-C, Java,
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
522 etc) at the same time, you probably want the CC Mode style variables
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
523 to be buffer local. If you do, it's advicable to set any CC Mode
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
524 style variables in a hook function (e.g. off of `c-mode-common-hook'),
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
525 instead of at the top level of your ~/.emacs file.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 This function makes all the CC Mode style variables buffer local.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 Call it after CC Mode is loaded into your Emacs environment.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 Conversely, set the variable `c-style-variables-are-local-p' to t in
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 your .emacs file, before CC Mode is loaded, and this function will be
20918
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
531 automatically called when CC Mode is loaded.
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
532
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
533 Optional argument, when non-nil, means use `make-local-variable'
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
534 instead of `make-variable-buffer-local'."
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 ;; style variables
20918
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
536 (let ((func (if this-buf-only-p
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
537 'make-local-variable
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
538 'make-variable-buffer-local))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
539 (varsyms (cons 'c-indentation-style (copy-alist c-style-variables))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
540 (delq 'c-special-indent-hook varsyms)
20918
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
541 (mapcar func varsyms)
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
542 ;; Hooks must be handled specially
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
543 (if this-buf-only-p
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
544 (make-local-hook 'c-special-indent-hook)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
545 (make-variable-buffer-local 'c-special-indent-hook)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24282
diff changeset
546 (setq c-style-variables-are-local-p t))
20918
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
547 ))
8e64bd5b1b5f (c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents: 20147
diff changeset
548
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (provide 'cc-styles)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 ;;; cc-styles.el ends here