comparison lisp/cc-mode/cc-langs.el @ 171:929b76928fce r20-3b12

Import from CVS: tag r20-3b12
author cvs
date Mon, 13 Aug 2007 09:47:52 +0200
parents 85ec50267440
children 2d532a89d707
comparison
equal deleted inserted replaced
170:98a42ee61975 171:929b76928fce
5 ;; Authors: 1992-1997 Barry A. Warsaw 5 ;; Authors: 1992-1997 Barry A. Warsaw
6 ;; 1987 Dave Detlefs and Stewart Clamen 6 ;; 1987 Dave Detlefs and Stewart Clamen
7 ;; 1985 Richard M. Stallman 7 ;; 1985 Richard M. Stallman
8 ;; Maintainer: cc-mode-help@python.org 8 ;; Maintainer: cc-mode-help@python.org
9 ;; Created: 22-Apr-1997 (split from cc-mode.el) 9 ;; Created: 22-Apr-1997 (split from cc-mode.el)
10 ;; Version: 5.11 10 ;; Version: 5.12
11 ;; Keywords: c languages oop 11 ;; Keywords: c languages oop
12 12
13 ;; This file is part of GNU Emacs. 13 ;; This file is part of GNU Emacs.
14 14
15 ;; GNU Emacs is free software; you can redistribute it and/or modify 15 ;; GNU Emacs is free software; you can redistribute it and/or modify
24 24
25 ;; You should have received a copy of the GNU General Public License 25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the 26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA. 28 ;; Boston, MA 02111-1307, USA.
29
30 (eval-when-compile
31 (load-file "./cc-styles.el"))
32 29
33 30
34 ;; Regular expressions and other values which must be parameterized on 31 ;; Regular expressions and other values which must be parameterized on
35 ;; a per-language basis. 32 ;; a per-language basis.
36 33
187 (defun c-use-java-style () 184 (defun c-use-java-style ()
188 "Institutes `java' indentation style. 185 "Institutes `java' indentation style.
189 For use with the variable `java-mode-hook'." 186 For use with the variable `java-mode-hook'."
190 (c-set-style "java")) 187 (c-set-style "java"))
191 188
189 (defvar c-styles-are-initialized nil)
190
192 (defun c-common-init () 191 (defun c-common-init ()
193 ;; Common initializations for c++-mode and c-mode. 192 ;; Common initializations for all modes.
194 ;; 193 (if c-styles-are-initialized
194 nil
195 (require 'cc-styles)
196 (c-initialize-builtin-style)
197 (if c-style-variables-are-local-p
198 (c-make-styles-buffer-local))
199 (setq c-styles-are-initialized t))
195 ;; these variables should always be buffer local; they do not affect 200 ;; these variables should always be buffer local; they do not affect
196 ;; indentation style. 201 ;; indentation style.
197 (make-local-variable 'paragraph-start) 202 (make-local-variable 'paragraph-start)
198 (make-local-variable 'paragraph-separate) 203 (make-local-variable 'paragraph-separate)
199 (make-local-variable 'paragraph-ignore-fill-prefix) 204 (make-local-variable 'paragraph-ignore-fill-prefix)
341 (define-key c-mode-base-map "\ee" 'c-end-of-statement) 346 (define-key c-mode-base-map "\ee" 'c-end-of-statement)
342 (define-key c-mode-base-map "\C-c\C-n" 'c-forward-conditional) 347 (define-key c-mode-base-map "\C-c\C-n" 'c-forward-conditional)
343 (define-key c-mode-base-map "\C-c\C-p" 'c-backward-conditional) 348 (define-key c-mode-base-map "\C-c\C-p" 'c-backward-conditional)
344 (define-key c-mode-base-map "\C-c\C-u" 'c-up-conditional) 349 (define-key c-mode-base-map "\C-c\C-u" 'c-up-conditional)
345 (define-key c-mode-base-map "\t" 'c-indent-command) 350 (define-key c-mode-base-map "\t" 'c-indent-command)
346 ;; In XEmacs 19 and Emacs 19, this binds both the BackSpace and 351 ;; Caution! Enter here at your own risk. We are trying to support
347 ;; Delete keysyms to c-electric-backspace. In XEmacs 20 it binds 352 ;; several behaviors and it gets disgusting. :-(
348 ;; only BackSpace, so we now bind them individually 353 ;;
349 (define-key c-mode-base-map [delete] 'c-electric-delete) 354 ;; In XEmacs 19, Emacs 19, and Emacs 20, we use this to bind
350 (define-key c-mode-base-map [backspace] 'c-electric-backspace) 355 ;; backwards deletion behavior to DEL, which both Delete and
356 ;; Backspace get translated to. There's no way to separate this
357 ;; behavior in a clean way, so deal with it! Besides, it's been
358 ;; this way since the dawn of BOCM.
359 (if (not (boundp 'delete-key-deletes-forward))
360 (define-key c-mode-base-map "\177" 'c-electric-backspace)
361 ;; However, XEmacs 20 actually achieved enlightenment. It is
362 ;; possible to sanely define both backward and forward deletion
363 ;; behavior under X separately (TTYs are forever beyond hope, but
364 ;; who cares? XEmacs 20 does the right thing with these too).
365 (define-key c-mode-base-map [delete] 'c-electric-delete)
366 (define-key c-mode-base-map [backspace] 'c-electric-backspace))
351 ;; these are new keybindings, with no counterpart to BOCM 367 ;; these are new keybindings, with no counterpart to BOCM
352 (define-key c-mode-base-map "," 'c-electric-semi&comma) 368 (define-key c-mode-base-map "," 'c-electric-semi&comma)
353 (define-key c-mode-base-map "*" 'c-electric-star) 369 (define-key c-mode-base-map "*" 'c-electric-star)
354 (define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun) 370 (define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun)
355 (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region) 371 (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region)
365 (define-key c-mode-base-map "\C-c." 'c-set-style) 381 (define-key c-mode-base-map "\C-c." 'c-set-style)
366 ;; conflicts with OOBR 382 ;; conflicts with OOBR
367 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version) 383 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version)
368 ) 384 )
369 385
386 ;; menu support for both XEmacs and Emacs. If you don't have easymenu
387 ;; with your version of Emacs, you are incompatible!
388 (require 'easymenu)
389
390 (defvar c-c-menu nil)
391 (defvar c-c++-menu nil)
392 (defvar c-objc-menu nil)
393 (defvar c-java-menu nil)
394
395 (defun c-mode-menu (modestr)
396 (let ((m
397 '(["Comment Out Region" comment-region (mark)]
398 ["Macro Expand Region" c-macro-expand (mark)]
399 ["Backslashify" c-backslash-region (mark)]
400 ["Indent Expression" c-indent-exp
401 (memq (char-after) '(?\( ?\[ ?\{))]
402 ["Indent Line" c-indent-command t]
403 ["Fill Comment Paragraph" c-fill-paragraph t]
404 ["Up Conditional" c-up-conditional t]
405 ["Backward Conditional" c-backward-conditional t]
406 ["Forward Conditional" c-forward-conditional t]
407 ["Backward Statement" c-beginning-of-statement t]
408 ["Forward Statement" c-end-of-statement t]
409 )))
410 (cons modestr m)))
411
370 412
371 413
372 ;; Support for C 414 ;; Support for C
373 415
374 (defvar c-mode-abbrev-table nil 416 (defvar c-mode-abbrev-table nil
401 your `.emacs' file before you visit any C files. The changes are 443 your `.emacs' file before you visit any C files. The changes are
402 global and affect all future `c-mode' buffers." 444 global and affect all future `c-mode' buffers."
403 (c-setup-dual-comments c-mode-syntax-table) 445 (c-setup-dual-comments c-mode-syntax-table)
404 (setq-default c-C-comment-start-regexp c-C++-comment-start-regexp)) 446 (setq-default c-C-comment-start-regexp c-C++-comment-start-regexp))
405 447
448 (easy-menu-define c-c-menu c-mode-map "C Mode Commands"
449 (c-mode-menu "C"))
406 450
407 451
408 ;; Support for C++ 452 ;; Support for C++
409 453
410 (defvar c++-mode-abbrev-table nil 454 (defvar c++-mode-abbrev-table nil
437 ;; but it also bothers me that this only seems appropriate for C++ 481 ;; but it also bothers me that this only seems appropriate for C++
438 ;; and not C. 482 ;; and not C.
439 ;;(modify-syntax-entry ?: "_" c++-mode-syntax-table) 483 ;;(modify-syntax-entry ?: "_" c++-mode-syntax-table)
440 ) 484 )
441 485
486 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
487 (c-mode-menu "C++"))
442 488
443 489
444 ;; Support for Objective-C 490 ;; Support for Objective-C
445 491
446 (defvar objc-mode-abbrev-table nil 492 (defvar objc-mode-abbrev-table nil
465 (c-setup-dual-comments objc-mode-syntax-table) 511 (c-setup-dual-comments objc-mode-syntax-table)
466 ;; everyone gets these 512 ;; everyone gets these
467 (modify-syntax-entry ?@ "_" objc-mode-syntax-table) 513 (modify-syntax-entry ?@ "_" objc-mode-syntax-table)
468 ) 514 )
469 515
516 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
517 (c-mode-menu "ObjC"))
470 518
471 519
472 ;; Support for Java 520 ;; Support for Java
473 521
474 (defvar java-mode-abbrev-table nil 522 (defvar java-mode-abbrev-table nil
493 (c-setup-dual-comments java-mode-syntax-table) 541 (c-setup-dual-comments java-mode-syntax-table)
494 ;; everyone gets these 542 ;; everyone gets these
495 (modify-syntax-entry ?@ "_" java-mode-syntax-table) 543 (modify-syntax-entry ?@ "_" java-mode-syntax-table)
496 ) 544 )
497 545
546 (easy-menu-define c-java-menu java-mode-map "Java Mode Commands"
547 (c-mode-menu "Java"))
498 548
499 549
500 (provide 'cc-langs) 550 (provide 'cc-langs)
501 ;;; cc-langs.el ends here 551 ;;; cc-langs.el ends here