1. xemacs
  2. cc-mode

Source

cc-mode / cc-mode.el

Diff from to

File cc-mode.el

 ;;; cc-mode.el --- major mode for editing C, C++, Objective-C, and Java code
 
-;; Copyright (C) 1985,1987,1992-2000 Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc.
 
 ;; Authors:    2000- Martin Stjernholm
 ;;	       1998-1999 Barry A. Warsaw and Martin Stjernholm
 ;; Created:    a long, long, time ago. adapted from the original c-mode.el
 ;; Keywords:   c languages oop
 
-(defconst c-version "5.27"
-  "CC Mode version number.")
-
-;; NOTE: Read the commentary below for the right way to submit bug reports!
-;; NOTE: See the accompanying texinfo manual for details on using this mode!
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; along with this program; see the file COPYING.  If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
+(defconst c-version "5.28"
+  "CC Mode version number.")
+
+;; NOTE: Read the commentary below for the right way to submit bug reports!
+;; NOTE: See the accompanying texinfo manual for details on using this mode!
+
 ;;; Commentary:
 
 ;; This package provides GNU Emacs major modes for editing C, C++,
 ;; gnu.emacs.bug) as well as bug-cc-mode@gnu.org, which directly
 ;; contacts the CC Mode maintainers.  Questions can sent to
 ;; help-gnu-emacs@gnu.org (mirrored as gnu.emacs.help) and/or
