summaryrefslogtreecommitdiff
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-08-11 22:13:48 +0000
committerRichard M. Stallman <rms@gnu.org>1997-08-11 22:13:48 +0000
commitb5592c93e185fd19f48ef69c252f601422b2621a (patch)
treeb9c696c9a3ddb0d9352c7b5d34fc9102f392c52f /lisp/progmodes
parentd8381101710a31e5597ff0568960ee678eddb442 (diff)
downloademacs-b5592c93e185fd19f48ef69c252f601422b2621a.tar.gz
(c-mode-base-map, c++-mode-map):
Move `/' as an electric character from c++-mode-map to c-mode-base-map for all languages. (c-common-init): Set comment-multi-line and comment-line-break-function here for all modes. Make comment-line-break-function buffer local iff it's boundp. (c-C-comment-start-regexp): Obsolete. (c-comment-start-regexp): Initialize from c-C++-comment-start-regexp. (c-populate-syntax-table, c-setup-dual-comments): Merge both functions into c-populate-syntax-table. With the new 9X draft C standard, both line and block oriented comments are supported in all modes, so always set up the syntax tables to support both comment styles. (c-enable-//-in-c-mode): Obsolete. (c++-mode-syntax-table, java-mode-syntax-table) (objc-mode-syntax-table, idl-mode-syntax-table): Added autoload cookies. c-mode-syntax-table already has one. Use the new syntax table initialization idioms.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/cc-langs.el77
1 files changed, 29 insertions, 48 deletions
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 918be2f7188..551b2f7fb19 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -7,7 +7,7 @@
;; 1985 Richard M. Stallman
;; Maintainer: cc-mode-help@python.org
;; Created: 22-Apr-1997 (split from cc-mode.el)
-;; Version: 5.14
+;; Version: 5.15
;; Keywords: c languages oop
;; This file is part of GNU Emacs.
@@ -125,12 +125,11 @@
;; comment starter definitions for various languages. language specific
-(defconst c-C-comment-start-regexp "/[*]")
(defconst c-C++-comment-start-regexp "/[/*]")
;; We need to match all 3 Java style comments
;; 1) Traditional C block; 2) javadoc /** ...; 3) C++ style
(defconst c-Java-comment-start-regexp "/\\(/\\|[*][*]?\\)")
-(defvar c-comment-start-regexp c-C-comment-start-regexp)
+(defvar c-comment-start-regexp c-C++-comment-start-regexp)
(make-variable-buffer-local 'c-comment-start-regexp)
@@ -217,6 +216,9 @@ For use with the variable `java-mode-hook'."
(make-local-variable 'outline-level)
(make-local-variable 'adaptive-fill-regexp)
(make-local-variable 'imenu-generic-expression) ;set in the mode functions
+ ;; X/Emacs 20 only
+ (and (boundp 'comment-line-break-function)
+ (make-local-variable 'comment-line-break-function))
;; Emacs 19.30 and beyond only, AFAIK
(if (boundp 'fill-paragraph-function)
(progn
@@ -234,6 +236,8 @@ For use with the variable `java-mode-hook'."
outline-level 'c-outline-level
comment-column 32
comment-start-skip "/\\*+ *\\|// *"
+ comment-multi-line nil
+ comment-line-break-function 'c-comment-line-break-function
adaptive-fill-regexp nil)
;; we have to do something special for c-offsets-alist so that the
;; buffer local value has its own alist structure.
@@ -299,28 +303,26 @@ it finds in `c-file-offsets'."
(modify-syntax-entry ?> "." table)
(modify-syntax-entry ?& "." table)
(modify-syntax-entry ?| "." table)
- (modify-syntax-entry ?\' "\"" table))
-
-(defun c-setup-dual-comments (table)
- ;; Set up TABLE to handle block and line style comments
+ (modify-syntax-entry ?\' "\"" table)
+ ;; Set up block and line oriented comments. The new C standard
+ ;; mandates both comment styles even in C, so since all languages
+ ;; now require dual comments, we make this the default.
(cond
;; XEmacs 19 & 20
((memq '8-bit c-emacs-features)
(modify-syntax-entry ?/ ". 1456" table)
- (modify-syntax-entry ?* ". 23" table)
- (modify-syntax-entry ?\n "> b" table)
- ;; Give CR the same syntax as newline, for selective-display
- (modify-syntax-entry ?\^m "> b" table))
- ;; Emacs 19
+ (modify-syntax-entry ?* ". 23" table))
+ ;; Emacs 19 & 20
((memq '1-bit c-emacs-features)
(modify-syntax-entry ?/ ". 124b" table)
- (modify-syntax-entry ?* ". 23" table)
- (modify-syntax-entry ?\n "> b" table)
- ;; Give CR the same syntax as newline, for selective-display
- (modify-syntax-entry ?\^m "> b" table))
+ (modify-syntax-entry ?* ". 23" table))
;; incompatible
(t (error "CC Mode is incompatible with this version of Emacs"))
- ))
+ )
+ (modify-syntax-entry ?\n "> b" table)
+ ;; Give CR the same syntax as newline, for selective-display
+ (modify-syntax-entry ?\^m "> b" table))
+
(defvar c-mode-base-map ()
"Keymap shared by all CC Mode related modes.")
@@ -369,6 +371,7 @@ it finds in `c-file-offsets'."
;; these are new keybindings, with no counterpart to BOCM
(define-key c-mode-base-map "," 'c-electric-semi&comma)
(define-key c-mode-base-map "*" 'c-electric-star)
+ (define-key c-mode-base-map "/" 'c-electric-slash)
(define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun)
(define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region)
;; TBD: where if anywhere, to put c-backward|forward-into-nomenclature
@@ -438,19 +441,7 @@ it finds in `c-file-offsets'."
(if c-mode-syntax-table
()
(setq c-mode-syntax-table (make-syntax-table))
- (c-populate-syntax-table c-mode-syntax-table)
- ;; add extra comment syntax
- (modify-syntax-entry ?/ ". 14" c-mode-syntax-table)
- (modify-syntax-entry ?* ". 23" c-mode-syntax-table))
-
-(defun c-enable-//-in-c-mode ()
- "Enables // as a comment delimiter in `c-mode'.
-ANSI C currently does *not* allow this, although many C compilers
-support optional C++ style comments. To use, call this function from
-your `.emacs' file before you visit any C files. The changes are
-global and affect all future `c-mode' buffers."
- (c-setup-dual-comments c-mode-syntax-table)
- (setq-default c-C-comment-start-regexp c-C++-comment-start-regexp))
+ (c-populate-syntax-table c-mode-syntax-table))
(easy-menu-define c-c-menu c-mode-map "C Mode Commands"
(c-mode-menu "C"))
@@ -469,18 +460,16 @@ global and affect all future `c-mode' buffers."
(setq c++-mode-map (c-make-inherited-keymap))
;; add bindings which are only useful for C++
(define-key c++-mode-map "\C-c:" 'c-scope-operator)
- (define-key c++-mode-map "/" 'c-electric-slash)
(define-key c++-mode-map "<" 'c-electric-lt-gt)
(define-key c++-mode-map ">" 'c-electric-lt-gt))
+;;;###autoload
(defvar c++-mode-syntax-table nil
"Syntax table used in c++-mode buffers.")
(if c++-mode-syntax-table
()
(setq c++-mode-syntax-table (make-syntax-table))
(c-populate-syntax-table c++-mode-syntax-table)
- ;; add extra comment syntax
- (c-setup-dual-comments c++-mode-syntax-table)
;; TBD: does it make sense for colon to be symbol class in C++?
;; I'm not so sure, since c-label-key is busted on lines like:
;; Foo::bar( i );
@@ -508,17 +497,15 @@ global and affect all future `c-mode' buffers."
;; add bindings which are only useful for Objective-C
(define-key objc-mode-map "/" 'c-electric-slash))
+;;;###autoload
(defvar objc-mode-syntax-table nil
"Syntax table used in objc-mode buffers.")
(if objc-mode-syntax-table
()
(setq objc-mode-syntax-table (make-syntax-table))
(c-populate-syntax-table objc-mode-syntax-table)
- ;; add extra comment syntax
- (c-setup-dual-comments objc-mode-syntax-table)
- ;; everyone gets these
- (modify-syntax-entry ?@ "_" objc-mode-syntax-table)
- )
+ ;; add extra Objective-C only syntax
+ (modify-syntax-entry ?@ "_" objc-mode-syntax-table))
(easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
(c-mode-menu "ObjC"))
@@ -538,17 +525,13 @@ global and affect all future `c-mode' buffers."
;; add bindings which are only useful for Java
(define-key java-mode-map "/" 'c-electric-slash))
+;;;###autoload
(defvar java-mode-syntax-table nil
"Syntax table used in java-mode buffers.")
(if java-mode-syntax-table
()
(setq java-mode-syntax-table (make-syntax-table))
- (c-populate-syntax-table java-mode-syntax-table)
- ;; add extra comment syntax
- (c-setup-dual-comments java-mode-syntax-table)
- ;; everyone gets these
- (modify-syntax-entry ?@ "_" java-mode-syntax-table)
- )
+ (c-populate-syntax-table java-mode-syntax-table))
(easy-menu-define c-java-menu java-mode-map "Java Mode Commands"
(c-mode-menu "Java"))
@@ -568,15 +551,13 @@ global and affect all future `c-mode' buffers."
;; additional bindings
(define-key idl-mode-map "/" 'c-electric-slash))
+;;;###autoload
(defvar idl-mode-syntax-table nil
"Syntax table used in idl-mode buffers.")
(if idl-mode-syntax-table
nil
(setq idl-mode-syntax-table (make-syntax-table))
- (c-populate-syntax-table idl-mode-syntax-table)
- ;; add extra comment syntax
- (c-setup-dual-comments idl-mode-syntax-table)
- )
+ (c-populate-syntax-table idl-mode-syntax-table))
(easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands"
(c-mode-menu "IDL"))