annotate lisp/progmodes/cc-langs.el @ 20376:67f1753dc577

(message): Declare a as char *[3].
author Andreas Schwab <schwab@suse.de>
date Fri, 28 Nov 1997 14:34:52 +0000
parents 1a85b213eb6d
children c746c93c9c95
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-langs.el --- specific language support for CC Mode
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Authors: 1992-1997 Barry A. Warsaw
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; 1987 Dave Detlefs and Stewart Clamen
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; 1985 Richard M. Stallman
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Maintainer: cc-mode-help@python.org
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; Created: 22-Apr-1997 (split from cc-mode.el)
20141
1a85b213eb6d Remove version number.
Karl Heuer <kwzh@gnu.org>
parents: 20138
diff changeset
10 ;; Version: See cc-mode.el
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; Keywords: c languages oop
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; This file is part of GNU Emacs.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; 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
17 ;; the Free Software Foundation; either version 2, or (at your option)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; any later version.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU Emacs is distributed in the hope that it will be useful,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; GNU General Public License for more details.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; You should have received a copy of the GNU General Public License
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; 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
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; Boston, MA 02111-1307, USA.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
18842
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
30 (require 'cc-defs)
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
31
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
18772
d8ccd2413041 Require cc-defs.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
33 (require 'cc-defs)
d8ccd2413041 Require cc-defs.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
34
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; Regular expressions and other values which must be parameterized on
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; a per-language basis.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; Keywords defining protection levels
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (defconst c-protection-key "\\<\\(public\\|protected\\|private\\)\\>")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
18842
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
41 ;; Regex describing a `symbol' in all languages. We cannot use just
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; `word' syntax class since `_' cannot be in word class. Putting
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; underscore in word class breaks forward word movement behavior that
18842
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
44 ;; users are familiar with. Besides, this runs counter to Emacs
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
45 ;; convention.
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
46 ;;
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
47 ;; I suspect this definition isn't correct in light of Java's
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
48 ;; definition of a symbol as being Unicode. I know so little about
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
49 ;; I18N (except how to sound cool and say I18N :-) that I'm willing to
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
50 ;; punt on this for now.
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
51
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
52 (defconst c-symbol-key "[_a-zA-Z]\\(\\w\\|\\s_\\)*")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; keywords introducing class definitions. language specific
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (defconst c-C-class-key "\\(struct\\|union\\)")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (defconst c-C++-class-key "\\(class\\|struct\\|union\\)")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (defconst c-ObjC-class-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (concat
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 "@\\(interface\\|implementation\\)\\s +"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 c-symbol-key ;name of the class
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 "\\(\\s *:\\s *" c-symbol-key "\\)?" ;maybe followed by the superclass
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 "\\(\\s *<[^>]+>\\)?" ;and maybe the adopted protocols list
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (defconst c-Java-class-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (concat
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 "\\(" c-protection-key "\\s +\\)?"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 "\\(interface\\|class\\)\\s +"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 c-symbol-key ;name of the class
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 "\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;;"\\(\\s *implements *[^{]+{\\)?" ;maybe the adopted protocols list
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (defvar c-class-key c-C-class-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (make-variable-buffer-local 'c-class-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; regexp describing access protection clauses. language specific
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (defvar c-access-key nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (make-variable-buffer-local 'c-access-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (defconst c-C++-access-key (concat c-protection-key "[ \t]*:"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (defconst c-ObjC-access-key (concat "@" c-protection-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (defconst c-Java-access-key nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; keywords introducing conditional blocks
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (defconst c-C-conditional-key nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (defconst c-C++-conditional-key nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (defconst c-Java-conditional-key nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (let ((all-kws "for\\|if\\|do\\|else\\|while\\|switch")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (exc-kws "\\|try\\|catch")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (thr-kws "\\|finally\\|synchronized")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (front "\\b\\(")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (back "\\)\\b[^_]"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (setq c-C-conditional-key (concat front all-kws back)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 c-C++-conditional-key (concat front all-kws exc-kws back)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 c-Java-conditional-key (concat front all-kws exc-kws thr-kws back)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (defvar c-conditional-key c-C-conditional-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (make-variable-buffer-local 'c-conditional-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; keywords describing method definition introductions
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (defvar c-method-key nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (make-variable-buffer-local 'c-method-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (defconst c-ObjC-method-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (concat
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 "^\\s *[+-]\\s *"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 "\\(([^)]*)\\)?" ; return type
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ;; \\s- in objc syntax table does not include \n
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;; since it is considered the end of //-comments.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 "[ \t\n]*" c-symbol-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (defconst c-Java-method-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (concat
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 "^\\s *[+-]\\s *"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 "\\(([^)]*)\\)?" ; return type
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; \\s- in java syntax table does not include \n
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;; since it is considered the end of //-comments.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 "[ \t\n]*" c-symbol-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; comment starter definitions for various languages. language specific
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (defconst c-C++-comment-start-regexp "/[/*]")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;; We need to match all 3 Java style comments
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;; 1) Traditional C block; 2) javadoc /** ...; 3) C++ style
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (defconst c-Java-comment-start-regexp "/\\(/\\|[*][*]?\\)")
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
132 (defvar c-comment-start-regexp c-C++-comment-start-regexp)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (make-variable-buffer-local 'c-comment-start-regexp)
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
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; Regexp describing a switch's case or default label for all languages
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (defconst c-switch-label-key "\\(\\(case[( \t]+\\S .*\\)\\|default[ \t]*\\):")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; Regexp describing any label.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (defconst c-label-key (concat c-symbol-key ":\\([^:]\\|$\\)"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;; Regexp describing class inheritance declarations. TBD: this should
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;; be language specific, and only makes sense for C++
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (defconst c-inher-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (concat "\\(\\<static\\>\\s +\\)?"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 c-C++-class-key "[ \t]+" c-symbol-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 "\\([ \t]*:[ \t]*\\)\\s *[^;]"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;; Regexp describing C++ base classes in a derived class definition.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ;; TBD: this should be language specific, and only makes sense for C++
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (defvar c-baseclass-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (concat
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ":?[ \t]*\\(virtual[ \t]+\\)?\\("
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 c-protection-key "[ \t]+\\)" c-symbol-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (make-variable-buffer-local 'c-baseclass-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;; Regexp describing friend declarations in C++ classes.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (defconst c-C++-friend-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 "friend[ \t]+\\|template[ \t]*<.+>[ \t]*friend[ \t]+")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ;; Regexp describing Java inheritance and throws clauses.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (defconst c-Java-special-key "\\(implements\\|extends\\|throws\\)[^_]")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ;; Regexp describing the beginning of a Java top-level definition.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (defconst c-Java-defun-prompt-regexp
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 "^[ \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-*")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167
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
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ;; internal state variables
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 ;; Internal state of hungry delete key feature
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (defvar c-hungry-delete-key nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (make-variable-buffer-local 'c-hungry-delete-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 ;; Internal state of auto newline feature.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (defvar c-auto-newline nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (make-variable-buffer-local 'c-auto-newline)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 ;; Internal auto-newline/hungry-delete designation string for mode line.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (defvar c-auto-hungry-string nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (make-variable-buffer-local 'c-auto-hungry-string)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 ;; Non-nil means K&R style argument declarations are valid.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (defvar c-recognize-knr-p t)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (make-variable-buffer-local 'c-recognize-knr-p)
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
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (defun c-use-java-style ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 "Institutes `java' indentation style.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 For use with the variable `java-mode-hook'."
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (c-set-style "java"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (defun c-common-init ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 ;; Common initializations for all modes.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 ;; these variables should always be buffer local; they do not affect
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 ;; indentation style.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (make-local-variable 'paragraph-start)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (make-local-variable 'paragraph-separate)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (make-local-variable 'paragraph-ignore-fill-prefix)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (make-local-variable 'require-final-newline)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (make-local-variable 'parse-sexp-ignore-comments)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (make-local-variable 'indent-line-function)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (make-local-variable 'indent-region-function)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (make-local-variable 'comment-start)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (make-local-variable 'comment-end)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (make-local-variable 'comment-column)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (make-local-variable 'comment-start-skip)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (make-local-variable 'comment-multi-line)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (make-local-variable 'outline-regexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (make-local-variable 'outline-level)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (make-local-variable 'adaptive-fill-regexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (make-local-variable 'imenu-generic-expression) ;set in the mode functions
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
215 ;; X/Emacs 20 only
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
216 (and (boundp 'comment-line-break-function)
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
217 (make-local-variable 'comment-line-break-function))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 ;; Emacs 19.30 and beyond only, AFAIK
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (if (boundp 'fill-paragraph-function)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (make-local-variable 'fill-paragraph-function)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (setq fill-paragraph-function 'c-fill-paragraph)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 ;; now set their values
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (setq paragraph-start (concat page-delimiter "\\|$")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 paragraph-separate paragraph-start
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 paragraph-ignore-fill-prefix t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 require-final-newline t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 parse-sexp-ignore-comments t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 indent-line-function 'c-indent-line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 indent-region-function 'c-indent-region
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 outline-regexp "[^#\n\^M]"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 outline-level 'c-outline-level
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 comment-column 32
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 comment-start-skip "/\\*+ *\\|// *"
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
235 comment-multi-line nil
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
236 comment-line-break-function 'c-comment-line-break-function
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 adaptive-fill-regexp nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 ;; we have to do something special for c-offsets-alist so that the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 ;; buffer local value has its own alist structure.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (setq c-offsets-alist (copy-alist c-offsets-alist))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 ;; setup the comment indent variable in a Emacs version portable way
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 ;; ignore any byte compiler warnings you might get here
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (make-local-variable 'comment-indent-function)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (setq comment-indent-function 'c-comment-indent)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 ;; add menus to menubar
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (easy-menu-add (c-mode-menu mode-name))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 ;; put auto-hungry designators onto minor-mode-alist, but only once
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (or (assq 'c-auto-hungry-string minor-mode-alist)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (setq minor-mode-alist
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (cons '(c-auto-hungry-string c-auto-hungry-string)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 minor-mode-alist))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (defun c-postprocess-file-styles ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 "Function that post processes relevant file local variables.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 Currently, this function simply applies any style and offset settings
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 found in the file's Local Variable list. It first applies any style
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 setting found in `c-file-style', then it applies any offset settings
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 it finds in `c-file-offsets'."
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 ;; apply file styles and offsets
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (and c-file-style
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (c-set-style c-file-style))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (and c-file-offsets
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (mapcar
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (function
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (lambda (langentry)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (let ((langelem (car langentry))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (offset (cdr langentry)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (c-set-offset langelem offset)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 c-file-offsets)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 ;; Common routines
18842
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
276 (defun c-make-inherited-keymap ()
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (let ((map (make-sparse-keymap)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 ;; XEmacs 19 & 20
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 ((fboundp 'set-keymap-parents)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (set-keymap-parents map c-mode-base-map))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 ;; Emacs 19
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 ((fboundp 'set-keymap-parent)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (set-keymap-parent map c-mode-base-map))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 ;; incompatible
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (t (error "CC Mode is incompatible with this version of Emacs")))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 map))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (defun c-populate-syntax-table (table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 ;; Populate the syntax TABLE
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS!
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (modify-syntax-entry ?_ "_" table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (modify-syntax-entry ?\\ "\\" table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (modify-syntax-entry ?+ "." table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (modify-syntax-entry ?- "." table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (modify-syntax-entry ?= "." table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (modify-syntax-entry ?% "." table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (modify-syntax-entry ?< "." table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (modify-syntax-entry ?> "." table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (modify-syntax-entry ?& "." table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (modify-syntax-entry ?| "." table)
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
302 (modify-syntax-entry ?\' "\"" table)
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
303 ;; Set up block and line oriented comments. The new C standard
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
304 ;; mandates both comment styles even in C, so since all languages
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
305 ;; now require dual comments, we make this the default.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 ;; XEmacs 19 & 20
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 ((memq '8-bit c-emacs-features)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (modify-syntax-entry ?/ ". 1456" table)
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
310 (modify-syntax-entry ?* ". 23" table))
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
311 ;; Emacs 19 & 20
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 ((memq '1-bit c-emacs-features)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (modify-syntax-entry ?/ ". 124b" table)
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
314 (modify-syntax-entry ?* ". 23" table))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 ;; incompatible
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (t (error "CC Mode is incompatible with this version of Emacs"))
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
317 )
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
318 (modify-syntax-entry ?\n "> b" table)
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
319 ;; Give CR the same syntax as newline, for selective-display
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
320 (modify-syntax-entry ?\^m "> b" table))
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
321
18720
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 (defvar c-mode-base-map ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 "Keymap shared by all CC Mode related modes.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (if c-mode-base-map
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 ;; TBD: should we even worry about naming this keymap. My vote: no,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 ;; because Emacs and XEmacs do it differently.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (setq c-mode-base-map (make-sparse-keymap))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 ;; put standard keybindings into MAP
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 ;; the following mappings correspond more or less directly to BOCM
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (define-key c-mode-base-map "{" 'c-electric-brace)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (define-key c-mode-base-map "}" 'c-electric-brace)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (define-key c-mode-base-map ";" 'c-electric-semi&comma)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (define-key c-mode-base-map "#" 'c-electric-pound)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (define-key c-mode-base-map ":" 'c-electric-colon)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 ;; Lucid Emacs 19.9 defined these two, the second of which was
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 ;; commented out...
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 ;; (define-key c-mode-base-map "\e{" 'c-insert-braces)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 ;; Commented out electric square brackets because nobody likes them.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 ;; (define-key c-mode-base-map "[" 'c-insert-brackets)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (define-key c-mode-base-map "\C-c\C-m" 'c-mark-function)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (define-key c-mode-base-map "\e\C-q" 'c-indent-exp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (define-key c-mode-base-map "\ea" 'c-beginning-of-statement)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (define-key c-mode-base-map "\ee" 'c-end-of-statement)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (define-key c-mode-base-map "\C-c\C-n" 'c-forward-conditional)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (define-key c-mode-base-map "\C-c\C-p" 'c-backward-conditional)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (define-key c-mode-base-map "\C-c\C-u" 'c-up-conditional)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (define-key c-mode-base-map "\t" 'c-indent-command)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 ;; Caution! Enter here at your own risk. We are trying to support
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 ;; several behaviors and it gets disgusting. :-(
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 ;;
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 ;; In XEmacs 19, Emacs 19, and Emacs 20, we use this to bind
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 ;; backwards deletion behavior to DEL, which both Delete and
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 ;; Backspace get translated to. There's no way to separate this
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 ;; behavior in a clean way, so deal with it! Besides, it's been
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 ;; this way since the dawn of BOCM.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 (if (not (boundp 'delete-key-deletes-forward))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (define-key c-mode-base-map "\177" 'c-electric-backspace)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 ;; However, XEmacs 20 actually achieved enlightenment. It is
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 ;; possible to sanely define both backward and forward deletion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 ;; behavior under X separately (TTYs are forever beyond hope, but
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 ;; who cares? XEmacs 20 does the right thing with these too).
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (define-key c-mode-base-map [delete] 'c-electric-delete)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (define-key c-mode-base-map [backspace] 'c-electric-backspace))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 ;; these are new keybindings, with no counterpart to BOCM
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (define-key c-mode-base-map "," 'c-electric-semi&comma)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (define-key c-mode-base-map "*" 'c-electric-star)
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
370 (define-key c-mode-base-map "/" 'c-electric-slash)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 ;; TBD: where if anywhere, to put c-backward|forward-into-nomenclature
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (define-key c-mode-base-map "\C-c\C-a" 'c-toggle-auto-state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (define-key c-mode-base-map "\C-c\C-b" 'c-submit-bug-report)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (define-key c-mode-base-map "\C-c\C-c" 'comment-region)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (define-key c-mode-base-map "\C-c\C-d" 'c-toggle-hungry-state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (define-key c-mode-base-map "\C-c\C-o" 'c-set-offset)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (define-key c-mode-base-map "\C-c\C-s" 'c-show-syntactic-information)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (define-key c-mode-base-map "\C-c\C-t" 'c-toggle-auto-hungry-state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (define-key c-mode-base-map "\C-c." 'c-set-style)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 ;; conflicts with OOBR
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 ;; menu support for both XEmacs and Emacs. If you don't have easymenu
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 ;; with your version of Emacs, you are incompatible!
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (require 'easymenu)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (defvar c-c-menu nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (defvar c-c++-menu nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (defvar c-objc-menu nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (defvar c-java-menu nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (defun c-mode-menu (modestr)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (let ((m
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 '(["Comment Out Region" comment-region (mark)]
18842
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
398 ["Uncomment Region"
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
399 (comment-region (region-beginning) (region-end) '(4))
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
400 (mark)]
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
401 ["Fill Comment Paragraph" c-fill-paragraph t]
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
402 "---"
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 ["Indent Expression" c-indent-exp
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (memq (char-after) '(?\( ?\[ ?\{))]
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ["Indent Line" c-indent-command t]
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 ["Up Conditional" c-up-conditional t]
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 ["Backward Conditional" c-backward-conditional t]
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 ["Forward Conditional" c-forward-conditional t]
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 ["Backward Statement" c-beginning-of-statement t]
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 ["Forward Statement" c-end-of-statement t]
18842
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
411 "---"
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
412 ["Macro Expand Region" c-macro-expand (mark)]
72c2475ece1c Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents: 18772
diff changeset
413 ["Backslashify" c-backslash-region (mark)]
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (cons modestr m)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 ;; Support for C
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (defvar c-mode-abbrev-table nil
19250
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
422 "Abbreviation table used in c-mode buffers.")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (define-abbrev-table 'c-mode-abbrev-table ())
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (defvar c-mode-map ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 "Keymap used in c-mode buffers.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (if c-mode-map
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (setq c-mode-map (c-make-inherited-keymap))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 ;; add bindings which are only useful for C
19805
e804ac04eec1 (c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents: 19381
diff changeset
431 (define-key c-mode-map "\C-c\C-e" 'c-macro-expand)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 ;;;###autoload
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (defvar c-mode-syntax-table nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 "Syntax table used in c-mode buffers.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (if c-mode-syntax-table
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (setq c-mode-syntax-table (make-syntax-table))
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
440 (c-populate-syntax-table c-mode-syntax-table))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (easy-menu-define c-c-menu c-mode-map "C Mode Commands"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (c-mode-menu "C"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 ;; Support for C++
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (defvar c++-mode-abbrev-table nil
19250
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
449 "Abbreviation table used in c++-mode buffers.")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (define-abbrev-table 'c++-mode-abbrev-table ())
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 (defvar c++-mode-map ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 "Keymap used in c++-mode buffers.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (if c++-mode-map
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (setq c++-mode-map (c-make-inherited-keymap))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 ;; add bindings which are only useful for C++
19805
e804ac04eec1 (c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents: 19381
diff changeset
458 (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand)
e804ac04eec1 (c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents: 19381
diff changeset
459 (define-key c++-mode-map "\C-c:" 'c-scope-operator)
e804ac04eec1 (c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents: 19381
diff changeset
460 (define-key c++-mode-map "<" 'c-electric-lt-gt)
e804ac04eec1 (c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents: 19381
diff changeset
461 (define-key c++-mode-map ">" 'c-electric-lt-gt))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
463 ;;;###autoload
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 (defvar c++-mode-syntax-table nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 "Syntax table used in c++-mode buffers.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (if c++-mode-syntax-table
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 (setq c++-mode-syntax-table (make-syntax-table))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 (c-populate-syntax-table c++-mode-syntax-table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 ;; TBD: does it make sense for colon to be symbol class in C++?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 ;; I'm not so sure, since c-label-key is busted on lines like:
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 ;; Foo::bar( i );
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 ;; maybe c-label-key should be fixed instead of commenting this out,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 ;; but it also bothers me that this only seems appropriate for C++
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 ;; and not C.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 ;;(modify-syntax-entry ?: "_" c++-mode-syntax-table)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (c-mode-menu "C++"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 ;; Support for Objective-C
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (defvar objc-mode-abbrev-table nil
19250
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
486 "Abbreviation table used in objc-mode buffers.")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (define-abbrev-table 'objc-mode-abbrev-table ())
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (defvar objc-mode-map ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 "Keymap used in objc-mode buffers.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (if objc-mode-map
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (setq objc-mode-map (c-make-inherited-keymap))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 ;; add bindings which are only useful for Objective-C
19805
e804ac04eec1 (c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents: 19381
diff changeset
495 (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
497 ;;;###autoload
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (defvar objc-mode-syntax-table nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 "Syntax table used in objc-mode buffers.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (if objc-mode-syntax-table
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (setq objc-mode-syntax-table (make-syntax-table))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (c-populate-syntax-table objc-mode-syntax-table)
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
504 ;; add extra Objective-C only syntax
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
505 (modify-syntax-entry ?@ "_" objc-mode-syntax-table))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (c-mode-menu "ObjC"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 ;; Support for Java
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (defvar java-mode-abbrev-table nil
19250
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
514 "Abbreviation table used in java-mode buffers.")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (define-abbrev-table 'java-mode-abbrev-table ())
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (defvar java-mode-map ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 "Keymap used in java-mode buffers.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (if java-mode-map
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (setq java-mode-map (c-make-inherited-keymap))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 ;; add bindings which are only useful for Java
19805
e804ac04eec1 (c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents: 19381
diff changeset
523 )
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
525 ;;;###autoload
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 (defvar java-mode-syntax-table nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 "Syntax table used in java-mode buffers.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (if java-mode-syntax-table
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 (setq java-mode-syntax-table (make-syntax-table))
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
531 (c-populate-syntax-table java-mode-syntax-table))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 (easy-menu-define c-java-menu java-mode-map "Java Mode Commands"
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 (c-mode-menu "Java"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536
19250
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
537 ;; Support for CORBA's IDL language
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
538
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
539 (defvar idl-mode-abbrev-table nil
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
540 "Abbreviation table used in idl-mode buffers.")
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
541 (define-abbrev-table 'idl-mode-abbrev-table ())
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
542
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
543 (defvar idl-mode-map ()
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
544 "Keymap used in idl-mode buffers.")
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
545 (if idl-mode-map
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
546 nil
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
547 (setq idl-mode-map (c-make-inherited-keymap))
19805
e804ac04eec1 (c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents: 19381
diff changeset
548 ;; add bindings which are only useful for IDL
e804ac04eec1 (c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents: 19381
diff changeset
549 )
19250
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
550
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
551 ;;;###autoload
19250
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
552 (defvar idl-mode-syntax-table nil
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
553 "Syntax table used in idl-mode buffers.")
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
554 (if idl-mode-syntax-table
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
555 nil
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
556 (setq idl-mode-syntax-table (make-syntax-table))
19300
b07fa43938cc (c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents: 19250
diff changeset
557 (c-populate-syntax-table idl-mode-syntax-table))
19250
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
558
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
559 (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands"
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
560 (c-mode-menu "IDL"))
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
561
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
562
23f71af4d504 (c-symbol-key):
Richard M. Stallman <rms@gnu.org>
parents: 18842
diff changeset
563
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (provide 'cc-langs)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 ;;; cc-langs.el ends here