annotate lisp/cc-mode/cc-langs.el @ 165:5a88923fcbfe r20-3b9

Import from CVS: tag r20-3b9
author cvs
date Mon, 13 Aug 2007 09:44:42 +0200
parents
children 85ec50267440
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
1 ;;; cc-langs.el --- specific language support for CC Mode
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
2
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
4
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
5 ;; Authors: 1992-1997 Barry A. Warsaw
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
6 ;; 1987 Dave Detlefs and Stewart Clamen
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
7 ;; 1985 Richard M. Stallman
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
8 ;; Maintainer: cc-mode-help@python.org
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
9 ;; Created: 22-Apr-1997 (split from cc-mode.el)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
10 ;; Version: 5.11
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
11 ;; Keywords: c languages oop
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
12
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
13 ;; This file is part of GNU Emacs.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
14
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
16 ;; it under the terms of the GNU General Public License as published by
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
17 ;; the Free Software Foundation; either version 2, or (at your option)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
18 ;; any later version.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
19
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
20 ;; GNU Emacs is distributed in the hope that it will be useful,
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
23 ;; GNU General Public License for more details.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
24
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
25 ;; You should have received a copy of the GNU General Public License
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
28 ;; Boston, MA 02111-1307, USA.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
29
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
30 (eval-when-compile
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
31 (load-file "./cc-styles.el"))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
32
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
33
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
34 ;; Regular expressions and other values which must be parameterized on
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
35 ;; a per-language basis.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
36
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
37 ;; Keywords defining protection levels
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
38 (defconst c-protection-key "\\<\\(public\\|protected\\|private\\)\\>")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
39
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
40 ;; Regex describing a `symbol' in all languages We cannot use just
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
41 ;; `word' syntax class since `_' cannot be in word class. Putting
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
42 ;; underscore in word class breaks forward word movement behavior that
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
43 ;; users are familiar with.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
44 (defconst c-symbol-key "\\(\\w\\|\\s_\\)+")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
45
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
46
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
47 ;; keywords introducing class definitions. language specific
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
48 (defconst c-C-class-key "\\(struct\\|union\\)")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
49 (defconst c-C++-class-key "\\(class\\|struct\\|union\\)")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
50
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
51 (defconst c-ObjC-class-key
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
52 (concat
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
53 "@\\(interface\\|implementation\\)\\s +"
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
54 c-symbol-key ;name of the class
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
55 "\\(\\s *:\\s *" c-symbol-key "\\)?" ;maybe followed by the superclass
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
56 "\\(\\s *<[^>]+>\\)?" ;and maybe the adopted protocols list
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
57 ))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
58
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
59 (defconst c-Java-class-key
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
60 (concat
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
61 "\\(" c-protection-key "\\s +\\)?"
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
62 "\\(interface\\|class\\)\\s +"
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
63 c-symbol-key ;name of the class
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
64 "\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
65 ;;"\\(\\s *implements *[^{]+{\\)?" ;maybe the adopted protocols list
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
66 ))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
67
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
68 (defvar c-class-key c-C-class-key)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
69 (make-variable-buffer-local 'c-class-key)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
70
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
71
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
72 ;; regexp describing access protection clauses. language specific
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
73 (defvar c-access-key nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
74 (make-variable-buffer-local 'c-access-key)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
75 (defconst c-C++-access-key (concat c-protection-key "[ \t]*:"))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
76 (defconst c-ObjC-access-key (concat "@" c-protection-key))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
77 (defconst c-Java-access-key nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
78
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
79
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
80 ;; keywords introducing conditional blocks
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
81 (defconst c-C-conditional-key nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
82 (defconst c-C++-conditional-key nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
83 (defconst c-Java-conditional-key nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
84
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
85 (let ((all-kws "for\\|if\\|do\\|else\\|while\\|switch")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
86 (exc-kws "\\|try\\|catch")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
87 (thr-kws "\\|finally\\|synchronized")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
88 (front "\\b\\(")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
89 (back "\\)\\b[^_]"))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
90 (setq c-C-conditional-key (concat front all-kws back)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
91 c-C++-conditional-key (concat front all-kws exc-kws back)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
92 c-Java-conditional-key (concat front all-kws exc-kws thr-kws back)))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
93
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
94 (defvar c-conditional-key c-C-conditional-key)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
95 (make-variable-buffer-local 'c-conditional-key)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
96
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
97
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
98 ;; keywords describing method definition introductions
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
99 (defvar c-method-key nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
100 (make-variable-buffer-local 'c-method-key)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
101
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
102 (defconst c-ObjC-method-key
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
103 (concat
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
104 "^\\s *[+-]\\s *"
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
105 "\\(([^)]*)\\)?" ; return type
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
106 ;; \\s- in objc syntax table does not include \n
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
107 ;; since it is considered the end of //-comments.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
108 "[ \t\n]*" c-symbol-key))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
109
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
110 (defconst c-Java-method-key
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
111 (concat
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
112 "^\\s *[+-]\\s *"
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
113 "\\(([^)]*)\\)?" ; return type
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
114 ;; \\s- in java syntax table does not include \n
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
115 ;; since it is considered the end of //-comments.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
116 "[ \t\n]*" c-symbol-key))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
117
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
118
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
119 ;; comment starter definitions for various languages. language specific
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
120 (defconst c-C-comment-start-regexp "/[*]")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
121 (defconst c-C++-comment-start-regexp "/[/*]")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
122 ;; We need to match all 3 Java style comments
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
123 ;; 1) Traditional C block; 2) javadoc /** ...; 3) C++ style
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
124 (defconst c-Java-comment-start-regexp "/\\(/\\|[*][*]?\\)")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
125 (defvar c-comment-start-regexp c-C-comment-start-regexp)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
126 (make-variable-buffer-local 'c-comment-start-regexp)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
127
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
128
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
129
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
130 ;; Regexp describing a switch's case or default label for all languages
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
131 (defconst c-switch-label-key "\\(\\(case[( \t]+\\S .*\\)\\|default[ \t]*\\):")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
132 ;; Regexp describing any label.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
133 (defconst c-label-key (concat c-symbol-key ":\\([^:]\\|$\\)"))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
134
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
135 ;; Regexp describing class inheritance declarations. TBD: this should
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
136 ;; be language specific, and only makes sense for C++
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
137 (defconst c-inher-key
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
138 (concat "\\(\\<static\\>\\s +\\)?"
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
139 c-C++-class-key "[ \t]+" c-symbol-key
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
140 "\\([ \t]*:[ \t]*\\)\\s *[^;]"))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
141
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
142 ;; Regexp describing C++ base classes in a derived class definition.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
143 ;; TBD: this should be language specific, and only makes sense for C++
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
144 (defvar c-baseclass-key
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
145 (concat
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
146 ":?[ \t]*\\(virtual[ \t]+\\)?\\("
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
147 c-protection-key "[ \t]+\\)" c-symbol-key))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
148 (make-variable-buffer-local 'c-baseclass-key)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
149
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
150 ;; Regexp describing friend declarations in C++ classes.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
151 (defconst c-C++-friend-key
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
152 "friend[ \t]+\\|template[ \t]*<.+>[ \t]*friend[ \t]+")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
153
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
154 ;; Regexp describing Java inheritance and throws clauses.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
155 (defconst c-Java-special-key "\\(implements\\|extends\\|throws\\)[^_]")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
156
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
157 ;; Regexp describing the beginning of a Java top-level definition.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
158 (defconst c-Java-defun-prompt-regexp
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
159 "^[ \t]*\\(\\(\\(public\\|protected\\|private\\|const\\|abstract\\|synchronized\\|final\\|static\\|threadsafe\\|transient\\|native\\|volatile\\)\\s-+\\)*\\(\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*[][_$.a-zA-Z0-9]+\\|[[a-zA-Z]\\)\\s-*\\)\\s-+\\)\\)?\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*\\s-+\\)\\s-*\\)?\\([_a-zA-Z][^][ \t:;.,{}()=]*\\|\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)\\)\\s-*\\(([^);{}]*)\\)?\\([] \t]*\\)\\(\\s-*\\<throws\\>\\s-*\\(\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)[, \t\n\r\f]*\\)+\\)?\\s-*")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
160
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
161
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
162
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
163 ;; internal state variables
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
164
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
165 ;; Internal state of hungry delete key feature
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
166 (defvar c-hungry-delete-key nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
167 (make-variable-buffer-local 'c-hungry-delete-key)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
168
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
169 ;; Internal state of auto newline feature.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
170 (defvar c-auto-newline nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
171 (make-variable-buffer-local 'c-auto-newline)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
172
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
173 ;; Internal auto-newline/hungry-delete designation string for mode line.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
174 (defvar c-auto-hungry-string nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
175 (make-variable-buffer-local 'c-auto-hungry-string)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
176
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
177 ;; Buffer local language-specific comment style flag.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
178 (defvar c-double-slash-is-comments-p nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
179 (make-variable-buffer-local 'c-double-slash-is-comments-p)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
180
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
181 ;; Non-nil means K&R style argument declarations are valid.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
182 (defvar c-recognize-knr-p t)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
183 (make-variable-buffer-local 'c-recognize-knr-p)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
184
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
185
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
186
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
187 (defun c-use-java-style ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
188 "Institutes `java' indentation style.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
189 For use with the variable `java-mode-hook'."
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
190 (c-set-style "java"))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
191
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
192 (defun c-common-init ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
193 ;; Common initializations for c++-mode and c-mode.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
194 ;;
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
195 ;; these variables should always be buffer local; they do not affect
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
196 ;; indentation style.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
197 (make-local-variable 'paragraph-start)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
198 (make-local-variable 'paragraph-separate)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
199 (make-local-variable 'paragraph-ignore-fill-prefix)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
200 (make-local-variable 'require-final-newline)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
201 (make-local-variable 'parse-sexp-ignore-comments)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
202 (make-local-variable 'indent-line-function)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
203 (make-local-variable 'indent-region-function)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
204 (make-local-variable 'comment-start)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
205 (make-local-variable 'comment-end)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
206 (make-local-variable 'comment-column)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
207 (make-local-variable 'comment-start-skip)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
208 (make-local-variable 'comment-multi-line)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
209 (make-local-variable 'outline-regexp)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
210 (make-local-variable 'outline-level)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
211 (make-local-variable 'adaptive-fill-regexp)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
212 (make-local-variable 'imenu-generic-expression) ;set in the mode functions
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
213 ;; Emacs 19.30 and beyond only, AFAIK
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
214 (if (boundp 'fill-paragraph-function)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
215 (progn
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
216 (make-local-variable 'fill-paragraph-function)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
217 (setq fill-paragraph-function 'c-fill-paragraph)))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
218 ;; now set their values
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
219 (setq paragraph-start (concat page-delimiter "\\|$")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
220 paragraph-separate paragraph-start
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
221 paragraph-ignore-fill-prefix t
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
222 require-final-newline t
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
223 parse-sexp-ignore-comments t
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
224 indent-line-function 'c-indent-line
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
225 indent-region-function 'c-indent-region
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
226 outline-regexp "[^#\n\^M]"
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
227 outline-level 'c-outline-level
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
228 comment-column 32
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
229 comment-start-skip "/\\*+ *\\|// *"
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
230 adaptive-fill-regexp nil)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
231 ;; we have to do something special for c-offsets-alist so that the
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
232 ;; buffer local value has its own alist structure.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
233 (setq c-offsets-alist (copy-alist c-offsets-alist))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
234 ;; setup the comment indent variable in a Emacs version portable way
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
235 ;; ignore any byte compiler warnings you might get here
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
236 (make-local-variable 'comment-indent-function)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
237 (setq comment-indent-function 'c-comment-indent)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
238 ;; add menus to menubar
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
239 (easy-menu-add (c-mode-menu mode-name))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
240 ;; put auto-hungry designators onto minor-mode-alist, but only once
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
241 (or (assq 'c-auto-hungry-string minor-mode-alist)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
242 (setq minor-mode-alist
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
243 (cons '(c-auto-hungry-string c-auto-hungry-string)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
244 minor-mode-alist))))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
245
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
246 (defun c-postprocess-file-styles ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
247 "Function that post processes relevant file local variables.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
248 Currently, this function simply applies any style and offset settings
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
249 found in the file's Local Variable list. It first applies any style
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
250 setting found in `c-file-style', then it applies any offset settings
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
251 it finds in `c-file-offsets'."
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
252 ;; apply file styles and offsets
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
253 (and c-file-style
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
254 (c-set-style c-file-style))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
255 (and c-file-offsets
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
256 (mapcar
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
257 (function
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
258 (lambda (langentry)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
259 (let ((langelem (car langentry))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
260 (offset (cdr langentry)))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
261 (c-set-offset langelem offset)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
262 )))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
263 c-file-offsets)))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
264
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
265 (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
266
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
267
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
268 ;; Common routines
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
269 (defsubst c-make-inherited-keymap ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
270 (let ((map (make-sparse-keymap)))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
271 (cond
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
272 ;; XEmacs 19 & 20
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
273 ((fboundp 'set-keymap-parents)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
274 (set-keymap-parents map c-mode-base-map))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
275 ;; Emacs 19
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
276 ((fboundp 'set-keymap-parent)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
277 (set-keymap-parent map c-mode-base-map))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
278 ;; incompatible
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
279 (t (error "CC Mode is incompatible with this version of Emacs")))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
280 map))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
281
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
282 (defun c-populate-syntax-table (table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
283 ;; Populate the syntax TABLE
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
284 ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS!
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
285 (modify-syntax-entry ?_ "_" table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
286 (modify-syntax-entry ?\\ "\\" table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
287 (modify-syntax-entry ?+ "." table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
288 (modify-syntax-entry ?- "." table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
289 (modify-syntax-entry ?= "." table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
290 (modify-syntax-entry ?% "." table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
291 (modify-syntax-entry ?< "." table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
292 (modify-syntax-entry ?> "." table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
293 (modify-syntax-entry ?& "." table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
294 (modify-syntax-entry ?| "." table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
295 (modify-syntax-entry ?\' "\"" table))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
296
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
297 (defun c-setup-dual-comments (table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
298 ;; Set up TABLE to handle block and line style comments
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
299 (cond
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
300 ;; XEmacs 19 & 20
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
301 ((memq '8-bit c-emacs-features)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
302 (modify-syntax-entry ?/ ". 1456" table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
303 (modify-syntax-entry ?* ". 23" table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
304 (modify-syntax-entry ?\n "> b" table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
305 ;; Give CR the same syntax as newline, for selective-display
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
306 (modify-syntax-entry ?\^m "> b" table))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
307 ;; Emacs 19
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
308 ((memq '1-bit c-emacs-features)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
309 (modify-syntax-entry ?/ ". 124b" table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
310 (modify-syntax-entry ?* ". 23" table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
311 (modify-syntax-entry ?\n "> b" table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
312 ;; Give CR the same syntax as newline, for selective-display
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
313 (modify-syntax-entry ?\^m "> b" table))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
314 ;; incompatible
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
315 (t (error "CC Mode is incompatible with this version of Emacs"))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
316 ))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
317
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
318 (defvar c-mode-base-map ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
319 "Keymap shared by all CC Mode related modes.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
320
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
321 (if c-mode-base-map
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
322 nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
323 ;; TBD: should we even worry about naming this keymap. My vote: no,
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
324 ;; because Emacs and XEmacs do it differently.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
325 (setq c-mode-base-map (make-sparse-keymap))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
326 ;; put standard keybindings into MAP
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
327 ;; the following mappings correspond more or less directly to BOCM
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
328 (define-key c-mode-base-map "{" 'c-electric-brace)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
329 (define-key c-mode-base-map "}" 'c-electric-brace)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
330 (define-key c-mode-base-map ";" 'c-electric-semi&comma)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
331 (define-key c-mode-base-map "#" 'c-electric-pound)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
332 (define-key c-mode-base-map ":" 'c-electric-colon)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
333 ;; Lucid Emacs 19.9 defined these two, the second of which was
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
334 ;; commented out...
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
335 ;; (define-key c-mode-base-map "\e{" 'c-insert-braces)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
336 ;; Commented out electric square brackets because nobody likes them.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
337 ;; (define-key c-mode-base-map "[" 'c-insert-brackets)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
338 (define-key c-mode-base-map "\C-c\C-m" 'c-mark-function)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
339 (define-key c-mode-base-map "\e\C-q" 'c-indent-exp)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
340 (define-key c-mode-base-map "\ea" 'c-beginning-of-statement)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
341 (define-key c-mode-base-map "\ee" 'c-end-of-statement)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
342 (define-key c-mode-base-map "\C-c\C-n" 'c-forward-conditional)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
343 (define-key c-mode-base-map "\C-c\C-p" 'c-backward-conditional)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
344 (define-key c-mode-base-map "\C-c\C-u" 'c-up-conditional)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
345 (define-key c-mode-base-map "\t" 'c-indent-command)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
346 ;; In XEmacs 19 and Emacs 19, this binds both the BackSpace and
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
347 ;; Delete keysyms to c-electric-backspace. In XEmacs 20 it binds
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
348 ;; only BackSpace, so we now bind them individually
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
349 (define-key c-mode-base-map [delete] 'c-electric-delete)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
350 (define-key c-mode-base-map [backspace] 'c-electric-backspace)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
351 ;; these are new keybindings, with no counterpart to BOCM
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
352 (define-key c-mode-base-map "," 'c-electric-semi&comma)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
353 (define-key c-mode-base-map "*" 'c-electric-star)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
354 (define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
355 (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
356 ;; TBD: where if anywhere, to put c-backward|forward-into-nomenclature
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
357 (define-key c-mode-base-map "\C-c\C-a" 'c-toggle-auto-state)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
358 (define-key c-mode-base-map "\C-c\C-b" 'c-submit-bug-report)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
359 (define-key c-mode-base-map "\C-c\C-c" 'comment-region)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
360 (define-key c-mode-base-map "\C-c\C-d" 'c-toggle-hungry-state)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
361 (define-key c-mode-base-map "\C-c\C-e" 'c-macro-expand)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
362 (define-key c-mode-base-map "\C-c\C-o" 'c-set-offset)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
363 (define-key c-mode-base-map "\C-c\C-s" 'c-show-syntactic-information)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
364 (define-key c-mode-base-map "\C-c\C-t" 'c-toggle-auto-hungry-state)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
365 (define-key c-mode-base-map "\C-c." 'c-set-style)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
366 ;; conflicts with OOBR
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
367 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
368 )
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
369
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
370
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
371
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
372 ;; Support for C
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
373
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
374 (defvar c-mode-abbrev-table nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
375 "Abbrev table in use in c-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
376 (define-abbrev-table 'c-mode-abbrev-table ())
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
377
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
378 (defvar c-mode-map ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
379 "Keymap used in c-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
380 (if c-mode-map
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
381 nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
382 (setq c-mode-map (c-make-inherited-keymap))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
383 ;; add bindings which are only useful for C
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
384 )
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
385
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
386 (defvar c-mode-syntax-table nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
387 "Syntax table used in c-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
388 (if c-mode-syntax-table
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
389 ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
390 (setq c-mode-syntax-table (make-syntax-table))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
391 (c-populate-syntax-table c-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
392 ;; add extra comment syntax
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
393 (modify-syntax-entry ?/ ". 14" c-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
394 (modify-syntax-entry ?* ". 23" c-mode-syntax-table))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
395
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
396 (defun c-enable-//-in-c-mode ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
397 "Enables // as a comment delimiter in `c-mode'.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
398 ANSI C currently does *not* allow this, although many C compilers
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
399 support optional C++ style comments. To use, call this function from
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
400 your `.emacs' file before you visit any C files. The changes are
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
401 global and affect all future `c-mode' buffers."
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
402 (c-setup-dual-comments c-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
403 (setq-default c-C-comment-start-regexp c-C++-comment-start-regexp))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
404
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
405
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
406
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
407 ;; Support for C++
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
408
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
409 (defvar c++-mode-abbrev-table nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
410 "Abbrev table in use in c++-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
411 (define-abbrev-table 'c++-mode-abbrev-table ())
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
412
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
413 (defvar c++-mode-map ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
414 "Keymap used in c++-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
415 (if c++-mode-map
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
416 nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
417 (setq c++-mode-map (c-make-inherited-keymap))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
418 ;; add bindings which are only useful for C++
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
419 (define-key c++-mode-map "\C-c:" 'c-scope-operator)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
420 (define-key c++-mode-map "/" 'c-electric-slash)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
421 (define-key c++-mode-map "<" 'c-electric-lt-gt)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
422 (define-key c++-mode-map ">" 'c-electric-lt-gt))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
423
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
424 (defvar c++-mode-syntax-table nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
425 "Syntax table used in c++-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
426 (if c++-mode-syntax-table
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
427 ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
428 (setq c++-mode-syntax-table (make-syntax-table))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
429 (c-populate-syntax-table c++-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
430 ;; add extra comment syntax
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
431 (c-setup-dual-comments c++-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
432 ;; TBD: does it make sense for colon to be symbol class in C++?
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
433 ;; I'm not so sure, since c-label-key is busted on lines like:
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
434 ;; Foo::bar( i );
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
435 ;; maybe c-label-key should be fixed instead of commenting this out,
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
436 ;; but it also bothers me that this only seems appropriate for C++
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
437 ;; and not C.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
438 ;;(modify-syntax-entry ?: "_" c++-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
439 )
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
440
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
441
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
442
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
443 ;; Support for Objective-C
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
444
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
445 (defvar objc-mode-abbrev-table nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
446 "Abbrev table in use in objc-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
447 (define-abbrev-table 'objc-mode-abbrev-table ())
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
448
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
449 (defvar objc-mode-map ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
450 "Keymap used in objc-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
451 (if objc-mode-map
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
452 nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
453 (setq objc-mode-map (c-make-inherited-keymap))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
454 ;; add bindings which are only useful for Objective-C
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
455 (define-key objc-mode-map "/" 'c-electric-slash))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
456
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
457 (defvar objc-mode-syntax-table nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
458 "Syntax table used in objc-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
459 (if objc-mode-syntax-table
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
460 ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
461 (setq objc-mode-syntax-table (make-syntax-table))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
462 (c-populate-syntax-table objc-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
463 ;; add extra comment syntax
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
464 (c-setup-dual-comments objc-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
465 ;; everyone gets these
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
466 (modify-syntax-entry ?@ "_" objc-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
467 )
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
468
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
469
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
470
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
471 ;; Support for Java
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
472
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
473 (defvar java-mode-abbrev-table nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
474 "Abbrev table in use in java-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
475 (define-abbrev-table 'java-mode-abbrev-table ())
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
476
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
477 (defvar java-mode-map ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
478 "Keymap used in java-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
479 (if java-mode-map
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
480 nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
481 (setq java-mode-map (c-make-inherited-keymap))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
482 ;; add bindings which are only useful for Java
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
483 (define-key java-mode-map "/" 'c-electric-slash))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
484
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
485 (defvar java-mode-syntax-table nil
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
486 "Syntax table used in java-mode buffers.")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
487 (if java-mode-syntax-table
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
488 ()
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
489 (setq java-mode-syntax-table (make-syntax-table))
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
490 (c-populate-syntax-table java-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
491 ;; add extra comment syntax
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
492 (c-setup-dual-comments java-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
493 ;; everyone gets these
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
494 (modify-syntax-entry ?@ "_" java-mode-syntax-table)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
495 )
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
496
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
497
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
498
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
499 (provide 'cc-langs)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents:
diff changeset
500 ;;; cc-langs.el ends here