Mercurial > emacs
annotate lisp/progmodes/cc-mode.el @ 39565:e03e925846db
Use facep iso find-face.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 05 Oct 2001 09:32:11 +0000 |
parents | 79039a33283a |
children | b89d0c514129 |
rev | line source |
---|---|
18720 | 1 ;;; cc-mode.el --- major mode for editing C, C++, Objective-C, and Java code |
2 | |
36920 | 3 ;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc. |
18720 | 4 |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5 ;; Authors: 2000- Martin Stjernholm |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6 ;; 1998-1999 Barry A. Warsaw and Martin Stjernholm |
24282 | 7 ;; 1992-1997 Barry A. Warsaw |
18720 | 8 ;; 1987 Dave Detlefs and Stewart Clamen |
9 ;; 1985 Richard M. Stallman | |
24282 | 10 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 11 ;; Created: a long, long, time ago. adapted from the original c-mode.el |
12 ;; Keywords: c languages oop | |
13 | |
14 ;; This file is part of GNU Emacs. | |
15 | |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
17 ;; it under the terms of the GNU General Public License as published by | |
18 ;; the Free Software Foundation; either version 2, or (at your option) | |
19 ;; any later version. | |
20 | |
21 ;; GNU Emacs is distributed in the hope that it will be useful, | |
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 ;; GNU General Public License for more details. | |
25 | |
26 ;; You should have received a copy of the GNU General Public License | |
36920 | 27 ;; along with this program; see the file COPYING. If not, write to |
28 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18720 | 29 ;; Boston, MA 02111-1307, USA. |
30 | |
36920 | 31 (defconst c-version "5.28" |
32 "CC Mode version number.") | |
33 | |
34 ;; NOTE: Read the commentary below for the right way to submit bug reports! | |
35 ;; NOTE: See the accompanying texinfo manual for details on using this mode! | |
36 | |
18720 | 37 ;;; Commentary: |
38 | |
39 ;; This package provides GNU Emacs major modes for editing C, C++, | |
24282 | 40 ;; Objective-C, Java, IDL and Pike code. As of the latest Emacs and |
41 ;; XEmacs releases, it is the default package for editing these | |
42 ;; languages. This package is called "CC Mode", and should be spelled | |
43 ;; exactly this way. | |
44 | |
45 ;; CC Mode supports K&R and ANSI C, ANSI C++, Objective-C, Java, | |
46 ;; CORBA's IDL, and Pike with a consistent indentation model across | |
47 ;; all modes. This indentation model is intuitive and very flexible, | |
48 ;; so that almost any desired style of indentation can be supported. | |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
49 ;; Installation, usage, and programming details are contained in an |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
50 ;; accompanying texinfo manual. |
18720 | 51 |
52 ;; CC Mode's immediate ancestors were, c++-mode.el, cplus-md.el, and | |
53 ;; cplus-md1.el.. | |
54 | |
55 ;; NOTE: This mode does not perform font-locking (a.k.a syntactic | |
56 ;; coloring, keyword highlighting, etc.) for any of the supported | |
57 ;; modes. Typically this is done by a package called font-lock.el | |
24282 | 58 ;; which we do *not* maintain. You should contact the Emacs or XEmacs |
18720 | 59 ;; maintainers for questions about coloring or highlighting in any |
60 ;; language mode. | |
61 | |
62 ;; To submit bug reports, type "C-c C-b". These will be sent to | |
24282 | 63 ;; bug-gnu-emacs@gnu.org (mirrored as the Usenet newsgroup |
64 ;; gnu.emacs.bug) as well as bug-cc-mode@gnu.org, which directly | |
65 ;; contacts the CC Mode maintainers. Questions can sent to | |
66 ;; help-gnu-emacs@gnu.org (mirrored as gnu.emacs.help) and/or | |
36920 | 67 ;; bug-cc-mode@gnu.org. Please do not send bugs or questions to our |
68 ;; personal accounts; we reserve the right to ignore such email! | |
18720 | 69 |
70 ;; Many, many thanks go out to all the folks on the beta test list. | |
71 ;; Without their patience, testing, insight, code contributions, and | |
72 ;; encouragement CC Mode would be a far inferior package. | |
73 | |
74 ;; You can get the latest version of CC Mode, including PostScript | |
75 ;; documentation and separate individual files from: | |
76 ;; | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
77 ;; http://cc-mode.sourceforge.net/ |
18720 | 78 ;; |
24282 | 79 ;; You can join a moderated CC Mode announcement-only mailing list by |
80 ;; visiting | |
81 ;; | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
82 ;; http://lists.sourceforge.net/mailman/listinfo/cc-mode-announce |
18720 | 83 |
84 ;;; Code: | |
85 | |
26817 | 86 (eval-when-compile |
87 (let ((load-path | |
36920 | 88 (if (and (boundp 'byte-compile-dest-file) |
89 (stringp byte-compile-dest-file)) | |
90 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 91 load-path))) |
36920 | 92 (require 'cc-bytecomp))) |
21109
a0eda86dd0be
(c-initialize-cc-mode): Moved require's to top level.
Richard M. Stallman <rms@gnu.org>
parents:
20917
diff
changeset
|
93 |
36920 | 94 (cc-require 'cc-defs) |
95 (cc-require 'cc-menus) | |
96 (cc-require 'cc-vars) | |
97 (cc-require 'cc-langs) | |
98 (cc-require 'cc-styles) | |
99 (cc-require 'cc-engine) | |
100 (cc-require 'cc-cmds) | |
101 (cc-require 'cc-align) | |
102 | |
103 ;; Silence the compiler. | |
104 (cc-bytecomp-defvar comment-line-break-function) ; (X)Emacs 20+ | |
105 (cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs 20+ | |
106 (cc-bytecomp-defun set-keymap-parents) ; XEmacs | |
107 | |
108 ;; Menu support for both XEmacs and Emacs. If you don't have easymenu | |
109 ;; with your version of Emacs, you are incompatible! | |
110 (require 'easymenu) | |
18720 | 111 |
112 | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
113 ;; Other modes and packages which depend on CC Mode should do the |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
114 ;; following to make sure everything is loaded and available for their |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
115 ;; use: |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
116 ;; |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
117 ;; (require 'cc-mode) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
118 ;; (c-initialize-cc-mode) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
119 |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
120 ;;;###autoload |
24282 | 121 (defun c-initialize-cc-mode () |
19299
7cd7373cc021
(c-initialize-cc-mode): Set c-buffer-is-cc-mode to t.
Richard M. Stallman <rms@gnu.org>
parents:
19253
diff
changeset
|
122 (setq c-buffer-is-cc-mode t) |
24282 | 123 (let ((initprop 'cc-mode-is-initialized) |
124 c-initialization-ok) | |
125 (unless (get 'c-initialize-cc-mode initprop) | |
126 (unwind-protect | |
127 (progn | |
26817 | 128 (put 'c-initialize-cc-mode initprop t) |
129 (c-initialize-builtin-style) | |
24282 | 130 (run-hooks 'c-initialization-hook) |
26817 | 131 ;; Fix obsolete variables. |
132 (if (boundp 'c-comment-continuation-stars) | |
133 (setq c-block-comment-prefix c-comment-continuation-stars)) | |
24282 | 134 (setq c-initialization-ok t)) |
135 ;; Will try initialization hooks again if they failed. | |
26817 | 136 (put 'c-initialize-cc-mode initprop c-initialization-ok))) |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
137 )) |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
138 |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
139 |
36920 | 140 ;; Common routines |
141 (defvar c-mode-base-map () | |
142 "Keymap shared by all CC Mode related modes.") | |
143 | |
144 (defun c-make-inherited-keymap () | |
145 (let ((map (make-sparse-keymap))) | |
146 (cond | |
147 ;; XEmacs 19 & 20 | |
148 ((fboundp 'set-keymap-parents) | |
149 (set-keymap-parents map c-mode-base-map)) | |
150 ;; Emacs 19 | |
151 ((fboundp 'set-keymap-parent) | |
152 (set-keymap-parent map c-mode-base-map)) | |
153 ;; incompatible | |
154 (t (error "CC Mode is incompatible with this version of Emacs"))) | |
155 map)) | |
156 | |
157 (if c-mode-base-map | |
158 nil | |
159 ;; TBD: should we even worry about naming this keymap. My vote: no, | |
160 ;; because Emacs and XEmacs do it differently. | |
161 (setq c-mode-base-map (make-sparse-keymap)) | |
162 ;; put standard keybindings into MAP | |
163 ;; the following mappings correspond more or less directly to BOCM | |
164 (define-key c-mode-base-map "{" 'c-electric-brace) | |
165 (define-key c-mode-base-map "}" 'c-electric-brace) | |
166 (define-key c-mode-base-map ";" 'c-electric-semi&comma) | |
167 (define-key c-mode-base-map "#" 'c-electric-pound) | |
168 (define-key c-mode-base-map ":" 'c-electric-colon) | |
169 (define-key c-mode-base-map "(" 'c-electric-paren) | |
170 (define-key c-mode-base-map ")" 'c-electric-paren) | |
171 ;; Separate M-BS from C-M-h. The former should remain | |
172 ;; backward-kill-word. | |
173 (define-key c-mode-base-map [(control meta h)] 'c-mark-function) | |
174 (define-key c-mode-base-map "\e\C-q" 'c-indent-exp) | |
175 (substitute-key-definition 'backward-sentence | |
176 'c-beginning-of-statement | |
177 c-mode-base-map global-map) | |
178 (substitute-key-definition 'forward-sentence | |
179 'c-end-of-statement | |
180 c-mode-base-map global-map) | |
181 (substitute-key-definition 'indent-new-comment-line | |
182 'c-indent-new-comment-line | |
183 c-mode-base-map global-map) | |
184 ;; RMS says don't make these the default. | |
185 ;; (define-key c-mode-base-map "\e\C-a" 'c-beginning-of-defun) | |
186 ;; (define-key c-mode-base-map "\e\C-e" 'c-end-of-defun) | |
187 (define-key c-mode-base-map "\C-c\C-n" 'c-forward-conditional) | |
188 (define-key c-mode-base-map "\C-c\C-p" 'c-backward-conditional) | |
189 (define-key c-mode-base-map "\C-c\C-u" 'c-up-conditional) | |
190 (substitute-key-definition 'indent-for-tab-command | |
191 'c-indent-command | |
192 c-mode-base-map global-map) | |
193 ;; It doesn't suffice to put c-fill-paragraph on | |
194 ;; fill-paragraph-function due to the way it works. | |
195 (substitute-key-definition 'fill-paragraph 'c-fill-paragraph | |
196 c-mode-base-map global-map) | |
197 ;; In XEmacs the default fill function is called | |
198 ;; fill-paragraph-or-region. | |
199 (substitute-key-definition 'fill-paragraph-or-region 'c-fill-paragraph | |
200 c-mode-base-map global-map) | |
37563
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
201 ;; Bind the electric deletion functions to C-d and DEL. Emacs 21 |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
202 ;; automatically maps the [delete] and [backspace] keys to these two |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
203 ;; depending on window system and user preferences. (In earlier |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
204 ;; versions it's possible to do the same by using `function-key-map'.) |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
205 (define-key c-mode-base-map "\C-d" 'c-electric-delete-forward) |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
206 (define-key c-mode-base-map "\177" 'c-electric-backspace) |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
207 (when (boundp 'delete-key-deletes-forward) |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
208 ;; In XEmacs 20 and later we fix the forward and backward deletion |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
209 ;; behavior by binding the keysyms for the [delete] and |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
210 ;; [backspace] keys directly, and use `delete-forward-p' or |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
211 ;; `delete-key-deletes-forward' to decide what [delete] should do. |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
212 (define-key c-mode-base-map [delete] 'c-electric-delete) |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
213 (define-key c-mode-base-map [backspace] 'c-electric-backspace)) |
36920 | 214 ;; these are new keybindings, with no counterpart to BOCM |
215 (define-key c-mode-base-map "," 'c-electric-semi&comma) | |
216 (define-key c-mode-base-map "*" 'c-electric-star) | |
217 (define-key c-mode-base-map "/" 'c-electric-slash) | |
218 (define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun) | |
219 (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region) | |
220 ;; TBD: where if anywhere, to put c-backward|forward-into-nomenclature | |
221 (define-key c-mode-base-map "\C-c\C-a" 'c-toggle-auto-state) | |
222 (define-key c-mode-base-map "\C-c\C-b" 'c-submit-bug-report) | |
223 (define-key c-mode-base-map "\C-c\C-c" 'comment-region) | |
224 (define-key c-mode-base-map "\C-c\C-d" 'c-toggle-hungry-state) | |
225 (define-key c-mode-base-map "\C-c\C-o" 'c-set-offset) | |
226 (define-key c-mode-base-map "\C-c\C-s" 'c-show-syntactic-information) | |
227 (define-key c-mode-base-map "\C-c\C-t" 'c-toggle-auto-hungry-state) | |
228 (define-key c-mode-base-map "\C-c." 'c-set-style) | |
229 ;; conflicts with OOBR | |
230 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version) | |
231 ) | |
232 | |
233 (defvar c-c-menu nil) | |
234 (defvar c-c++-menu nil) | |
235 (defvar c-objc-menu nil) | |
236 (defvar c-java-menu nil) | |
237 (defvar c-pike-menu nil) | |
238 | |
239 (defun c-mode-menu (modestr) | |
240 (let ((m | |
241 '(["Comment Out Region" comment-region (c-fn-region-is-active-p)] | |
242 ["Uncomment Region" | |
243 (comment-region (region-beginning) (region-end) '(4)) | |
244 (c-fn-region-is-active-p)] | |
245 ["Fill Comment Paragraph" c-fill-paragraph t] | |
246 "---" | |
247 ["Indent Expression" c-indent-exp | |
248 (memq (char-after) '(?\( ?\[ ?\{))] | |
249 ["Indent Line or Region" c-indent-line-or-region t] | |
250 ["Up Conditional" c-up-conditional t] | |
251 ["Backward Conditional" c-backward-conditional t] | |
252 ["Forward Conditional" c-forward-conditional t] | |
253 ["Backward Statement" c-beginning-of-statement t] | |
254 ["Forward Statement" c-end-of-statement t] | |
255 "---" | |
256 ["Macro Expand Region" c-macro-expand (c-fn-region-is-active-p)] | |
257 ["Backslashify" c-backslash-region | |
258 (c-fn-region-is-active-p)] | |
259 ))) | |
260 (cons modestr m))) | |
261 | |
262 ;; We don't require the outline package, but we configure it a bit anyway. | |
263 (cc-bytecomp-defvar outline-level) | |
264 | |
265 (defun c-common-init () | |
266 ;; Common initializations for all modes. | |
267 ;; these variables should always be buffer local; they do not affect | |
268 ;; indentation style. | |
269 (make-local-variable 'require-final-newline) | |
270 (make-local-variable 'parse-sexp-ignore-comments) | |
271 (make-local-variable 'indent-line-function) | |
272 (make-local-variable 'indent-region-function) | |
273 (make-local-variable 'outline-regexp) | |
274 (make-local-variable 'outline-level) | |
275 (make-local-variable 'normal-auto-fill-function) | |
276 (make-local-variable 'comment-start) | |
277 (make-local-variable 'comment-end) | |
278 (make-local-variable 'comment-column) | |
279 (make-local-variable 'comment-start-skip) | |
280 (make-local-variable 'comment-multi-line) | |
281 (make-local-variable 'paragraph-start) | |
282 (make-local-variable 'paragraph-separate) | |
283 (make-local-variable 'paragraph-ignore-fill-prefix) | |
284 (make-local-variable 'adaptive-fill-mode) | |
285 (make-local-variable 'adaptive-fill-regexp) | |
286 (make-local-variable 'imenu-generic-expression) ;set in the mode functions | |
287 ;; X/Emacs 20 only | |
288 (and (boundp 'comment-line-break-function) | |
289 (progn | |
290 (make-local-variable 'comment-line-break-function) | |
291 (setq comment-line-break-function | |
292 'c-indent-new-comment-line))) | |
293 ;; now set their values | |
294 (setq require-final-newline t | |
295 parse-sexp-ignore-comments t | |
296 indent-line-function 'c-indent-line | |
297 indent-region-function 'c-indent-region | |
298 outline-regexp "[^#\n\^M]" | |
299 outline-level 'c-outline-level | |
300 normal-auto-fill-function 'c-do-auto-fill | |
301 comment-column 32 | |
302 comment-start-skip "/\\*+ *\\|//+ *" | |
303 comment-multi-line t) | |
304 ;; now set the mode style based on c-default-style | |
305 (let ((style (if (stringp c-default-style) | |
306 c-default-style | |
307 (or (cdr (assq major-mode c-default-style)) | |
308 (cdr (assq 'other c-default-style)) | |
309 "gnu")))) | |
310 ;; Override style variables if `c-old-style-variable-behavior' is | |
311 ;; set. Also override if we are using global style variables, | |
312 ;; have already initialized a style once, and are switching to a | |
313 ;; different style. (It's doubtful whether this is desirable, but | |
314 ;; the whole situation with nonlocal style variables is a bit | |
315 ;; awkward. It's at least the most compatible way with the old | |
316 ;; style init procedure.) | |
317 (c-set-style style (not (or c-old-style-variable-behavior | |
318 (and (not c-style-variables-are-local-p) | |
319 c-indentation-style | |
320 (not (string-equal c-indentation-style | |
321 style))))))) | |
322 ;; Fix things up for paragraph recognition and filling inside | |
323 ;; comments by using c-current-comment-prefix in the relevant | |
324 ;; places. We use adaptive filling for this to make it possible to | |
325 ;; use filladapt or some other fancy package. | |
326 (setq c-current-comment-prefix | |
327 (if (listp c-comment-prefix-regexp) | |
328 (cdr-safe (or (assoc major-mode c-comment-prefix-regexp) | |
329 (assoc 'other c-comment-prefix-regexp))) | |
330 c-comment-prefix-regexp)) | |
331 (let ((comment-line-prefix | |
332 (concat "[ \t]*\\(" c-current-comment-prefix "\\)[ \t]*"))) | |
333 (setq paragraph-start (concat comment-line-prefix | |
334 c-append-paragraph-start | |
335 "\\|" | |
336 page-delimiter) | |
337 paragraph-separate (concat comment-line-prefix | |
338 c-append-paragraph-separate | |
339 "\\|" | |
340 page-delimiter) | |
341 paragraph-ignore-fill-prefix t | |
342 adaptive-fill-mode t | |
343 adaptive-fill-regexp | |
344 (concat comment-line-prefix | |
345 (if adaptive-fill-regexp | |
346 (concat "\\(" adaptive-fill-regexp "\\)") | |
347 ""))) | |
348 (when (boundp 'adaptive-fill-first-line-regexp) | |
349 ;; XEmacs (20.x) adaptive fill mode doesn't have this. | |
350 (make-local-variable 'adaptive-fill-first-line-regexp) | |
351 (setq adaptive-fill-first-line-regexp | |
352 (concat "\\`" comment-line-prefix | |
353 ;; Maybe we should incorporate the old value here, | |
354 ;; but then we have to do all sorts of kludges to | |
355 ;; deal with the \` and \' it probably contains. | |
356 "\\'")))) | |
357 ;; we have to do something special for c-offsets-alist so that the | |
358 ;; buffer local value has its own alist structure. | |
359 (setq c-offsets-alist (copy-alist c-offsets-alist)) | |
360 ;; setup the comment indent variable in a Emacs version portable way | |
361 ;; ignore any byte compiler warnings you might get here | |
362 (make-local-variable 'comment-indent-function) | |
363 (setq comment-indent-function 'c-comment-indent) | |
364 ;; add menus to menubar | |
365 (easy-menu-add (c-mode-menu mode-name)) | |
366 ;; put auto-hungry designators onto minor-mode-alist, but only once | |
367 (or (assq 'c-auto-hungry-string minor-mode-alist) | |
368 (setq minor-mode-alist | |
369 (cons '(c-auto-hungry-string c-auto-hungry-string) | |
370 minor-mode-alist))) | |
371 ) | |
372 | |
373 (defun c-postprocess-file-styles () | |
374 "Function that post processes relevant file local variables. | |
375 Currently, this function simply applies any style and offset settings | |
376 found in the file's Local Variable list. It first applies any style | |
377 setting found in `c-file-style', then it applies any offset settings | |
378 it finds in `c-file-offsets'. | |
379 | |
380 Note that the style variables are always made local to the buffer." | |
381 ;; apply file styles and offsets | |
382 (if (or c-file-style c-file-offsets) | |
383 (c-make-styles-buffer-local t)) | |
384 (and c-file-style | |
385 (c-set-style c-file-style)) | |
386 (and c-file-offsets | |
387 (mapcar | |
388 (function | |
389 (lambda (langentry) | |
390 (let ((langelem (car langentry)) | |
391 (offset (cdr langentry))) | |
392 (c-set-offset langelem offset) | |
393 ))) | |
394 c-file-offsets))) | |
395 | |
396 (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles) | |
397 | |
398 | |
399 ;; Support for C | |
400 | |
401 (defvar c-mode-abbrev-table nil | |
402 "Abbreviation table used in c-mode buffers.") | |
403 (define-abbrev-table 'c-mode-abbrev-table | |
404 '(("else" "else" c-electric-continued-statement 0) | |
405 ("while" "while" c-electric-continued-statement 0))) | |
406 | |
407 (defvar c-mode-map () | |
408 "Keymap used in c-mode buffers.") | |
409 (if c-mode-map | |
410 nil | |
411 (setq c-mode-map (c-make-inherited-keymap)) | |
412 ;; add bindings which are only useful for C | |
413 (define-key c-mode-map "\C-c\C-e" 'c-macro-expand) | |
414 ) | |
415 | |
416 (easy-menu-define c-c-menu c-mode-map "C Mode Commands" | |
417 (c-mode-menu "C")) | |
418 | |
18720 | 419 ;;;###autoload |
420 (defun c-mode () | |
421 "Major mode for editing K&R and ANSI C code. | |
422 To submit a problem report, enter `\\[c-submit-bug-report]' from a | |
423 c-mode buffer. This automatically sets up a mail buffer with version | |
424 information already added. You just need to add a description of the | |
425 problem, including a reproducible test case and send the message. | |
426 | |
427 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
428 | |
429 The hook variable `c-mode-hook' is run with no args, if that value is | |
430 bound and has a non-nil value. Also the hook `c-mode-common-hook' is | |
431 run first. | |
432 | |
433 Key bindings: | |
434 \\{c-mode-map}" | |
435 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
436 (c-initialize-cc-mode) |
18720 | 437 (kill-all-local-variables) |
438 (set-syntax-table c-mode-syntax-table) | |
439 (setq major-mode 'c-mode | |
440 mode-name "C" | |
36920 | 441 local-abbrev-table c-mode-abbrev-table |
442 abbrev-mode t) | |
18720 | 443 (use-local-map c-mode-map) |
444 (c-common-init) | |
445 (setq comment-start "/* " | |
446 comment-end " */" | |
36920 | 447 c-keywords (c-identifier-re c-C-keywords) |
18720 | 448 c-conditional-key c-C-conditional-key |
449 c-class-key c-C-class-key | |
450 c-baseclass-key nil | |
26817 | 451 c-comment-start-regexp c-C-comment-start-regexp |
452 c-bitfield-key c-C-bitfield-key | |
24282 | 453 ) |
26817 | 454 (cc-imenu-init cc-imenu-c-generic-expression) |
18720 | 455 (run-hooks 'c-mode-common-hook) |
456 (run-hooks 'c-mode-hook) | |
457 (c-update-modeline)) | |
458 | |
459 | |
36920 | 460 ;; Support for C++ |
461 | |
462 (defvar c++-mode-abbrev-table nil | |
463 "Abbreviation table used in c++-mode buffers.") | |
464 (define-abbrev-table 'c++-mode-abbrev-table | |
465 '(("else" "else" c-electric-continued-statement 0) | |
466 ("while" "while" c-electric-continued-statement 0) | |
467 ("catch" "catch" c-electric-continued-statement 0))) | |
468 | |
469 (defvar c++-mode-map () | |
470 "Keymap used in c++-mode buffers.") | |
471 (if c++-mode-map | |
472 nil | |
473 (setq c++-mode-map (c-make-inherited-keymap)) | |
474 ;; add bindings which are only useful for C++ | |
475 (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand) | |
476 (define-key c++-mode-map "\C-c:" 'c-scope-operator) | |
477 (define-key c++-mode-map "<" 'c-electric-lt-gt) | |
478 (define-key c++-mode-map ">" 'c-electric-lt-gt)) | |
479 | |
480 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands" | |
481 (c-mode-menu "C++")) | |
482 | |
18720 | 483 ;;;###autoload |
484 (defun c++-mode () | |
485 "Major mode for editing C++ code. | |
486 To submit a problem report, enter `\\[c-submit-bug-report]' from a | |
487 c++-mode buffer. This automatically sets up a mail buffer with | |
488 version information already added. You just need to add a description | |
489 of the problem, including a reproducible test case, and send the | |
490 message. | |
491 | |
492 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
493 | |
494 The hook variable `c++-mode-hook' is run with no args, if that | |
495 variable is bound and has a non-nil value. Also the hook | |
496 `c-mode-common-hook' is run first. | |
497 | |
498 Key bindings: | |
499 \\{c++-mode-map}" | |
500 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
501 (c-initialize-cc-mode) |
18720 | 502 (kill-all-local-variables) |
503 (set-syntax-table c++-mode-syntax-table) | |
504 (setq major-mode 'c++-mode | |
505 mode-name "C++" | |
36920 | 506 local-abbrev-table c++-mode-abbrev-table |
507 abbrev-mode t) | |
18720 | 508 (use-local-map c++-mode-map) |
509 (c-common-init) | |
510 (setq comment-start "// " | |
511 comment-end "" | |
36920 | 512 c-keywords (c-identifier-re c-C++-keywords) |
18720 | 513 c-conditional-key c-C++-conditional-key |
514 c-comment-start-regexp c-C++-comment-start-regexp | |
515 c-class-key c-C++-class-key | |
24282 | 516 c-extra-toplevel-key c-C++-extra-toplevel-key |
18720 | 517 c-access-key c-C++-access-key |
518 c-recognize-knr-p nil | |
26817 | 519 c-bitfield-key c-C-bitfield-key |
24282 | 520 ) |
26817 | 521 (cc-imenu-init cc-imenu-c++-generic-expression) |
18720 | 522 (run-hooks 'c-mode-common-hook) |
523 (run-hooks 'c++-mode-hook) | |
524 (c-update-modeline)) | |
525 | |
526 | |
36920 | 527 ;; Support for Objective-C |
528 | |
529 (defvar objc-mode-abbrev-table nil | |
530 "Abbreviation table used in objc-mode buffers.") | |
531 (define-abbrev-table 'objc-mode-abbrev-table | |
532 '(("else" "else" c-electric-continued-statement 0) | |
533 ("while" "while" c-electric-continued-statement 0))) | |
534 | |
535 (defvar objc-mode-map () | |
536 "Keymap used in objc-mode buffers.") | |
537 (if objc-mode-map | |
538 nil | |
539 (setq objc-mode-map (c-make-inherited-keymap)) | |
540 ;; add bindings which are only useful for Objective-C | |
541 (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand)) | |
542 | |
543 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands" | |
544 (c-mode-menu "ObjC")) | |
545 | |
18720 | 546 ;;;###autoload |
547 (defun objc-mode () | |
548 "Major mode for editing Objective C code. | |
549 To submit a problem report, enter `\\[c-submit-bug-report]' from an | |
550 objc-mode buffer. This automatically sets up a mail buffer with | |
551 version information already added. You just need to add a description | |
552 of the problem, including a reproducible test case, and send the | |
553 message. | |
554 | |
555 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
556 | |
557 The hook variable `objc-mode-hook' is run with no args, if that value | |
558 is bound and has a non-nil value. Also the hook `c-mode-common-hook' | |
559 is run first. | |
560 | |
561 Key bindings: | |
562 \\{objc-mode-map}" | |
563 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
564 (c-initialize-cc-mode) |
18720 | 565 (kill-all-local-variables) |
566 (set-syntax-table objc-mode-syntax-table) | |
567 (setq major-mode 'objc-mode | |
568 mode-name "ObjC" | |
36920 | 569 local-abbrev-table objc-mode-abbrev-table |
570 abbrev-mode t) | |
18720 | 571 (use-local-map objc-mode-map) |
572 (c-common-init) | |
573 (setq comment-start "// " | |
574 comment-end "" | |
36920 | 575 c-keywords (c-identifier-re c-ObjC-keywords) |
26817 | 576 c-conditional-key c-ObjC-conditional-key |
577 c-comment-start-regexp c-ObjC-comment-start-regexp | |
18720 | 578 c-class-key c-ObjC-class-key |
579 c-baseclass-key nil | |
580 c-access-key c-ObjC-access-key | |
20135
ecb78a6ccd8d
(objc-mode): Bind imenu-create-index-function
Karl Heuer <kwzh@gnu.org>
parents:
19808
diff
changeset
|
581 c-method-key c-ObjC-method-key |
20917
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
582 ) |
26817 | 583 (cc-imenu-init cc-imenu-objc-generic-expression) |
18720 | 584 (run-hooks 'c-mode-common-hook) |
585 (run-hooks 'objc-mode-hook) | |
586 (c-update-modeline)) | |
587 | |
588 | |
36920 | 589 ;; Support for Java |
590 | |
591 (defvar java-mode-abbrev-table nil | |
592 "Abbreviation table used in java-mode buffers.") | |
593 (define-abbrev-table 'java-mode-abbrev-table | |
594 '(("else" "else" c-electric-continued-statement 0) | |
595 ("while" "while" c-electric-continued-statement 0) | |
596 ("catch" "catch" c-electric-continued-statement 0) | |
597 ("finally" "finally" c-electric-continued-statement 0))) | |
598 | |
599 (defvar java-mode-map () | |
600 "Keymap used in java-mode buffers.") | |
601 (if java-mode-map | |
602 nil | |
603 (setq java-mode-map (c-make-inherited-keymap)) | |
604 ;; add bindings which are only useful for Java | |
605 ) | |
606 | |
607 (easy-menu-define c-java-menu java-mode-map "Java Mode Commands" | |
608 (c-mode-menu "Java")) | |
609 | |
18720 | 610 ;;;###autoload |
611 (defun java-mode () | |
612 "Major mode for editing Java code. | |
20135
ecb78a6ccd8d
(objc-mode): Bind imenu-create-index-function
Karl Heuer <kwzh@gnu.org>
parents:
19808
diff
changeset
|
613 To submit a problem report, enter `\\[c-submit-bug-report]' from a |
18720 | 614 java-mode buffer. This automatically sets up a mail buffer with |
615 version information already added. You just need to add a description | |
616 of the problem, including a reproducible test case and send the | |
617 message. | |
618 | |
619 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
620 | |
621 The hook variable `java-mode-hook' is run with no args, if that value | |
622 is bound and has a non-nil value. Also the common hook | |
623 `c-mode-common-hook' is run first. Note that this mode automatically | |
624 sets the \"java\" style before calling any hooks so be careful if you | |
625 set styles in `c-mode-common-hook'. | |
626 | |
627 Key bindings: | |
628 \\{java-mode-map}" | |
629 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
630 (c-initialize-cc-mode) |
18720 | 631 (kill-all-local-variables) |
632 (set-syntax-table java-mode-syntax-table) | |
633 (setq major-mode 'java-mode | |
634 mode-name "Java" | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
635 local-abbrev-table java-mode-abbrev-table |
36920 | 636 abbrev-mode t |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
637 c-append-paragraph-start c-Java-javadoc-paragraph-start) |
18720 | 638 (use-local-map java-mode-map) |
639 (c-common-init) | |
640 (setq comment-start "// " | |
641 comment-end "" | |
36920 | 642 c-keywords (c-identifier-re c-Java-keywords) |
18720 | 643 c-conditional-key c-Java-conditional-key |
644 c-comment-start-regexp c-Java-comment-start-regexp | |
645 c-class-key c-Java-class-key | |
20917
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
646 c-method-key nil |
18720 | 647 c-baseclass-key nil |
648 c-recognize-knr-p nil | |
24282 | 649 c-inexpr-class-key c-Java-inexpr-class-key |
18720 | 650 ;defun-prompt-regexp c-Java-defun-prompt-regexp |
651 ) | |
26817 | 652 (cc-imenu-init cc-imenu-java-generic-expression) |
18720 | 653 (run-hooks 'c-mode-common-hook) |
654 (run-hooks 'java-mode-hook) | |
655 (c-update-modeline)) | |
656 | |
657 | |
36920 | 658 ;; Support for CORBA's IDL language |
659 | |
660 (defvar idl-mode-abbrev-table nil | |
661 "Abbreviation table used in idl-mode buffers.") | |
662 (define-abbrev-table 'idl-mode-abbrev-table ()) | |
663 | |
664 (defvar idl-mode-map () | |
665 "Keymap used in idl-mode buffers.") | |
666 (if idl-mode-map | |
667 nil | |
668 (setq idl-mode-map (c-make-inherited-keymap)) | |
669 ;; add bindings which are only useful for IDL | |
670 ) | |
671 | |
672 (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands" | |
673 (c-mode-menu "IDL")) | |
674 | |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
675 ;;;###autoload |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
676 (defun idl-mode () |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
677 "Major mode for editing CORBA's IDL code. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
678 To submit a problem report, enter `\\[c-submit-bug-report]' from an |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
679 idl-mode buffer. This automatically sets up a mail buffer with |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
680 version information already added. You just need to add a description |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
681 of the problem, including a reproducible test case, and send the |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
682 message. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
683 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
684 To see what version of CC Mode you are running, enter `\\[c-version]'. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
685 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
686 The hook variable `idl-mode-hook' is run with no args, if that |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
687 variable is bound and has a non-nil value. Also the hook |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
688 `c-mode-common-hook' is run first. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
689 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
690 Key bindings: |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
691 \\{idl-mode-map}" |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
692 (interactive) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
693 (c-initialize-cc-mode) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
694 (kill-all-local-variables) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
695 (set-syntax-table idl-mode-syntax-table) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
696 (setq major-mode 'idl-mode |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
697 mode-name "IDL" |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
698 local-abbrev-table idl-mode-abbrev-table) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
699 (use-local-map idl-mode-map) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
700 (c-common-init) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
701 (setq comment-start "// " |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
702 comment-end "" |
36920 | 703 c-keywords (c-identifier-re c-IDL-keywords) |
26817 | 704 c-conditional-key c-IDL-conditional-key |
705 c-comment-start-regexp c-IDL-comment-start-regexp | |
24282 | 706 c-class-key c-IDL-class-key |
26817 | 707 c-method-key nil |
708 c-baseclass-key nil | |
24282 | 709 c-extra-toplevel-key c-IDL-extra-toplevel-key |
20917
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
710 c-recognize-knr-p nil |
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
711 ) |
26817 | 712 ;;(cc-imenu-init cc-imenu-idl-generic-expression) ;FIXME |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
713 (run-hooks 'c-mode-common-hook) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
714 (run-hooks 'idl-mode-hook) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
715 (c-update-modeline)) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
716 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
717 |
36920 | 718 ;; Support for Pike |
719 | |
720 (defvar pike-mode-abbrev-table nil | |
721 "Abbreviation table used in pike-mode buffers.") | |
722 (define-abbrev-table 'pike-mode-abbrev-table | |
723 '(("else" "else" c-electric-continued-statement 0) | |
724 ("while" "while" c-electric-continued-statement 0))) | |
725 | |
726 (defvar pike-mode-map () | |
727 "Keymap used in pike-mode buffers.") | |
728 (if pike-mode-map | |
729 nil | |
730 (setq pike-mode-map (c-make-inherited-keymap)) | |
731 ;; additional bindings | |
732 (define-key pike-mode-map "\C-c\C-e" 'c-macro-expand)) | |
733 | |
734 (easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands" | |
735 (c-mode-menu "Pike")) | |
736 | |
24282 | 737 ;;;###autoload |
738 (defun pike-mode () | |
739 "Major mode for editing Pike code. | |
740 To submit a problem report, enter `\\[c-submit-bug-report]' from an | |
741 idl-mode buffer. This automatically sets up a mail buffer with | |
742 version information already added. You just need to add a description | |
743 of the problem, including a reproducible test case, and send the | |
744 message. | |
745 | |
746 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
747 | |
748 The hook variable `pike-mode-hook' is run with no args, if that value | |
749 is bound and has a non-nil value. Also the common hook | |
750 `c-mode-common-hook' is run first. | |
751 | |
752 Key bindings: | |
753 \\{pike-mode-map}" | |
754 (interactive) | |
755 (c-initialize-cc-mode) | |
756 (kill-all-local-variables) | |
757 (set-syntax-table pike-mode-syntax-table) | |
758 (setq major-mode 'pike-mode | |
759 mode-name "Pike" | |
36920 | 760 local-abbrev-table pike-mode-abbrev-table |
761 abbrev-mode t | |
762 c-append-paragraph-start c-Pike-pikedoc-paragraph-start | |
763 c-append-paragraph-separate c-Pike-pikedoc-paragraph-separate) | |
24282 | 764 (use-local-map pike-mode-map) |
765 (c-common-init) | |
766 (setq comment-start "// " | |
767 comment-end "" | |
36920 | 768 c-keywords (c-identifier-re c-Pike-keywords) |
24282 | 769 c-conditional-key c-Pike-conditional-key |
26817 | 770 c-comment-start-regexp c-Pike-comment-start-regexp |
24282 | 771 c-class-key c-Pike-class-key |
772 c-method-key nil | |
773 c-baseclass-key nil | |
774 c-recognize-knr-p nil | |
775 c-lambda-key c-Pike-lambda-key | |
776 c-inexpr-block-key c-Pike-inexpr-block-key | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
777 c-inexpr-class-key c-Pike-inexpr-class-key |
24282 | 778 c-special-brace-lists c-Pike-special-brace-lists |
779 ) | |
26817 | 780 ;;(cc-imenu-init cc-imenu-pike-generic-expression) ;FIXME |
24282 | 781 (run-hooks 'c-mode-common-hook) |
782 (run-hooks 'pike-mode-hook) | |
783 (c-update-modeline)) | |
784 | |
785 | |
36920 | 786 ;; Helper for setting up Filladapt mode. It's not used by CC Mode itself. |
787 | |
788 (cc-bytecomp-defvar filladapt-token-table) | |
789 (cc-bytecomp-defvar filladapt-token-match-table) | |
790 (cc-bytecomp-defvar filladapt-token-conversion-table) | |
791 | |
26817 | 792 (defun c-setup-filladapt () |
793 "Convenience function to configure Kyle E. Jones' Filladapt mode for | |
794 CC Mode by making sure the proper entries are present on | |
795 `filladapt-token-table', `filladapt-token-match-table', and | |
796 `filladapt-token-conversion-table'. This is intended to be used on | |
797 `c-mode-common-hook' or similar." | |
798 ;; This function is intended to be used explicitly by the end user | |
799 ;; only. | |
800 ;; | |
801 ;; The default configuration already handles C++ comments, but we | |
802 ;; need to add handling of C block comments. A new filladapt token | |
803 ;; `c-comment' is added for that. | |
804 (let (p) | |
805 (setq p filladapt-token-table) | |
806 (while (and p (not (eq (car-safe (cdr-safe (car-safe p))) 'c-comment))) | |
807 (setq p (cdr-safe p))) | |
808 (if p | |
36920 | 809 (setcar (car p) c-current-comment-prefix) |
26817 | 810 (setq filladapt-token-table |
811 (append (list (car filladapt-token-table) | |
36920 | 812 (list c-current-comment-prefix 'c-comment)) |
26817 | 813 (cdr filladapt-token-table))))) |
814 (unless (assq 'c-comment filladapt-token-match-table) | |
815 (setq filladapt-token-match-table | |
816 (append '((c-comment c-comment)) | |
817 filladapt-token-match-table))) | |
818 (unless (assq 'c-comment filladapt-token-conversion-table) | |
819 (setq filladapt-token-conversion-table | |
820 (append '((c-comment . exact)) | |
821 filladapt-token-conversion-table)))) | |
822 | |
823 | |
20146 | 824 ;; bug reporting |
18720 | 825 |
826 (defconst c-mode-help-address | |
24282 | 827 "bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org" |
828 "Addresses for CC Mode bug reports.") | |
18720 | 829 |
830 (defun c-version () | |
831 "Echo the current version of CC Mode in the minibuffer." | |
832 (interactive) | |
833 (message "Using CC Mode version %s" c-version) | |
834 (c-keep-region-active)) | |
835 | |
36920 | 836 (defvar c-prepare-bug-report-hooks nil) |
837 | |
838 ;; Dynamic variables used by reporter. | |
839 (defvar reporter-prompt-for-summary-p) | |
840 (defvar reporter-dont-compact-list) | |
841 | |
18720 | 842 (defun c-submit-bug-report () |
843 "Submit via mail a bug report on CC Mode." | |
844 (interactive) | |
20917
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
845 (require 'reporter) |
18720 | 846 ;; load in reporter |
847 (let ((reporter-prompt-for-summary-p t) | |
848 (reporter-dont-compact-list '(c-offsets-alist)) | |
849 (style c-indentation-style) | |
850 (c-features c-emacs-features)) | |
851 (and | |
852 (if (y-or-n-p "Do you want to submit a report on CC Mode? ") | |
853 t (message "") nil) | |
854 (require 'reporter) | |
855 (reporter-submit-bug-report | |
856 c-mode-help-address | |
857 (concat "CC Mode " c-version " (" | |
858 (cond ((eq major-mode 'c++-mode) "C++") | |
859 ((eq major-mode 'c-mode) "C") | |
860 ((eq major-mode 'objc-mode) "ObjC") | |
861 ((eq major-mode 'java-mode) "Java") | |
26817 | 862 ((eq major-mode 'idl-mode) "IDL") |
24282 | 863 ((eq major-mode 'pike-mode) "Pike") |
18720 | 864 ) |
865 ")") | |
26817 | 866 (let ((vars (append |
18720 | 867 ;; report only the vars that affect indentation |
26817 | 868 c-style-variables |
869 '(c-delete-function | |
870 c-electric-pound-behavior | |
871 c-indent-comments-syntactically-p | |
872 c-tab-always-indent | |
873 defun-prompt-regexp | |
874 tab-width | |
875 comment-column | |
876 parse-sexp-ignore-comments | |
877 ;; A brain-damaged XEmacs only variable that, if | |
878 ;; set to nil can cause all kinds of chaos. | |
879 signal-error-on-buffer-boundary | |
880 ;; Variables that affect line breaking and comments. | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
881 auto-fill-function |
26817 | 882 filladapt-mode |
883 comment-multi-line | |
884 comment-start-skip | |
885 fill-prefix | |
886 paragraph-start | |
887 adaptive-fill-mode | |
888 adaptive-fill-regexp) | |
889 nil))) | |
890 (delq 'c-special-indent-hook vars) | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
891 (mapcar (lambda (var) (unless (boundp var) (delq var vars))) |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
892 '(signal-error-on-buffer-boundary |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
893 filladapt-mode |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
894 defun-prompt-regexp)) |
26817 | 895 vars) |
18720 | 896 (function |
897 (lambda () | |
36920 | 898 (run-hooks 'c-prepare-bug-report-hooks) |
18720 | 899 (insert |
900 "Buffer Style: " style "\n\n" | |
901 (format "c-emacs-features: %s\n" c-features) | |
36920 | 902 ))))))) |
18720 | 903 |
904 | |
36920 | 905 (cc-provide 'cc-mode) |
18720 | 906 ;;; cc-mode.el ends here |