-;; bug-cc-mode@gnu.org.  Please use bug-cc-mode@gnu.org instead.
-;; Please do not send bugs or questions to our personal accounts; we
-;; reserve the right to ignore such email!
+;; bug-cc-mode@gnu.org.  Please do not send bugs or questions to our
+;; personal accounts; we reserve the right to ignore such email!
 
 ;; Many, many thanks go out to all the folks on the beta test list.
 ;; Without their patience, testing, insight, code contributions, and
 
 (eval-when-compile
   (let ((load-path
-	 ;; Try to make sure the source directory is at the front of
-	 ;; load-path when we load cc-defs.
-	 (if (and (boundp 'byte-compile-current-file)
-		  (stringp byte-compile-current-file))
-	     ;; byte-compile-current-file is set by the byte compiler
-	     ;; to the full path to this file.
-	     (cons (file-name-directory byte-compile-current-file)
-		   load-path)
+	 (if (and (boundp 'byte-compile-dest-file)
+		  (stringp byte-compile-dest-file))
+	     (cons (file-name-directory byte-compile-dest-file) load-path)
 	   load-path)))
-    ;; Load our version of cc-defs unconditionally, since an older
-    ;; version might very well be dumped in or already loaded.  This
-    ;; way we ensure that the code is compiled with the correct macros
-    ;; and defsubsts.  The same problem affects the subpackages that's
-    ;; require'd below, but that doesn't harm the compiler; it can
-    ;; only cause some bogus warnings.
-    (load "cc-defs" nil t)))
+    (require 'cc-bytecomp)))
 
-(require 'cc-defs) ; Not meaningless; this passes on require's from cc-defs.
-(require 'cc-menus)
-(require 'cc-vars)
-(require 'cc-styles)
-(require 'cc-langs)
-(require 'cc-engine)
-(require 'cc-align)
-(require 'cc-cmds)
+(cc-require 'cc-defs)
+(cc-require 'cc-menus)
+(cc-require 'cc-vars)
+(cc-require 'cc-langs)
+(cc-require 'cc-styles)
+(cc-require 'cc-engine)
+(cc-require 'cc-cmds)
+(cc-require 'cc-align)
+
+;; Silence the compiler.
+(cc-bytecomp-defvar comment-line-break-function) ; (X)Emacs 20+
+(cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs 20+
+(cc-bytecomp-defun set-keymap-parents)	; XEmacs
+
+;; Menu support for both XEmacs and Emacs.  If you don't have easymenu
+;; with your version of Emacs, you are incompatible!
+(require 'easymenu)
 
 
 ;; Other modes and packages which depend on CC Mode should do the
     ))
 
 
+;; Common routines
+(defvar c-mode-base-map ()
+  "Keymap shared by all CC Mode related modes.")
+
+(defun c-make-inherited-keymap ()
+  (let ((map (make-sparse-keymap)))
+    (cond
+     ;; XEmacs 19 & 20
+     ((fboundp 'set-keymap-parents)
+      (set-keymap-parents map c-mode-base-map))
+     ;; Emacs 19
+     ((fboundp 'set-keymap-parent)
+      (set-keymap-parent map c-mode-base-map))
+     ;; incompatible
+     (t (error "CC Mode is incompatible with this version of Emacs")))
+    map))
+
+(if c-mode-base-map
+    nil
+  ;; TBD: should we even worry about naming this keymap. My vote: no,
+  ;; because Emacs and XEmacs do it differently.
+  (setq c-mode-base-map (make-sparse-keymap))
+  ;; put standard keybindings into MAP
+  ;; the following mappings correspond more or less directly to BOCM
+  (define-key c-mode-base-map "{"         'c-electric-brace)
+  (define-key c-mode-base-map "}"         'c-electric-brace)
+  (define-key c-mode-base-map ";"         'c-electric-semi&comma)
+  (define-key c-mode-base-map "#"         'c-electric-pound)
+  (define-key c-mode-base-map ":"         'c-electric-colon)
+  (define-key c-mode-base-map "("         'c-electric-paren)
+  (define-key c-mode-base-map ")"         'c-electric-paren)
+  ;; Separate M-BS from C-M-h.  The former should remain
+  ;; backward-kill-word.
+  (define-key c-mode-base-map [(control meta h)] 'c-mark-function)
+  (define-key c-mode-base-map "\e\C-q"    'c-indent-exp)
+  (substitute-key-definition 'backward-sentence
+			     'c-beginning-of-statement
+			     c-mode-base-map global-map)
+  (substitute-key-definition 'forward-sentence
+			     'c-end-of-statement
+			     c-mode-base-map global-map)
+  (substitute-key-definition 'indent-new-comment-line
+			     'c-indent-new-comment-line
+			     c-mode-base-map global-map)
+  ;; RMS says don't make these the default.
+;;  (define-key c-mode-base-map "\e\C-a"    'c-beginning-of-defun)
+;;  (define-key c-mode-base-map "\e\C-e"    'c-end-of-defun)
+  (define-key c-mode-base-map "\C-c\C-n"  'c-forward-conditional)
+  (define-key c-mode-base-map "\C-c\C-p"  'c-backward-conditional)
+  (define-key c-mode-base-map "\C-c\C-u"  'c-up-conditional)
+  (substitute-key-definition 'indent-for-tab-command
+			     'c-indent-command
+			     c-mode-base-map global-map)
+  ;; It doesn't suffice to put c-fill-paragraph on
+  ;; fill-paragraph-function due to the way it works.
+  (substitute-key-definition 'fill-paragraph 'c-fill-paragraph
+			     c-mode-base-map global-map)
+  ;; In XEmacs the default fill function is called
+  ;; fill-paragraph-or-region.
+  (substitute-key-definition 'fill-paragraph-or-region 'c-fill-paragraph
+			     c-mode-base-map global-map)
+  ;; Caution!  Enter here at your own risk.  We are trying to support
+  ;; several behaviors and it gets disgusting. :-(
+  ;;
+  (if (boundp 'delete-key-deletes-forward)
+      (progn
+	;; In XEmacs 20 it is possible to sanely define both backward
+	;; and forward deletion behavior under X separately (TTYs are
+	;; forever beyond hope, but who cares?  XEmacs 20 does the
+	;; right thing with these too).
+	(define-key c-mode-base-map [delete]    'c-electric-delete)
+	(define-key c-mode-base-map [backspace] 'c-electric-backspace))
+    ;; In XEmacs 19, Emacs 19, and Emacs 20, we use this to bind
+    ;; backwards deletion behavior to DEL, which both Delete and
+    ;; Backspace get translated to.  There's no way to separate this
+    ;; behavior in a clean way, so deal with it!  Besides, it's been
+    ;; this way since the dawn of BOCM.
+    (define-key c-mode-base-map "\177" 'c-electric-backspace))
+  ;; 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
+  (define-key c-mode-base-map "\C-c\C-a"  'c-toggle-auto-state)
+  (define-key c-mode-base-map "\C-c\C-b"  'c-submit-bug-report)
+  (define-key c-mode-base-map "\C-c\C-c"  'comment-region)
+  (define-key c-mode-base-map "\C-c\C-d"  'c-toggle-hungry-state)
+  (define-key c-mode-base-map "\C-c\C-o"  'c-set-offset)
+  (define-key c-mode-base-map "\C-c\C-s"  'c-show-syntactic-information)
+  (define-key c-mode-base-map "\C-c\C-t"  'c-toggle-auto-hungry-state)
+  (define-key c-mode-base-map "\C-c."     'c-set-style)
+  ;; conflicts with OOBR
+  ;;(define-key c-mode-base-map "\C-c\C-v"  'c-version)
+  )
+
+(defvar c-c-menu nil)
+(defvar c-c++-menu nil)
+(defvar c-objc-menu nil)
+(defvar c-java-menu nil)
+(defvar c-pike-menu nil)
+
+(defun c-mode-menu (modestr)
+  (let ((m
+	 '(["Comment Out Region"     comment-region (c-fn-region-is-active-p)]
+	   ["Uncomment Region"
+	    (comment-region (region-beginning) (region-end) '(4))
+	    (c-fn-region-is-active-p)]
+	   ["Fill Comment Paragraph" c-fill-paragraph t]
+	   "---"
+	   ["Indent Expression"      c-indent-exp
+	    (memq (char-after) '(?\( ?\[ ?\{))]
+	   ["Indent Line or Region"  c-indent-line-or-region t]
+	   ["Up Conditional"         c-up-conditional t]
+	   ["Backward Conditional"   c-backward-conditional t]
+	   ["Forward Conditional"    c-forward-conditional t]
+	   ["Backward Statement"     c-beginning-of-statement t]
+	   ["Forward Statement"      c-end-of-statement t]
+	   "---"
+	   ["Macro Expand Region"    c-macro-expand (c-fn-region-is-active-p)]
+	   ["Backslashify"	     c-backslash-region
+	    (c-fn-region-is-active-p)]
+	   )))
+    (cons modestr m)))
+
+;; We don't require the outline package, but we configure it a bit anyway.
+(cc-bytecomp-defvar outline-level)
+
+(defun c-common-init ()
+  ;; Common initializations for all modes.
+  ;; these variables should always be buffer local; they do not affect
+  ;; indentation style.
+  (make-local-variable 'require-final-newline)
+  (make-local-variable 'parse-sexp-ignore-comments)
+  (make-local-variable 'indent-line-function)
+  (make-local-variable 'indent-region-function)
+  (make-local-variable 'outline-regexp)
+  (make-local-variable 'outline-level)
+  (make-local-variable 'normal-auto-fill-function)
+  (make-local-variable 'comment-start)
+  (make-local-variable 'comment-end)
+  (make-local-variable 'comment-column)
+  (make-local-variable 'comment-start-skip)
+  (make-local-variable 'comment-multi-line)
+  (make-local-variable 'paragraph-start)
+  (make-local-variable 'paragraph-separate)
+  (make-local-variable 'paragraph-ignore-fill-prefix)
+  (make-local-variable 'adaptive-fill-mode)
+  (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)
+       (progn
+	 (make-local-variable 'comment-line-break-function)
+	 (setq comment-line-break-function
+	       'c-indent-new-comment-line)))
+  ;; now set their values
+  (setq require-final-newline t
+	parse-sexp-ignore-comments t
+	indent-line-function 'c-indent-line
+	indent-region-function 'c-indent-region
+	outline-regexp "[^#\n\^M]"
+	outline-level 'c-outline-level
+	normal-auto-fill-function 'c-do-auto-fill
+	comment-column 32
+	comment-start-skip "/\\*+ *\\|//+ *"
+	comment-multi-line t)
+  ;; now set the mode style based on c-default-style
+  (let ((style (if (stringp c-default-style)
+		   c-default-style
+		 (or (cdr (assq major-mode c-default-style))
+		     (cdr (assq 'other c-default-style))
+		     "gnu"))))
+    ;; Override style variables if `c-old-style-variable-behavior' is
+    ;; set.  Also override if we are using global style variables,
+    ;; have already initialized a style once, and are switching to a
+    ;; different style.  (It's doubtful whether this is desirable, but
+    ;; the whole situation with nonlocal style variables is a bit
+    ;; awkward.  It's at least the most compatible way with the old
+    ;; style init procedure.)
+    (c-set-style style (not (or c-old-style-variable-behavior
+				(and (not c-style-variables-are-local-p)
+				     c-indentation-style
+				     (not (string-equal c-indentation-style
+							style)))))))
+  ;; Fix things up for paragraph recognition and filling inside
+  ;; comments by using c-current-comment-prefix in the relevant
+  ;; places.  We use adaptive filling for this to make it possible to
+  ;; use filladapt or some other fancy package.
+  (setq c-current-comment-prefix
+	(if (listp c-comment-prefix-regexp)
+	    (cdr-safe (or (assoc major-mode c-comment-prefix-regexp)
+			  (assoc 'other c-comment-prefix-regexp)))
+	  c-comment-prefix-regexp))
+  (let ((comment-line-prefix
+	 (concat "[ \t]*\\(" c-current-comment-prefix "\\)[ \t]*")))
+    (setq paragraph-start (concat comment-line-prefix
+				  c-append-paragraph-start
+				  "\\|"
+				  page-delimiter)
+	  paragraph-separate (concat comment-line-prefix
+				     c-append-paragraph-separate
+				     "\\|"
+				     page-delimiter)
+	  paragraph-ignore-fill-prefix t
+	  adaptive-fill-mode t
+	  adaptive-fill-regexp
+	  (concat comment-line-prefix
+		  (if adaptive-fill-regexp
+		      (concat "\\(" adaptive-fill-regexp "\\)")
+		    "")))
+    (when (boundp 'adaptive-fill-first-line-regexp)
+      ;; XEmacs (20.x) adaptive fill mode doesn't have this.
+      (make-local-variable 'adaptive-fill-first-line-regexp)
+      (setq adaptive-fill-first-line-regexp
+	    (concat "\\`" comment-line-prefix
+		    ;; Maybe we should incorporate the old value here,
+		    ;; but then we have to do all sorts of kludges to
+		    ;; deal with the \` and \' it probably contains.
+		    "\\'"))))
+  ;; we have to do something special for c-offsets-alist so that the
+  ;; buffer local value has its own alist structure.
+  (setq c-offsets-alist (copy-alist c-offsets-alist))
+  ;; setup the comment indent variable in a Emacs version portable way
+  ;; ignore any byte compiler warnings you might get here
+  (make-local-variable 'comment-indent-function)
+  (setq comment-indent-function 'c-comment-indent)
+  ;; add menus to menubar
+  (easy-menu-add (c-mode-menu mode-name))
+  ;; put auto-hungry designators onto minor-mode-alist, but only once
+  (or (assq 'c-auto-hungry-string minor-mode-alist)
+      (setq minor-mode-alist
+	    (cons '(c-auto-hungry-string c-auto-hungry-string)
+		  minor-mode-alist)))
+  )
+
+(defun c-postprocess-file-styles ()
+  "Function that post processes relevant file local variables.
+Currently, this function simply applies any style and offset settings
+found in the file's Local Variable list.  It first applies any style
+setting found in `c-file-style', then it applies any offset settings
+it finds in `c-file-offsets'.
+
+Note that the style variables are always made local to the buffer."
+  ;; apply file styles and offsets
+  (if (or c-file-style c-file-offsets)
+      (c-make-styles-buffer-local t))
+  (and c-file-style
+       (c-set-style c-file-style))
+  (and c-file-offsets
+       (mapcar
+	(function
+	 (lambda (langentry)
+	   (let ((langelem (car langentry))
+		 (offset (cdr langentry)))
+	     (c-set-offset langelem offset)
+	     )))
+	c-file-offsets)))
+
+(add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)
+
+
+;; Support for C
+
+(defvar c-mode-abbrev-table nil
+  "Abbreviation table used in c-mode buffers.")
+(define-abbrev-table 'c-mode-abbrev-table
+  '(("else" "else" c-electric-continued-statement 0)
+    ("while" "while" c-electric-continued-statement 0)))
+
+(defvar c-mode-map ()
+  "Keymap used in c-mode buffers.")
+(if c-mode-map
+    nil
+  (setq c-mode-map (c-make-inherited-keymap))
+  ;; add bindings which are only useful for C
+  (define-key c-mode-map "\C-c\C-e"  'c-macro-expand)
+  )
+
+(easy-menu-define c-c-menu c-mode-map "C Mode Commands"
+		  (c-mode-menu "C"))
+
 ;;;###autoload
 (defun c-mode ()
   "Major mode for editing K&R and ANSI C code.
   (set-syntax-table c-mode-syntax-table)
   (setq major-mode 'c-mode
 	mode-name "C"
-	local-abbrev-table c-mode-abbrev-table)
+	local-abbrev-table c-mode-abbrev-table
+	abbrev-mode t)
   (use-local-map c-mode-map)
   (c-common-init)
   (setq comment-start "/* "
 	comment-end   " */"
+	c-keywords (c-identifier-re c-C-keywords)
 	c-conditional-key c-C-conditional-key
 	c-class-key c-C-class-key
 	c-baseclass-key nil
   (c-update-modeline))
 
 
+;; Support for C++
+
+(defvar c++-mode-abbrev-table nil
+  "Abbreviation table used in c++-mode buffers.")
+(define-abbrev-table 'c++-mode-abbrev-table
+  '(("else" "else" c-electric-continued-statement 0)
+    ("while" "while" c-electric-continued-statement 0)
+    ("catch" "catch" c-electric-continued-statement 0)))
+
+(defvar c++-mode-map ()
+  "Keymap used in c++-mode buffers.")
+(if c++-mode-map
+    nil
+  (setq c++-mode-map (c-make-inherited-keymap))
+  ;; add bindings which are only useful for C++
+  (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand)
+  (define-key c++-mode-map "\C-c:"    'c-scope-operator)
+  (define-key c++-mode-map "<"        'c-electric-lt-gt)
+  (define-key c++-mode-map ">"        'c-electric-lt-gt))
+
+(easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
+		  (c-mode-menu "C++"))
+
 ;;;###autoload
 (defun c++-mode ()
   "Major mode for editing C++ code.
   (set-syntax-table c++-mode-syntax-table)
   (setq major-mode 'c++-mode
 	mode-name "C++"
-	local-abbrev-table c++-mode-abbrev-table)
+	local-abbrev-table c++-mode-abbrev-table
+	abbrev-mode t)
   (use-local-map c++-mode-map)
   (c-common-init)
   (setq comment-start "// "
 	comment-end ""
+	c-keywords (c-identifier-re c-C++-keywords)
 	c-conditional-key c-C++-conditional-key
 	c-comment-start-regexp c-C++-comment-start-regexp
 	c-class-key c-C++-class-key
   (c-update-modeline))
 
 
+;; Support for Objective-C
+
+(defvar objc-mode-abbrev-table nil
+  "Abbreviation table used in objc-mode buffers.")
+(define-abbrev-table 'objc-mode-abbrev-table
+  '(("else" "else" c-electric-continued-statement 0)
+    ("while" "while" c-electric-continued-statement 0)))
+
+(defvar objc-mode-map ()
+  "Keymap used in objc-mode buffers.")
+(if objc-mode-map
+    nil
+  (setq objc-mode-map (c-make-inherited-keymap))
+  ;; add bindings which are only useful for Objective-C
+  (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand))
+
+(easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
+		  (c-mode-menu "ObjC"))
+
 ;;;###autoload
 (defun objc-mode ()
   "Major mode for editing Objective C code.
   (set-syntax-table objc-mode-syntax-table)
   (setq major-mode 'objc-mode
 	mode-name "ObjC"
-	local-abbrev-table objc-mode-abbrev-table)
+	local-abbrev-table objc-mode-abbrev-table
+	abbrev-mode t)
   (use-local-map objc-mode-map)
   (c-common-init)
   (setq comment-start "// "
 	comment-end   ""
+	c-keywords (c-identifier-re c-ObjC-keywords)
 	c-conditional-key c-ObjC-conditional-key
 	c-comment-start-regexp c-ObjC-comment-start-regexp
  	c-class-key c-ObjC-class-key
   (c-update-modeline))
 
 
+;; Support for Java
+
+(defvar java-mode-abbrev-table nil
+  "Abbreviation table used in java-mode buffers.")
+(define-abbrev-table 'java-mode-abbrev-table
+  '(("else" "else" c-electric-continued-statement 0)
+    ("while" "while" c-electric-continued-statement 0)
+    ("catch" "catch" c-electric-continued-statement 0)
+    ("finally" "finally" c-electric-continued-statement 0)))
+
+(defvar java-mode-map ()
+  "Keymap used in java-mode buffers.")
+(if java-mode-map
+    nil
+  (setq java-mode-map (c-make-inherited-keymap))
+  ;; add bindings which are only useful for Java
+  )
+
+(easy-menu-define c-java-menu java-mode-map "Java Mode Commands"
+		  (c-mode-menu "Java"))
+
 ;;;###autoload
 (defun java-mode ()
   "Major mode for editing Java code.
   (setq major-mode 'java-mode
  	mode-name "Java"
  	local-abbrev-table java-mode-abbrev-table
+	abbrev-mode t
 	c-append-paragraph-start c-Java-javadoc-paragraph-start)
   (use-local-map java-mode-map)
   (c-common-init)
   (setq comment-start "// "
  	comment-end   ""
+	c-keywords (c-identifier-re c-Java-keywords)
  	c-conditional-key c-Java-conditional-key
  	c-comment-start-regexp c-Java-comment-start-regexp
   	c-class-key c-Java-class-key
 	c-method-key nil
  	c-baseclass-key nil
 	c-recognize-knr-p nil
- 	c-access-key c-Java-access-key
 	c-inexpr-class-key c-Java-inexpr-class-key
 	;defun-prompt-regexp c-Java-defun-prompt-regexp
 	)
   (c-update-modeline))
 
 
+;; Support for CORBA's IDL language
+
+(defvar idl-mode-abbrev-table nil
+  "Abbreviation table used in idl-mode buffers.")
+(define-abbrev-table 'idl-mode-abbrev-table ())
+
+(defvar idl-mode-map ()
+  "Keymap used in idl-mode buffers.")
+(if idl-mode-map
+    nil
+  (setq idl-mode-map (c-make-inherited-keymap))
+  ;; add bindings which are only useful for IDL
+  )
+
+(easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands"
+		  (c-mode-menu "IDL"))
+
 ;;;###autoload
 (defun idl-mode ()
   "Major mode for editing CORBA's IDL code.
   (c-common-init)
   (setq comment-start "// "
 	comment-end ""
+	c-keywords (c-identifier-re c-IDL-keywords)
 	c-conditional-key c-IDL-conditional-key
 	c-comment-start-regexp c-IDL-comment-start-regexp
 	c-class-key c-IDL-class-key
 	c-method-key nil
 	c-baseclass-key nil
 	c-extra-toplevel-key c-IDL-extra-toplevel-key
-	c-access-key c-IDL-access-key
 	c-recognize-knr-p nil
 	)
   ;;(cc-imenu-init cc-imenu-idl-generic-expression) ;FIXME
   (c-update-modeline))
 
 
+;; Support for Pike
+
+(defvar pike-mode-abbrev-table nil
+  "Abbreviation table used in pike-mode buffers.")
+(define-abbrev-table 'pike-mode-abbrev-table
+  '(("else" "else" c-electric-continued-statement 0)
+    ("while" "while" c-electric-continued-statement 0)))
+
+(defvar pike-mode-map ()
+  "Keymap used in pike-mode buffers.")
+(if pike-mode-map
+    nil
+  (setq pike-mode-map (c-make-inherited-keymap))
+  ;; additional bindings
+  (define-key pike-mode-map "\C-c\C-e" 'c-macro-expand))
+
+(easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands"
+		  (c-mode-menu "Pike"))
+
 ;;;###autoload
 (defun pike-mode ()
   "Major mode for editing Pike code.
   (set-syntax-table pike-mode-syntax-table)
   (setq major-mode 'pike-mode
  	mode-name "Pike"
- 	local-abbrev-table pike-mode-abbrev-table)
+ 	local-abbrev-table pike-mode-abbrev-table
+	abbrev-mode t
+	c-append-paragraph-start c-Pike-pikedoc-paragraph-start
+	c-append-paragraph-separate c-Pike-pikedoc-paragraph-separate)
   (use-local-map pike-mode-map)
   (c-common-init)
   (setq comment-start "// "
  	comment-end   ""
+	c-keywords (c-identifier-re c-Pike-keywords)
  	c-conditional-key c-Pike-conditional-key
 	c-comment-start-regexp c-Pike-comment-start-regexp
   	c-class-key c-Pike-class-key
 	c-method-key nil
  	c-baseclass-key nil
 	c-recognize-knr-p nil
- 	c-access-key c-Pike-access-key
 	c-lambda-key c-Pike-lambda-key
 	c-inexpr-block-key c-Pike-inexpr-block-key
 	c-inexpr-class-key c-Pike-inexpr-class-key
   (c-update-modeline))
 
 
+;; Helper for setting up Filladapt mode.  It's not used by CC Mode itself.
+
+(cc-bytecomp-defvar filladapt-token-table)
+(cc-bytecomp-defvar filladapt-token-match-table)
+(cc-bytecomp-defvar filladapt-token-conversion-table)
+
 (defun c-setup-filladapt ()
   "Convenience function to configure Kyle E. Jones' Filladapt mode for
 CC Mode by making sure the proper entries are present on
     (while (and p (not (eq (car-safe (cdr-safe (car-safe p))) 'c-comment)))
       (setq p (cdr-safe p)))
     (if p
-	(setcar (car p) c-comment-prefix-regexp)
+	(setcar (car p) c-current-comment-prefix)
       (setq filladapt-token-table
 	    (append (list (car filladapt-token-table)
-			  (list c-comment-prefix-regexp 'c-comment))
+			  (list c-current-comment-prefix 'c-comment))
 		    (cdr filladapt-token-table)))))
   (unless (assq 'c-comment filladapt-token-match-table)
     (setq filladapt-token-match-table
   (message "Using CC Mode version %s" c-version)
   (c-keep-region-active))
 
+(defvar c-prepare-bug-report-hooks nil)
+
+;; Dynamic variables used by reporter.
+(defvar reporter-prompt-for-summary-p)
+(defvar reporter-dont-compact-list)
+
 (defun c-submit-bug-report ()
   "Submit via mail a bug report on CC Mode."
   (interactive)
   (require 'reporter)
-  (require 'cc-vars)
   ;; load in reporter
   (let ((reporter-prompt-for-summary-p t)
 	(reporter-dont-compact-list '(c-offsets-alist))
 	(style c-indentation-style)
-	(hook c-special-indent-hook)
 	(c-features c-emacs-features))
     (and
      (if (y-or-n-p "Do you want to submit a report on CC Mode? ")
 	vars)
       (function
        (lambda ()
+	 (run-hooks 'c-prepare-bug-report-hooks)
 	 (insert
 	  "Buffer Style: " style "\n\n"
 	  (format "c-emacs-features: %s\n" c-features)
-	  )))
-      nil))))
+	  )))))))
 
 
-(provide 'cc-mode)
+(cc-provide 'cc-mode)
 ;;; cc-mode.el ends here