Commits

Anonymous committed ffb5994

Upgrade from 5.21 to 5.25

  • Participants
  • Parent commits 3901916

Comments (0)

Files changed (20)

File ANNOUNCEMENT

+Release Announcement
+CC Mode Version 5.25
+Barry A. Warsaw and Martin Stjernholm
+<mailto:bug-cc-mode@gnu.org>
+
+This message announces the availablity of a new version of CC Mode, a
+GNU Emacs mode for editing C (ANSI and K&R), C++, Objective-C, Java,
+CORBA's IDL, and Pike code.  A list of user visible changes is
+detailed in the NEWS file and in the URL listed below.  More
+information, including links to download the source, are available on
+the CC Mode Web page:
+
+    <http://www.python.org/emacs/cc-mode/>
+
+There is also a link to the CC Mode announcement mailing list, a
+moderated list that you can join to get future release announcements.
+Please see this page for more information on this mailing list:
+
+    <http://www.python.org/mailman/listinfo/cc-mode-announce>
+
+Send email correspondence to
+
+    bug-cc-mode@gnu.org
+
+Note that the old address, cc-mode-help@python.org is still active,
+but it's use is discouraged.
+
+For a list of changes please see
+
+    <http://www.python.org/emacs/cc-mode/changes-525.html>
+1998-12-30  Martin Buchholz  <martin@xemacs.org>
+
+	* Makefile (MAINTAINER): The preferred address is bug-cc-mode@gnu.org
+
+	* Release 5.25
+	Snarfed from http://www.python.org/emacs/cc-mode/
+
 1998-03-05  SL Baur  <steve@altair.xemacs.org>
 
 	* cc-mode.el: cc-defs isn't needed at run-time.
+Manifest for CC Mode 5.25
+Barry A. Warsaw and Martin Stjernholm
+<mailto:bug-cc-mode@gnu.org>
+
+You should have received the following files in this distribution:
+
+    MANIFEST: This file.
+
+    README: Quick intro into how to get CC Mode up and running.
+
+    NEWS: A list of the user visible changes in each version.
+
+    cc-align.el, cc-cmds.el, cc-defs.el, cc-engine.el, cc-langs.el,
+    cc-menus.el, cc-mode.el, cc-styles.el, cc-vars.el: The source code.
+
+    cc-compat.el: Helps ease the transition from c-mode.el (BOCM) to
+    the new indentation engine.  This is provided for your convenience
+    only, and is unguaranteed and unsupported.
+
+    cc-guess.el: Experiments in style guessing.  This is provided for
+    your convenience only, and is unguaranteed and unsupported.
+
+    cc-lobotomy.el: Performance vs. accuracy trade-offs.  May not
+    work, yadda, yadda.
+
+    cc-mode-19.el: Compatibility for Emacs 19.34.  Do not use with
+    Emacs 20, XEmacs 19, or XEmacs 20.
+
+    cc-make.el: Helps with byte-compiling the CC Mode distribution.
+
+    cc-mode.texi: The latest CC Mode Texinfo manual.
+
+    ANNOUNCEMENT: Release announcement as it appeared on various
+    forums.
+
+Note that of the above files, the following are distributed with Emacs
+20 and XEmacs 20:
+
+    cc-align.el, cc-cmds.el, cc-compat.el, cc-defs.el, cc-engine.el,
+    cc-langs.el, cc-menus.el, cc-mode.el, cc-styles.el, cc-vars.el,
+    cc-mode.texi
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.13
-AUTHOR_VERSION = 5.22
-MAINTAINER = Barry Warsaw <cc-mode-help@python.org>
+VERSION = 1.14
+AUTHOR_VERSION = 5.25
+MAINTAINER = Barry Warsaw <bug-cc-mode@gnu.org>
 PACKAGE = cc-mode
 PKG_TYPE = regular
 REQUIRES = xemacs-base
 CATEGORY = prog
 
 ELCS = cc-defs.elc cc-align.elc cc-cmds.elc cc-compat.elc cc-engine.elc \
-	cc-langs.elc cc-menus.elc cc-mode.elc cc-styles.elc cc-vars.elc
+	cc-langs.elc cc-menus.elc cc-mode.elc cc-styles.elc cc-vars.elc \
+	cc-lobotomy.elc cc-guess.elc
 #PRELOADS = -l cc-defs.el
 INFO_FILES = $(PACKAGE).info*
 TEXI_FILES = $(PACKAGE).texi
+README for CC Mode 5.25
+Current maintainers: Barry A. Warsaw and Martin Stjernholm
+Contact address    : bug-cc-mode@gnu.org (or cc-mode-help@python.org)
+
+INTRODUCTION
+
+    The canonical Web location for all knowledge CC Mode is:
+
+	<http://www.python.org/emacs/cc-mode/>
+
+    Please read the cc-mode.texi manual for details on using CC Mode.
+    This is available on-line from:
+
+        <http://www.python.org/emacs/cc-mode/cc-mode-html/Top.html>
+
+    As of this writing (23-Oct-1998), CC Mode version 5 currently
+    works out of the box with XEmacs versions 19.15, 19.16, 20.3,
+    20.4, and 21.0, and with Emacs versions 19.34, 20.2, 20.3.
+
+MORE INFORMATION
+
+    NOTE: Since there are now multiple maintainers of CC Mode, you
+    MUST address all correspondence to bug-cc-mode@gnu.org (or
+    cc-mode-help@python.org, is address is being phased out).
+
+    Check out the CC Mode Web site for the latest information,
+    updates, tips, installation and compatibility notes, etc. on using
+    CC Mode.  The installation instructions given below are an excerpt
+    of the on-line instructions.  If you have problems installing CC
+    Mode, please check out the URL above before submitting a bug
+    report.  Thanks!
+
+    The MANIFEST file contains a description of all the files you
+    should have gotten with this distribution.
+
+MANUALS
+
+    Preformatted versions of the manual in DVI, PostScript, and Info,
+    are all available at the CC Mode Web page.
+
+    To build the manual yourself, you will need the latest Texinfo
+    release (as of this writing, Texinfo 3.11).  Specifically, you
+    must make sure that your are using at least version 2.185 of the
+    texinfo.tex file.  To build the Info manual, simply type:
+
+        % makeinfo cc-mode.texi
+
+    To make the DVI version, simply type:
+
+        % texi2dvi cc-mode.texi
+
+    Note that I've heard of other package releases that purport to
+    include a texinfo.tex file newer than 2.185, but these don't
+    support the @macro{} command.  If you have problems building the
+    manuals, pick up a pre-built version.
+
+INSTALLATION
+
+    Here is a quick guide for installing CC Mode.  For the latest
+    information on installing CC Mode, including compatibility notes
+    for the various flavors of Emacs, please see the CC Mode Web site
+    given above.
+
+  Setting load-path
+
+    You need to make sure that this new version of CC Mode is on your
+    load-path, before any version that is distributed with your
+    X/Emacs.  Note that the CC Mode distribution unpacks into its own
+    subdirectory.  You can use this test to see which version of CC
+    Mode your X/Emacs finds first:
+
+        M-x locate-library RET cc-mode RET
+                                 
+    Make sure this finds the one you expect.  If not, you can add this
+    to your .emacs file:
+
+        (setq load-path (cons "/dir/of/cc-mode/" load-path))
+                                 
+    The path you use should be an absolute path (starting with a
+    slash).  You cannot use a path beginning with "~" in the load-path
+    variable.
+
+  Byte Compiling
+
+    It is highly recommended that you byte-compile CC Mode, for both
+    performance and compatibility reasons.  Running CC Mode
+    un-bytecompiled is not supported and may not work at all depending
+    on the flavor of X/Emacs you are using.
+
+    You can byte compile CC Mode by doing the following from your
+    shell:
+
+        % cd /path/to/cc-mode
+        % $(EMACS) -batch -no-site-file -q -l cc-make.el cc-*.el
+
+    where $(EMACS) is either emacs or xemacs depending on the flavor
+    you use.
+
+    You can safely ignore any byte compiler warnings; they are due to
+    the cross X/Emacsen support.
+
+    Be sure to see the list of compatibility issues (in the CC Mode
+    canonical Web pages -- see above), for special notes about X/Emacs
+    versions and package interactions.
+
+    To test that you have things set up correctly, visit a C file and
+    then type:
+
+        M-x c-version RET
+        => Using CC Mode version 5.XX
+
+    where XX is the correct minor revision number.
 
 ;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
 
-;; Authors:    1992-1997 Barry A. Warsaw
+;; Authors:    1998 Barry A. Warsaw and Martin Stjernholm
+;;             1992-1997 Barry A. Warsaw
 ;;             1987 Dave Detlefs and Stewart Clamen
 ;;             1985 Richard M. Stallman
-;; Maintainer: cc-mode-help@python.org
+;; Maintainer: bug-cc-mode@gnu.org
 ;; Created:    22-Apr-1997 (split from cc-mode.el)
 ;; Version:    See cc-mode.el
 ;; Keywords:   c languages oop
 	    (beginning-of-line)
 	    (looking-at "[ \t]*)"))
 	  (progn (goto-char (match-end 0))
-		 (forward-sexp -1)
+		 (c-forward-sexp -1)
 		 (forward-char 1)
 		 (c-forward-syntactic-ws)
 		 (- (current-column) langelem-col))
 	(let (opencol spec)
 	  (beginning-of-line)
 	  (backward-up-list 1)
-	  (setq spec (if (fboundp 'c-looking-at-special-brace-list)
-			 (c-looking-at-special-brace-list)))
-	  (if spec (goto-char (car spec)))
+	  (setq spec (c-looking-at-special-brace-list))
+	  (if spec (goto-char (car (car spec))))
 	  (setq opencol (current-column))
 	  (forward-char 1)
 	  (if spec (progn
       (beginning-of-line)
       (skip-chars-forward " \t")
       (if (and (eq (following-char) ?{)
-	       (condition-case nil
-		   (progn (forward-sexp) t)
-		 (error nil))
+	       (c-safe (progn (c-forward-sexp) t))
 	       (<= (point) eol)
 	       (eq (preceding-char) ?}))
 	  c-basic-offset
 	(if (c-in-literal (cdr langelem))
 	    (forward-char 1)
 	  (setq donep t)))
-      (if (not (eq (char-after) ?=))
+      (if (or (not (eq (char-after) ?=))
+	      (save-excursion
+		(forward-char 1)
+		(c-forward-syntactic-ws (c-point 'eol))
+		(eolp)))
 	  ;; there's no equal sign on the line
 	  c-basic-offset
 	;; calculate indentation column after equals and ws, unless
 			       (current-column)))
            (target-col (progn
 			 (forward-char)
-			 (forward-sexp)
+			 (c-forward-sexp)
 			 (skip-chars-forward " \t")
 			 (if (eolp)
 			     (+ open-bracket-col c-basic-offset)
 	    (+ curcol (- prev-col-column (current-column)))
 	  c-basic-offset)))))
 
+(defun c-lineup-inexpr-block (langelem)
+  ;; This function lines up the block for the various constructs that
+  ;; uses a block inside an expression.  For constructs matching
+  ;; c-lambda-key and c-inexpr-block-key, indentation to the column of
+  ;; the beginning of the match is added.  For standalone statement
+  ;; blocks, indentation to the column of the opening brace is added.
+  (save-excursion
+    (back-to-indentation)
+    (let ((res (or (c-looking-at-inexpr-block)
+		   (if (c-safe (backward-up-list 1)
+			       (eq (char-after) ?{))
+		       (c-looking-at-inexpr-block)))))
+      (if (not res)
+	  0
+	(goto-char (cdr res))
+	(- (current-column)
+	   (progn
+	     (back-to-indentation)
+	     (current-column)))))))
+
 (defun c-lineup-dont-change (langelem)
   ;; Do not change the indentation of the current line
   (save-excursion
 	       (setq langelem (assq 'block-close c-syntactic-context))
 	       (progn (goto-char (cdr langelem))
 		      (if (eq (char-after) ?{)
-			  (c-safe (forward-sexp -1)))
+			  (c-safe (c-forward-sexp -1)))
 		      (looking-at "\\<do\\>[^_]")))
 	  '(before)
 	'(before after)))))
-;;; cc-cmds.el --- user level commands for CC Mode 
+;;; cc-cmds.el --- user level commands for CC Mode
 
-;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
+;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Softare Foundation, Inc.
 
-;; Authors:    1992-1997 Barry A. Warsaw
+;; Authors:    1998 Barry A. Warsaw and Martin Stjernholm
+;;             1992-1997 Barry A. Warsaw
 ;;             1987 Dave Detlefs and Stewart Clamen
 ;;             1985 Richard M. Stallman
-;; Maintainer: cc-mode-help@python.org
+;; Maintainer: bug-cc-mode@gnu.org
 ;; Created:    22-Apr-1997 (split from cc-mode.el)
 ;; Version:    See cc-mode.el
 ;; Keywords:   c languages oop
 nil, or point is inside a literal then the function in the variable
 `c-delete-function' is called."
   (interactive "*P")
-  (if (and (boundp 'delete-key-deletes-forward)
-	   delete-key-deletes-forward)
+  (if (or (and (fboundp 'delete-forward-p) ;XEmacs 21
+	       (delete-forward-p))
+	  (and (boundp 'delete-key-deletes-forward) ;XEmacs 20
+	       delete-key-deletes-forward))
       (if (or (not c-hungry-delete-key)
 	      arg
 	      (c-in-literal))
 `c-electric-pound-behavior'.  If a numeric ARG is supplied, or if
 point is inside a literal, nothing special happens."
   (interactive "*P")
-  (if (or (c-in-literal)
-	  arg
-	  (not (memq 'alignleft c-electric-pound-behavior)))
+  (if (or arg
+	  (not (memq 'alignleft c-electric-pound-behavior))
+	  (save-excursion (skip-chars-backward " \t") (not (bolp)))
+	  (c-in-literal))
       ;; do nothing special
       (self-insert-command (prefix-numeric-value arg))
     ;; place the pound character at the left edge
 
 Also, the line is re-indented unless a numeric ARG is supplied, there
 are non-whitespace characters present on the line after the brace, or
-the brace is inserted inside a literal."
+the brace is inserted inside a literal.
+
+This function does various newline cleanups based on the value of
+`c-cleanup-list'."
   (interactive "*P")
   (let* ((c-state-cache (c-parse-state))
 	 (safepos (c-safe-position (point) c-state-cache))
     ;; if we're in a literal, or we're not at the end of the line, or
     ;; a numeric arg is provided, or auto-newlining is turned off,
     ;; then just insert the character.
-    (if (or literal arg
-;	    (not c-auto-newline)
+    (if (or literal
+	    arg
 	    (not (looking-at "[ \t]*$")))
 	(self-insert-command (prefix-numeric-value arg))
       (let* ((syms
 	      '(class-open class-close defun-open defun-close
 		inline-open inline-close
 		brace-list-open brace-list-close
-		brace-list-intro brace-list-entry
+		brace-list-intro brace-entry-open
 		block-open block-close
 		substatement-open statement-case-open
 		extern-lang-open extern-lang-close
 		namespace-open namespace-close
+		inexpr-class-open inexpr-class-close
 		))
 	    ;; we want to inhibit blinking the paren since this will
 	    ;; be most disruptive. we'll blink it ourselves later on
 		      (c-guess-basic-syntax)))
 	    (newlines (and
 		       c-auto-newline
-		       (or (c-lookup-lists syms syntax c-hanging-braces-alist)
+		       (or (c-lookup-lists
+			    syms
+			    ;; Substitute inexpr-class and class-open
+			    ;; or class-close with inexpr-class-open
+			    ;; or inexpr-class-close.
+			    (if (assq 'inexpr-class syntax)
+				(cond ((assq 'class-open syntax)
+				       '((inexpr-class-open)))
+				      ((assq 'class-close syntax)
+				       '((inexpr-class-close)))
+				      (t syntax))
+			      syntax)
+			    c-hanging-braces-alist)
 			   '(ignore before after)))))
+	;; Do not try to insert newlines around a special (Pike-style)
+	;; brace list.
+	(if (and c-special-brace-lists
+		 (c-intersect-lists '(brace-list-open brace-list-close
+				      brace-list-intro brace-entry-open)
+				    syntax)
+		 (save-excursion
+		   (c-safe (if (= (char-before) ?{)
+			       (forward-char -1)
+			     (c-forward-sexp -1))
+			   (c-looking-at-special-brace-list))))
+	    (setq newlines nil))
 	;; If syntax is a function symbol, then call it using the
 	;; defined semantics.
 	(if (and (not (consp (cdr newlines)))
 	    ;; we leave the newline we've put in there before,
 	    ;; but we need to re-indent the line above
 	    (let ((pos (- (point-max) (point)))
-		  (here (point))
-		  (c-state-cache c-state-cache))
+		  (here (point)))
 	      (forward-line -1)
-	      ;; we may need to update the cache. this should still be
-	      ;; faster than recalculating the state in many cases
-	      (save-excursion
-		(save-restriction
-		  (narrow-to-region here (point))
-		  (if (and (c-safe (progn (backward-up-list -1) t))
-			   (memq (char-before) '(?\) ?}))
-			   (progn (widen)
-				  (c-safe (progn (forward-sexp -1) t))))
-		      (setq c-state-cache
-			    (c-hack-state (point) 'open c-state-cache))
-		    (if (and (car c-state-cache)
-			     (not (consp (car c-state-cache)))
-			     (<= (point) (car c-state-cache)))
-			(setq c-state-cache (cdr c-state-cache))
-		      ))))
-	      (let ((here (point))
-		    (shift (c-indent-line)))
-		(setq c-state-cache (c-adjust-state (c-point 'bol) here
-						    (- shift) c-state-cache)))
+	      (let ((c-state-cache (c-whack-state (point) c-state-cache)))
+		;; we may need to update the cache. this should
+		;; still be faster than recalculating the state
+		;; in many cases
+		(save-excursion
+		  (save-restriction
+		    (narrow-to-region here (point))
+		    (if (and (c-safe (progn (backward-up-list -1) t))
+			     (memq (char-before) '(?\) ?}))
+			     (progn (widen)
+				    (c-safe (progn (c-forward-sexp -1)
+						   t))))
+			(setq c-state-cache
+			      (c-hack-state (point) 'open c-state-cache)))))
+		(c-indent-line))
+	      (setq c-state-cache (c-adjust-state (c-point 'bol) here
+						  (- (point) (c-point 'bol))
+						  c-state-cache))
 	      (goto-char (- (point-max) pos))
 	      ;; if the buffer has changed due to the indentation, we
 	      ;; need to recalculate syntax for the current line, but
 	;; now adjust the line's indentation. don't update the state
 	;; cache since c-guess-basic-syntax isn't called when the
 	;; syntax is passed to c-indent-line
-	(let ((here (point))
-	      (shift (c-indent-line syntax)))
+	(let* ((here (point)))
+	  (c-indent-line syntax)
 	  (setq c-state-cache (c-adjust-state (c-point 'bol) here
-					      (- shift) c-state-cache)))
+					      (- (c-point 'boi) (c-point 'bol))
+					      c-state-cache)))
 	;; Do all appropriate clean ups
 	(let ((here (point))
 	      (pos (- (point-max) (point)))
 	      (progn
 		(delete-region mbeg mend)
 		(insert "} else {")))
-	  ;; clean up brace-elseif-brace
-	  (if (and c-auto-newline
-		   (memq 'brace-elseif-brace c-cleanup-list)
-		   (eq last-command-char ?\{)
-		   (re-search-backward "}[ \t\n]*else[ \t\n]+if[ \t\n]*" nil t)
-		   (save-excursion
-		     (goto-char (match-end 0))
-		     (c-safe (forward-sexp 1))
-		     (skip-chars-forward " \t\n")
-		     (setq mbeg (match-beginning 0)
-			   mend (match-end 0))
-		     (= here (1+ (point))))
-		   (not (c-in-literal)))
-	      (progn
-		(delete-region mbeg mend)
-		(insert "} else if ")))
 	  (goto-char (- (point-max) pos))
 	  )
 	;; does a newline go after the brace?
 	       (c-backward-syntactic-ws safepos)
 	       (funcall old-blink-paren)))
 	))))
-      
+
 (defun c-electric-slash (arg)
   "Insert a slash character.
 
 
 When semicolon is inserted, the line is re-indented unless a numeric
 arg is supplied, point is inside a literal, or there are
-non-whitespace characters on the line following the semicolon."
+non-whitespace characters on the line following the semicolon.
+
+Based on the value of `c-cleanup-list', this function cleans up commas
+following brace lists and semicolons following defuns."
   (interactive "*P")
   (let* ((lim (c-most-enclosing-brace (c-parse-state)))
 	 (literal (c-in-literal lim))
 	(self-insert-command (prefix-numeric-value arg))
       ;; do some special stuff with the character
       (self-insert-command (prefix-numeric-value arg))
-      ;; do all cleanups, reindentations, and newline insertions, but
-      ;; only if c-auto-newline is turned on
-      (if (not c-auto-newline) nil
+      ;; do all cleanups and newline insertions if c-auto-newline is
+      ;; turned on
+      (if (not c-auto-newline)
+	  (c-indent-line)
 	;; clean ups
 	(let ((pos (- (point-max) (point))))
 	  (if (and (or (and
 		 (or (c-lookup-lists '(case-label label access-label)
 				     syntax c-hanging-colons-alist)
 		     (c-lookup-lists '(member-init-intro inher-intro)
-				     (prog2
-					 (insert "\n")
-					 (c-guess-basic-syntax)
-				       (delete-char -1))
+				     (let ((buffer-undo-list t))
+				       (insert "\n")
+				       (unwind-protect
+					   (c-guess-basic-syntax)
+					 (delete-char -1)))
 				     c-hanging-colons-alist))))
       ;; indent the current line
       (c-indent-line syntax)
 
 (defun c-electric-lt-gt (arg)
   "Insert a less-than, or greater-than character.
-When the auto-newline feature is turned on, as evidenced by the \"/a\"
-or \"/ah\" string on the mode line, the line will be re-indented if
-the character inserted is the second of a C++ style stream operator
-and the buffer is in C++ mode.
-
-The line will also not be re-indented if a numeric argument is
-supplied, or point is inside a literal."
+The line will be re-indented if the character inserted is the second
+of a C++ style stream operator and the buffer is in C++ mode.
+Exceptions are when a numeric argument is supplied, or point is inside
+a literal, in which case the line will not be re-indented."
   (interactive "*P")
   (let ((indentp (and (not arg)
 		      (eq (char-before) last-command-char)
     (if indentp
 	(c-indent-line))))
 
+(defun c-electric-paren (arg)
+  "Insert a parenthesis.
+
+If the auto-newline feature is turned on, as evidenced by the \"/a\"
+or \"/ah\" string on the mode line, some newline cleanups are done if
+appropriate; see the variable `c-cleanup-list'.
+
+Also, the line is re-indented unless a numeric ARG is supplied, there
+are non-whitespace characters present on the line after the colon, or
+the colon is inserted inside a literal."
+  (interactive "*P")
+  (let (;; shut this up
+	(c-echo-syntactic-information-p nil))
+    (if (or arg
+	    (not (looking-at "[ \t]*$"))
+	    (c-in-literal (c-point 'bod)))
+	(self-insert-command (prefix-numeric-value arg))
+      ;; do some special stuff with the character
+      (let* (;; We want to inhibit blinking the paren since this will
+	     ;; be most disruptive.  We'll blink it ourselves
+	     ;; afterwards.
+	     (old-blink-paren blink-paren-function)
+	     blink-paren-function)
+	(self-insert-command (prefix-numeric-value arg))
+	(c-indent-line)
+	(when c-auto-newline
+	  ;; Do all appropriate clean ups
+	  (let ((here (point))
+		(pos (- (point-max) (point)))
+		mbeg mend)
+	    ;; clean up brace-elseif-brace
+	    (if (and (memq 'brace-elseif-brace c-cleanup-list)
+		     (eq last-command-char ?\()
+		     (re-search-backward "}[ \t\n]*else[ \t\n]+if[ \t\n]*("
+					 nil t)
+		     (save-excursion
+		       (setq mbeg (match-beginning 0)
+			     mend (match-end 0))
+		       (= mend here))
+		     (not (c-in-literal)))
+		(progn
+		  (delete-region mbeg mend)
+		  (insert "} else if (")))
+	    ;; clean up brace-catch-brace
+	    (if (and (memq 'brace-catch-brace c-cleanup-list)
+		     (eq last-command-char ?\()
+		     (re-search-backward "}[ \t\n]*catch[ \t\n]*(" nil t)
+		     (save-excursion
+		       (setq mbeg (match-beginning 0)
+			     mend (match-end 0))
+		       (= mend here))
+		     (not (c-in-literal)))
+		(progn
+		  (delete-region mbeg mend)
+		  (insert "} catch (")))
+	    (goto-char (- (point-max) pos))
+	    ))
+	(funcall old-blink-paren)))))
+
 
 
 ;; better movement routines for ThisStyleOfVariablesCommonInCPlusPlus
 An end of a defun occurs right after the close-parenthesis that matches
 the open-parenthesis that starts a defun; see `beginning-of-defun'."
   (interactive "p")
+  (if (not arg)
+      (setq arg 1))
   (if (< arg 0)
       (c-beginning-of-defun (- arg))
     (while (> arg 0)
       (while (and (c-safe (down-list 1) t)
 		  (not (eq (char-before) ?{)))
 	(forward-char -1)
-	(forward-sexp))
+	(c-forward-sexp))
       (c-beginning-of-defun 1)
-      (forward-sexp 1)
+      (c-forward-sexp 1)
       (setq arg (1- arg)))
     (forward-line 1))
   (c-keep-region-active))
 	;; perhaps they should be changed, but that'd likely break a
 	;; lot in cc-engine.
 	(goto-char here)
-	;; Move out of any enclosing non-`{ }' parens.
-	(let ((last (point)))
-	  (while (and (c-safe (progn (up-list 1) t))
-		      (/= (char-before) ?\}))
-	    (setq last (point)))
-	  (goto-char last))
 	(if (> count 0)
 	    (if (condition-case nil
 		    ;; Stop before `{' and after `;', `{', `}' and
-		    ;; `};' when not followed by `}', but on the other
-		    ;; side of the syntactic ws.  Also stop before
-		    ;; `}', but only to catch comments.  Move by sexps
-		    ;; and move into `{ }', but not into any other
-		    ;; other type of paren.
+		    ;; `};' when not followed by `}' or `)', but on
+		    ;; the other side of the syntactic ws.  Also stop
+		    ;; before `}', but only to catch comments.  Move
+		    ;; by sexps and move into parens.
 		    (catch 'done
 		      (let (last)
 			(while t
 				((progn (backward-char)
 					(looking-at "[;{}]"))
 				 (if (or (= here last)
-					 (= (char-after last) ?}))
+					 (memq (char-after last) '(?\) ?})))
 				     (if (and (= (char-before) ?})
 					      (= (char-after) ?\;))
 					 (backward-char))
 				   (goto-char last)
 				   (throw 'done t)))
-				((or (= (char-syntax (char-after)) ?\))
-				     (= (char-syntax (char-after)) ?\"))
+				((= (char-syntax (char-after)) ?\")
 				 (forward-char)
-				 (backward-sexp))
+				 (c-backward-sexp))
 				))))
 		  (error
 		   (goto-char (point-min))
 		   t))
 		(setq count (1- count)))
 	  (if (condition-case nil
-		  ;; Stop before `{' and `}' and after `;', `}' and
-		  ;; `};'.  Also stop after `{', but only to catch
-		  ;; comments.  Move by sexps and move into `{ }', but
-		  ;; not into any other other type of paren.
+		  ;; Stop before `{' and `}', but on the other side of
+		  ;; the syntactic ws, and after `;', `}' and `};'.
+		  ;; Only stop before `{' if at top level or inside
+		  ;; braces, though.  Also stop after `{', but only to
+		  ;; catch comments.  Move by sexps and move into
+		  ;; parens.
 		  (catch 'done
 		    (let (last)
 		      (while t
 			(setq last (point))
 			(c-forward-syntactic-ws)
 			(cond ((= (char-after) ?{)
-			       (if (= here last)
+			       (if (or (= here last)
+				       (save-excursion
+					 (and (c-safe (progn (up-list -1) t))
+					      (/= (char-after) ?{))))
 				   (progn (forward-char)
 					  (throw 'done nil))
 				 (goto-char last)
 			      ((looking-at ";\\|};?")
 			       (goto-char (match-end 0))
 			       (throw 'done t))
-			      ((or (= (char-syntax (char-after)) ?\()
-				   (= (char-syntax (char-after)) ?\"))
-			       (forward-sexp))
+			      ((= (char-syntax (char-after)) ?\")
+			       (c-forward-sexp))
 			      (t
 			       (forward-char))
 			      ))))
    c-electric-star
    c-electric-semi&comma
    c-electric-lt-gt
-   c-electric-colon))
+   c-electric-colon
+   c-electric-paren))
 (put 'c-electric-delete    'delete-selection 'supersede) ; delsel
 (put 'c-electric-delete    'pending-delete   'supersede) ; pending-del
 (put 'c-electric-backspace 'delete-selection 'supersede) ; delsel
 	 ((or (looking-at "^#[ \t]*endif[ \t]*")
 	      (looking-at "^#[ \t]*else[ \t]*"))
 	  7)
-	 ;; CASE 3: when comment-column is nil, calculate the offset
-	 ;; according to c-offsets-alist.  E.g. identical to hitting
-	 ;; TAB.
+	 ;; CASE 3: when c-indent-comments-syntactically-p is t,
+	 ;; calculate the offset according to c-offsets-alist.
+	 ;; E.g. identical to hitting TAB.
 	 ((and c-indent-comments-syntactically-p
 	       (save-excursion
 		 (skip-chars-forward " \t")
-		 (or (looking-at comment-start)
+		 (or (looking-at c-comment-start-regexp)
 		     (eolp))))
 	  (let ((syntax (c-guess-basic-syntax)))
 	    ;; BOGOSITY ALERT: if we're looking at the eol, its
   (let ((literal (c-in-literal))
 	at-comment-col)
     (cond
-     ((eq literal 'string))
+     ((eq literal 'string)
+      (insert ?\n))
      ((or (not c-comment-continuation-stars)
 	  (not literal))
       (indent-new-comment-line soft))
   just inserts a tab character, or the equivalent number of spaces,
   depending on the variable `indent-tabs-mode'."
 
-  (interactive "*P")
+  (interactive "P")
   (let ((bod (c-point 'bod)))
     (if whole-exp
 	;; If arg, always indent this line as C
 	    (if (eq c-tab-always-indent t)
 		(beginning-of-line))
 	    (setq beg (point))
-	    (forward-sexp 1)
+	    (c-forward-sexp 1)
 	    (setq end (point))
 	    (goto-char beg)
 	    (forward-line 1)
 				(memq (char-after) '(?\( ?\[ ?\{))
 				(point)))))))
 	  ;; find balanced expression end
-	  (setq end (and (c-safe (progn (forward-sexp 1) t))
+	  (setq end (and (c-safe (progn (c-forward-sexp 1) t))
 			 (point-marker)))
 	  ;; sanity check
 	  (and (not start)
 		    (while (< (point) nextline)
 		      (condition-case nil
 			  (progn
-			    (forward-sexp 1)
+			    (c-forward-sexp 1)
 			    (setq sexpend (point)))
 			(error (setq sexpend nil)
 			       (goto-char nextline)))
 		      (c-forward-syntactic-ws))
 		    (if sexpend
-			(progn 
+			(progn
 			  ;; make sure the sexp we found really starts on the
 			  ;; current line and extends past it
 			  (goto-char sexpend)
 			  (setq sexpend (point-marker))
-			  (c-safe (backward-sexp 1))
+			  (c-safe (c-backward-sexp 1))
 			  (setq sexpbeg (point))))
 		    (if (and sexpbeg (< sexpbeg fence))
 			(setq sexpbeg fence)))
 	))))
 
 (defun c-mark-function ()
-  "Put mark at end of a C, C++, or Objective-C defun, point at beginning."
+  "Put mark at end of current top-level defun, point at beginning."
   (interactive)
   (let ((here (point))
-	;; there should be a c-point position for 'eod
-	(eod  (save-excursion (end-of-defun) (point)))
-	(state (c-parse-state))
-	brace)
-    (while state
-      (setq brace (car state))
-      (if (consp brace)
-	  (goto-char (cdr brace))
-	(goto-char brace))
-      (setq state (cdr state)))
-    (if (eq (char-after) ?{)
-	(progn
-	  (forward-line -1)
-	  (while (not (or (bobp)
-			  (looking-at "[ \t]*$")))
-	    (forward-line -1)))
-      (forward-line 1)
-      (skip-chars-forward " \t\n"))
+	(eod (c-point 'eod))
+	(state (c-parse-state)))
+    ;; Are we sitting at the top level, someplace between either the
+    ;; beginning of buffer, or the nearest preceding defun?  If so,
+    ;; try first to figure out whether we're sitting on the
+    ;; introduction to a top-level defun, in which case we want to
+    ;; mark the entire defun we're sitting on.
+    ;;
+    ;; If we're sitting on anything else at the top-level, we want to
+    ;; just mark the statement that we're on
+    (if (or (and (consp (car state))
+		 (= (length state) 1))
+	    (null state))
+	;; Are we in the whitespace after the nearest preceding defun?
+	(if (and state
+		 (looking-at "[ \t]*$")
+		 (= (save-excursion
+		      (c-backward-syntactic-ws)
+		      (skip-chars-backward ";")
+		      (point))
+		    (cdar state)))
+	    (progn
+	      (setq eod (point))
+	      (goto-char (caar state))
+	      (c-beginning-of-statement-1))
+	  (if (= ?{ (save-excursion
+		      (c-end-of-statement-1)
+		      (char-before)))
+	      ;; We must be in a defuns's introduction
+	      (progn
+		(c-end-of-statement-1)
+		(skip-chars-backward "{")
+		(c-beginning-of-statement-1)
+		(c-forward-syntactic-ws))
+	    ;; Just mark the statement
+	    (c-end-of-statement-1)
+	    (forward-line 1)
+	    (setq eod (point))
+	    (c-beginning-of-statement-1)))
+      ;; We are inside some enclosing brace structure, so we first
+      ;; need to find our way to the least enclosing brace.  Then, in
+      ;; both cases, we to mark the region from the beginning of the
+      ;; current statement, until the end of the next following defun
+      (while (and state)
+	(or (consp (car state))
+	    (goto-char (car state)))
+	(setq state (cdr state)))
+      (c-beginning-of-statement-1))
     (push-mark here)
     (push-mark eod nil t)))
 
+(defun c-indent-line-or-region ()
+  "When the region is active, indent it.  Otherwise indent the current line."
+  ;; Emacs has a variable called mark-active, XEmacs uses region-active-p
+  (interactive)
+  (if (c-region-is-active-p)
+      (c-indent-region (region-beginning) (region-end))
+    (c-indent-command)))
+
 
 ;; for progress reporting
 (defvar c-progress-info nil)
 This function does not modify blank lines at the start of the region.
 If the region ends at the start of a line, it always deletes the
 backslash (if any) at the end of the previous line.
- 
+
 You can put the region around an entire macro definition and use this
 command to conveniently insert and align the necessary backslashes."
   (interactive "*r\nP")
 		     t)))
 	  ;; Inside a comment: fill one comment paragraph.
 	  (let ((fill-prefix
-		 ;; The prefix for each line of this paragraph
-		 ;; is the appropriate part of the start of this line,
-		 ;; up to the column at which text should be indented.
-		 (save-excursion
-		   (beginning-of-line)
-		   (if (looking-at ".*/\\*.*\\*/")
-		       (progn (re-search-forward comment-start-skip)
-			      (make-string (current-column) ?\ ))
-		     (if first-line
-			 (forward-line 1)
-		       (if (and (looking-at "[ \t]*\\*/")
-				(not (save-excursion
-				       (forward-line -1)
-				       (looking-at ".*/\\*"))))
-			   (forward-line -1)))
+		 (or
+		  ;; Keep user set fill prefix if any.
+		  fill-prefix
+		  ;; The prefix for each line of this paragraph
+		  ;; is the appropriate part of the start of this line,
+		  ;; up to the column at which text should be indented.
+		  (save-excursion
+		    (beginning-of-line)
+		    (if (looking-at ".*/\\*.*\\*/")
+			(progn (re-search-forward comment-start-skip)
+			       (make-string (current-column) ?\ ))
+		      (if first-line
+			  (forward-line 1)
+			(if (and (looking-at "[ \t]*\\*/")
+				 (not (save-excursion
+					(forward-line -1)
+					(looking-at ".*/\\*"))))
+			    (forward-line -1)))
 
-		     (let ((line-width (progn (end-of-line) (current-column))))
-		       (beginning-of-line)
-		       (prog1
-			   (buffer-substring
-			    (point)
+		      (let ((line-width (progn (end-of-line)
+					       (current-column))))
+			(beginning-of-line)
+			(prog1
+			    (buffer-substring
+			     (point)
 
-			    ;; How shall we decide where the end of the
-			    ;; fill-prefix is?
-			    (progn
-			      (skip-chars-forward " \t*" (c-point 'eol))
-			      ;; kludge alert, watch out for */, in
-			      ;; which case fill-prefix should *not*
-			      ;; be "*"!
-			      (if (and (eq (char-after) ?/)
-				       (eq (char-before) ?*))
-				  (forward-char -1))
-			      (point)))
+			     ;; How shall we decide where the end of the
+			     ;; fill-prefix is?
+			     (progn
+			       (skip-chars-forward " \t*" (c-point 'eol))
+			       ;; kludge alert, watch out for */, in
+			       ;; which case fill-prefix should *not*
+			       ;; be "*"!
+			       (if (and (eq (char-after) ?/)
+					(eq (char-before) ?*))
+				   (forward-char -1))
+			       (point)))
 
-			 ;; If the comment is only one line followed
-			 ;; by a blank line, calling move-to-column
-			 ;; above may have added some spaces and tabs
-			 ;; to the end of the line; the fill-paragraph
-			 ;; function will then delete it and the
-			 ;; newline following it, so we'll lose a
-			 ;; blank line when we shouldn't.  So delete
-			 ;; anything move-to-column added to the end
-			 ;; of the line.  We record the line width
-			 ;; instead of the position of the old line
-			 ;; end because move-to-column might break a
-			 ;; tab into spaces, and the new characters
-			 ;; introduced there shouldn't be deleted.
+			  ;; If the comment is only one line followed
+			  ;; by a blank line, calling move-to-column
+			  ;; above may have added some spaces and tabs
+			  ;; to the end of the line; the fill-paragraph
+			  ;; function will then delete it and the
+			  ;; newline following it, so we'll lose a
+			  ;; blank line when we shouldn't.  So delete
+			  ;; anything move-to-column added to the end
+			  ;; of the line.  We record the line width
+			  ;; instead of the position of the old line
+			  ;; end because move-to-column might break a
+			  ;; tab into spaces, and the new characters
+			  ;; introduced there shouldn't be deleted.
 
-			 ;; If you can see a better way to do this,
-			 ;; please make the change.  This seems very
-			 ;; messy to me.
-			 (delete-region (progn (move-to-column line-width)
-					       (point))
-					(progn (end-of-line) (point))))))))
+			  ;; If you can see a better way to do this,
+			  ;; please make the change.  This seems very
+			  ;; messy to me.
+			  (delete-region (progn (move-to-column line-width)
+						(point))
+					 (progn (end-of-line) (point)))))))))
 
 		;; Lines containing just a comment start or just an end
 		;; should not be filled into paragraphs they are next
 		;; to.
-		(paragraph-start (if (eq major-mode 'java-mode)
+		(paragraph-start (if (c-major-mode-is 'java-mode)
 				     (concat paragraph-start
 					     re1 "\\("
 					     c-Java-javadoc-paragraph-start
 		   (goto-char (car limits))
 		   (end-of-line)
 		   (< (point) (cdr limits))))
-	    (let (fill-prefix
-		  fill-paragraph-function)
+	    (let (fill-paragraph-function)
 	      (save-restriction
 		(narrow-to-region (save-excursion
 				    (goto-char (1+ (car limits)))

File cc-compat.el

 ;;; cc-compat.el --- cc-mode compatibility with c-mode.el confusion
 
-;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc.
+;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
 
 ;; Author:     1994-1997 Barry A. Warsaw
-;; Maintainer: cc-mode-help@python.org
+;; Maintainer: bug-cc-mode@gnu.org
 ;; Created:    August 1994, split from cc-mode.el
 ;; Version:    See cc-mode.el
 ;; Keywords:   c languages oop
 	      ;; line
 	      (progn
 		(if (eq (char-before) ?\))
-		    (forward-sexp -1))
+		    (c-forward-sexp -1))
 		;; Get initial indentation of the line we are on.
 		(current-indentation)))))
       (- bocm-lossage curcol))))
 
 ;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
 
-;; Authors:    1992-1997 Barry A. Warsaw
+;; Authors:    1998 Barry A. Warsaw and Martin Stjernholm
+;;             1992-1997 Barry A. Warsaw
 ;;             1987 Dave Detlefs and Stewart Clamen
 ;;             1985 Richard M. Stallman
-;; Maintainer: cc-mode-help@python.org
+;; Maintainer: bug-cc-mode@gnu.org
 ;; Created:    22-Apr-1997 (split from cc-mode.el)
 ;; Version:    See cc-mode.el
 ;; Keywords:   c languages oop
 ;; Get all the necessary compile time definitions.
 (require 'custom)
 (require 'cc-menus)
+(require 'derived)			;only necessary in Emacs 20
 
 ;; cc-mode-19.el contains compatibility macros that should be compiled
 ;; in if needed.
 (if (or (not (fboundp 'functionp))
-	(not (fboundp 'char-before))
+	(not (condition-case nil
+		 (progn (char-before) t)
+	       (error nil)))
 	(not (condition-case nil
 		 (progn (char-after) t)
 	       (error nil)))
   ;; bol  -- beginning of line
   ;; eol  -- end of line
   ;; bod  -- beginning of defun
+  ;; eod  -- end of defun
   ;; boi  -- back to indentation
   ;; ionl -- indentation of next line
   ;; iopl -- indentation of previous line
      ((eq position 'ionl)
       (forward-line 1)
       (back-to-indentation))
+     ((eq position 'eod)  (c-end-of-defun))
      ((eq position 'bod)
       (if (and (fboundp 'buffer-syntactic-context-depth)
 	       c-enable-xemacs-performance-kludge-p)
 	  ;; XEmacs only.  This can improve the performance of
 	  ;; c-parse-state to between 3 and 60 times faster when
-	  ;; braces are hung.  It can cause c-parse-state to be
-	  ;; slightly slower when braces are not hung, but general
-	  ;; editing appears to be still about as fast.
+	  ;; braces are hung.  It can also degrade performance by
+	  ;; about as much when braces are not hung.
 	  (let (pos)
 	    (while (not pos)
 	      (save-restriction
 	(point)
       (goto-char here))))
 
+
 (defmacro c-safe (&rest body)
   ;; safely execute BODY, return nil if an error occurred
   (` (condition-case nil
 	 (progn (,@ body))
        (error nil))))
 
+(defmacro c-forward-sexp (&optional arg)
+  ;; like forward-sexp except
+  ;;   1. this is much stripped down from the XEmacs version
+  ;;   2. this cannot be used as a command, so we're insulated from
+  ;;      XEmacs' losing efforts to make forward-sexp more user
+  ;;      friendly
+  ;;   3. Preserves the semantics most of CC Mode is based on
+  (or arg (setq arg 1))
+  `(goto-char (or (scan-sexps (point) ,arg)
+		  ,(if (numberp arg)
+		       (if (> arg 0) `(point-max) `(point-min))
+		     `(if (> ,arg 0) (point-max) (point-min))))))
+
+(defmacro c-backward-sexp (&optional arg)
+  ;; See c-forward-sexp and reverse directions
+  (or arg (setq arg 1))
+  `(c-forward-sexp ,(if (numberp arg) (- arg) `(- ,arg))))
+
 (defmacro c-add-syntax (symbol &optional relpos)
   ;; a simple macro to append the syntax in symbol to the syntax list.
   ;; try to increase performance by using this macro
   (and (boundp 'zmacs-region-stays)
        (setq zmacs-region-stays t)))
 
+(defsubst c-region-is-active-p ()
+  ;; Return t when the region is active.  The determination of region
+  ;; activeness is different in both Emacs and XEmacs.
+  (cond
+   ;; XEmacs
+   ((and (fboundp 'region-active-p)
+	 zmacs-regions)
+    (region-active-p))
+   ;; Emacs
+   ((boundp 'mark-active) mark-active)
+   ;; fallback; shouldn't get here
+   (t (mark t))))
+
+(defsubst c-major-mode-is (mode)
+  (eq (derived-mode-class major-mode) mode))
+
 
 (provide 'cc-defs)
 ;;; cc-defs.el ends here

File cc-engine.el

 
 ;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
 
-;; Authors:    1992-1997 Barry A. Warsaw
+;; Authors:    1998 Barry A. Warsaw and Martin Stjernholm
+;;             1992-1997 Barry A. Warsaw
 ;;             1987 Dave Detlefs and Stewart Clamen
 ;;             1985 Richard M. Stallman
-;; Maintainer: cc-mode-help@python.org
+;; Maintainer: bug-cc-mode@gnu.org
 ;; Created:    22-Apr-1997 (split from cc-mode.el)
 ;; Version:    See cc-mode.el
 ;; Keywords:   c languages oop
 	(if (bobp) (setq donep t)
 	  ;; go backwards one balanced expression, but be careful of
 	  ;; unbalanced paren being reached
-	  (if (not (c-safe (progn (backward-sexp 1) t)))
+	  (if (not (c-safe (progn (c-backward-sexp 1) t)))
 	      (progn
 		(if firstp
 		    (backward-up-list 1)
 		;; characters appearing at front of identifier
 		(save-excursion
 		  (c-backward-syntactic-ws lim)
-		  (skip-chars-backward "-+!*&:.~ \t\n")
+		  (skip-chars-backward "-+!*&:.~@ \t\n")
 		  (if (eq (char-before) ?\()
 		      (setq last-begin (point))))
 		(goto-char last-begin)
 	   ((or (looking-at c-conditional-key)
 		(and (eq (char-after) ?\()
 		     (save-excursion
-		       (forward-sexp 1)
+		       (c-forward-sexp 1)
 		       (c-forward-syntactic-ws)
 		       (not (eq (char-after) ?\;)))
 		     (let ((here (point))
 	    ;; are we in the middle of an else-if clause?
 	    (if (save-excursion
 		  (and (not substmt-p)
-		       (c-safe (progn (forward-sexp -1) t))
+		       (c-safe (progn (c-forward-sexp -1) t))
 		       (looking-at "\\<else\\>[ \t\n]+\\<if\\>")
 		       (not (c-in-literal lim))))
 		(progn
-		  (forward-sexp -1)
+		  (c-forward-sexp -1)
 		  (c-backward-to-start-of-if lim)))
 	    ;; are we sitting at an else clause, that we are not a
 	    ;; substatement of?
 	    (if (and (not substmt-p)
 		     (looking-at "\\<else\\>[^_]"))
 		(c-backward-to-start-of-if lim))
+	    ;; a finally or a series of catches?
+	    (if (not substmt-p)
+		(while (looking-at "\\<\\(catch\\|finally\\)\\>[^_]")
+		  (c-safe (c-backward-sexp 2))
+		  (if (eq (char-after) ?\()
+		      (c-safe (c-backward-sexp)))))
 	    ;; are we sitting at the while of a do-while?
 	    (if (and (looking-at "\\<while\\>[^_]")
 		     (c-backward-to-start-of-do lim))
 					 (point) last-begin))
 			 last-begin (point)))
 	   ;; CASE 6: have we crossed a statement barrier?
-	   ((c-crosses-statement-barrier-p (point) last-begin)
+	   ((save-excursion
+	      ;; Move over in-expression blocks before checking the
+	      ;; barrier
+	      (if (or (memq (char-after) '(?\( ?\[))
+		      (and (eq (char-after) ?{)
+			   (c-looking-at-inexpr-block lim)))
+		  (c-forward-sexp 1))
+	      (c-crosses-statement-barrier-p (point) last-begin))
 	    (setq donep t))
 	   ;; CASE 7: ignore labels
 	   ((and c-maybe-labelp
 	   (t (setq last-begin (point)))
 	   ))))
     (goto-char last-begin)
-    ;; we always do want to skip over non-whitespace modifier
-    ;; characters that didn't get skipped above
-    (skip-chars-backward "-+!*&:.~" (c-point 'boi))))
+    ;; We always want to skip over the non-whitespace modifier
+    ;; characters that can start a statement.
+    (let ((lim (point)))
+      (skip-chars-backward "-+!*&~@ \t\n" (c-point 'boi))
+      (skip-chars-forward " \t\n" lim))))
 
 (defun c-end-of-statement-1 ()
   (condition-case nil
 	(while (and (not (eobp))
 		    (progn
 		      (setq beg (point))
-		      (forward-sexp 1)
+		      (c-forward-sexp 1)
 		      (setq end (point))
 		      (goto-char beg)
 		      (setq found nil)
 	  (goto-char from)
 	  (while (and (not crossedp)
 		      (< (point) to))
-	    (skip-chars-forward "^;{}:" to)
+	    (skip-chars-forward "^;{}:" (1- to))
 	    (if (not (c-in-literal lim))
 		(progn
 		  (if (memq (char-after) '(?\; ?{ ?}))
 
 
 ;; Moving by tokens, where a token is defined as all symbols and
-;; identifiers which aren't syntactic whitespace.  COUNT specifies the
-;; number of tokens to move forward; a negative COUNT moves backward.
-;; If BALANCED is true, move over balanced parens, otherwise move into
-;; them.  Also, if BALANCED is true, never move out of an enclosing
-;; paren.  LIM sets the limit for the movement.  Point is always left
-;; at the beginning of a token or at LIM.  Returns the number of
+;; identifiers which aren't syntactic whitespace (note that "->" is
+;; considered to be two tokens).  Point is always either left at the
+;; beginning of a token or not moved at all.  COUNT specifies the
+;; number of tokens to move; a negative COUNT moves in the opposite
+;; direction.  A COUNT of 0 moves to the next token beginning only if
+;; not already at one.  If BALANCED is true, move over balanced
+;; parens, otherwise move into them.  Also, if BALANCED is true, never
+;; move out of an enclosing paren.  LIM sets the limit for the
+;; movement and defaults to the point limit.  Returns the number of
 ;; tokens left to move (positive or negative).  If BALANCED is true, a
-;; move over a balanced paren counts as one.
+;; move over a balanced paren counts as one.  Note that if COUNT is 0
+;; and no appropriate token beginning is found, 1 will be returned.
+;; Thus, a return value of 0 guarantees that point is at the requested
+;; position and a return value less (without signs) than COUNT
+;; guarantees that point is at the beginning of some token.
 
 (defun c-forward-token-1 (&optional count balanced lim)
-  (let* ((jump-syntax (if balanced
-			  '(?w ?_ ?\" ?\\ ?/ ?$ ?' ?\( ?\))
-			'(?w ?_ ?\" ?\\ ?/ ?$ ?'))))
-    (or count (setq count 1))
-    (condition-case nil
-	(while (progn
-		 (c-forward-syntactic-ws lim)
-		 (> count 0))
-	  (if (memq (char-syntax (char-after)) jump-syntax)
-	      (goto-char (scan-sexps (point) 1))
-	    (forward-char))
-	  (setq count (1- count)))
-      (error
-       (and lim (> (point) lim) (goto-char lim))))
-    count))
+  (or count (setq count 1))
+  (if (< count 0)
+      (- (c-backward-token-1 (- count) balanced lim))
+    (let ((jump-syntax (if balanced
+			   '(?w ?_ ?\( ?\) ?\" ?\\ ?/ ?$ ?')
+			 '(?w ?_ ?\" ?\\ ?/ ?')))
+	  (last (point))
+	  (prev (point)))
+      (if (/= (point)
+	      (progn (c-forward-syntactic-ws) (point)))
+	  ;; Skip whitespace.  Count this as a move if we did in fact
+	  ;; move and aren't out of bounds.
+	  (or (eobp)
+	      (and lim (> (point) lim))
+	      (setq count (max (1- count) 0))))
+      (if (and (= count 0)
+	       (or (and (memq (char-syntax (or (char-after) ? )) '(?w ?_))
+			(memq (char-syntax (or (char-before) ? )) '(?w ?_)))
+		   (eobp)))
+	  ;; If count is zero we should jump if in the middle of a
+	  ;; token or if there is whitespace between point and the
+	  ;; following token beginning.
+	  (setq count 1))
+      ;; Avoid having the limit tests inside the loop.
+      (save-restriction
+	(if lim (narrow-to-region (point-min) lim))
+	(if (eobp)
+	    (goto-char last)
+	  (condition-case nil
+	      (while (> count 0)
+		(setq prev last
+		      last (point))
+		(if (memq (char-syntax (char-after)) jump-syntax)
+		    (goto-char (scan-sexps (point) 1))
+		  (forward-char))
+		(c-forward-syntactic-ws lim)
+		(setq count (1- count)))
+	    (error (goto-char last)))
+	  (when (eobp)
+	    (goto-char prev)
+	    (setq count (1+ count)))))
+      count)))
 
 (defun c-backward-token-1 (&optional count balanced lim)
-  (let* ((jump-syntax (if balanced
-			  '(?w ?_ ?\" ?\\ ?/ ?$ ?' ?\( ?\))
-			'(?w ?_ ?\" ?\\ ?/ ?$ ?')))
-	 last)
-    (or count (setq count 1))
-    (condition-case nil
-	(while (> count 0)
-	  (setq last (point))
-	  (c-backward-syntactic-ws lim)
-	  (if (memq (char-syntax (char-before)) jump-syntax)
-	      (goto-char (scan-sexps (point) -1))
-	    (backward-char))
-	  (setq count (1- count)))
-      (error
-       (goto-char last)
-       (and lim (< (point) lim) (goto-char lim))))
-    count))
+  (or count (setq count 1))
+  (if (< count 0)
+      (- (c-forward-token-1 (- count) balanced lim))
+    (let ((jump-syntax (if balanced
+			   '(?w ?_ ?\( ?\) ?\" ?\\ ?/ ?$ ?')
+			 '(?w ?_ ?\" ?\\ ?/ ?')))
+	  last)
+      (if (and (= count 0)
+	       (or (and (memq (char-syntax (or (char-after) ? )) '(?w ?_))
+			(memq (char-syntax (or (char-before) ? )) '(?w ?_)))
+		   (/= (point)
+		       (save-excursion (c-forward-syntactic-ws) (point)))
+		   (eobp)))
+	  ;; If count is zero we should jump if in the middle of a
+	  ;; token or if there is whitespace between point and the
+	  ;; following token beginning.
+	  (setq count 1))
+      ;; Avoid having the limit tests inside the loop.
+      (save-restriction
+	(if lim (narrow-to-region lim (point-max)))
+	(or (bobp)
+	    (progn
+	      (condition-case nil
+		  (while (progn
+			   (setq last (point))
+			   (> count 0))
+		    (c-backward-syntactic-ws lim)
+		    (if (memq (char-syntax (char-before)) jump-syntax)
+			(goto-char (scan-sexps (point) -1))
+		      (backward-char))
+		    (setq count (1- count)))
+		(error (goto-char last)))
+	      (if (bobp) (goto-char last)))))
+      count)))
 
 
 ;; Return `c' if in a C-style comment, `c++' if in a C++ style
 (if (fboundp 'buffer-syntactic-context)
     (defalias 'c-in-literal 'c-fast-in-literal))
 
-(defun c-literal-limits (&optional lim)
+(defun c-literal-limits (&optional lim near)
   ;; Returns a cons of the beginning and end positions of the comment
   ;; or string surrounding point (including both delimiters), or nil
-  ;; if point isn't in one.  This is the Emacs 19 version.
+  ;; if point isn't in one.  If LIM is non-nil, it's used as the
+  ;; "safe" position to start parsing from.  If NEAR is non-nil, then
+  ;; the limits of any literal next to point is returned.  "Next to"
+  ;; means there's only [ \t] between point and the literal.  The
+  ;; search for such a literal is done first in forward direction.
+  ;;
+  ;; This is the Emacs 19 version.
   (save-excursion
-    (let* ((lim (or lim (c-point 'bod)))
+    (let* ((pos (point))
+	   (lim (or lim (c-point 'bod)))
 	   (state (parse-partial-sexp lim (point))))
       (cond ((nth 3 state)
 	     ;; String.  Search backward for the start.
 	     (while (nth 3 state)
 	       (search-backward (make-string 1 (nth 3 state)))
 	       (setq state (parse-partial-sexp lim (point))))
-	     (cons (point) (or (c-safe (forward-sexp 1) (point))
+	     (cons (point) (or (c-safe (c-forward-sexp 1) (point))
 			       (point-max))))
 	    ((nth 7 state)
-	     ;; C++ comment.  Search from bol for the comment starter.
+	     ;; Line comment.  Search from bol for the comment starter.
 	     (beginning-of-line)
 	     (setq state (parse-partial-sexp lim (point))
 		   lim (point))
 	     (backward-char 2)
 	     (cons (point) (progn (forward-comment 1) (point))))
 	    ((nth 4 state)
-	     ;; C comment.  Search backward for the comment starter.
+	     ;; Block comment.  Search backward for the comment starter.
 	     (while (nth 4 state)
 	       (search-backward "/*")	; Should never fail.
 	       (setq state (parse-partial-sexp lim (point))))
 	     ;; We're standing in a comment starter.
 	     (backward-char 2)
 	     (cons (point) (progn (forward-comment 1) (point))))
+	    (near
+	     (goto-char pos)
+	     ;; Search forward for a literal.
+	     (skip-chars-forward " \t")
+	     (cond
+	      ((eq (char-syntax (or (char-after) ?\ )) ?\") ; String.
+	       (cons (point) (or (c-safe (c-forward-sexp 1) (point))
+				 (point-max))))
+	      ((looking-at "/[/*]")	; Line or block comment.
+	       (cons (point) (progn (forward-comment 1) (point))))
+	      (t
+	       ;; Search backward.
+	       (skip-chars-backward " \t")
+	       (let ((end (point)) beg)
+		 (cond
+		  ((eq (char-syntax (or (char-before) ?\ )) ?\") ; String.
+		   (setq beg (c-safe (c-backward-sexp 1) (point))))
+		  ((and (c-safe (forward-char -2) t)
+			(looking-at "*/"))
+		   ;; Block comment.  Due to the nature of line
+		   ;; comments, they will always be covered by the
+		   ;; normal case above.
+		   (goto-char end)
+		   (forward-comment -1)
+		   ;; If LIM is bogus, beg will be bogus.
+		   (setq beg (point))))
+		 (if beg (cons beg end))))))
 	    ))))
 
 (defun c-literal-limits-fast (&optional lim)
-  ;; Returns a cons of the beginning and end positions of the comment
-  ;; or string surrounding point (including both delimiters), or nil
-  ;; if point isn't in one.  This is for emacsen whose
-  ;; `parse-partial-sexp' returns the pos of the comment start.
+  ;; Like c-literal-limits, but for emacsen whose `parse-partial-sexp'
+  ;; returns the pos of the comment start.  FIXME: Add NEAR.
   (save-excursion
     (let ((state (parse-partial-sexp lim (point))))
       (cond ((nth 3 state)		; String.
 	     (goto-char (nth 8 state))
-	     (cons (point) (or (c-safe (forward-sexp 1) (point))
+	     (cons (point) (or (c-safe (c-forward-sexp 1) (point))
 			       (point-max))))
 	    ((nth 4 state)		; Comment.
 	     (goto-char (nth 8 state))
 	  range)
       (error range))))
 
+(defun c-literal-type (range)
+  ;; Convenience function that given the result of c-literal-limits,
+  ;; returns nil or the type of literal that the range surrounds.
+  ;; It's much faster than using c-in-literal and is intended to be
+  ;; used when you need both the type of a literal and its limits.
+  (if (consp range)
+    (save-excursion
+      (goto-char (car range))
+      (cond ((eq (char-syntax (or (char-after) ?\ )) ?\") 'string)
+	    ((looking-at "//") 'c++)
+	    (t 'c)))			; Assuming the range is valid.
+    range))
+
 
 
 ;; utilities for moving and querying around syntactic elements
 		  (let ((cnt 2))
 		    (while (not (or at-bob (zerop cnt)))
 		      (goto-char (c-point 'bod))
-		      (if (eq (char-after) ?\{)
+		      (if (and
+			   (eq (char-after) ?\{)
+			   ;; The following catches an obscure special
+			   ;; case where the brace is preceded by an
+			   ;; open paren.  That can only legally occur
+			   ;; with blocks inside expressions and in
+			   ;; Pike special brace lists.  Even so, this
+			   ;; test is still bogus then, but hopefully
+			   ;; good enough.  (We don't want to use
+			   ;; up-list here since it might be slow.)
+			   (save-excursion
+			     (c-backward-syntactic-ws)
+			     (not (eq (char-before) ?\())))
 			  (setq cnt (1- cnt)))
 		      (if (bobp)
 			  (setq at-bob t))))
 
 (defun c-adjust-state (from to shift state)
   ;; Adjust all points in state that lie in the region FROM..TO by
-  ;; SHIFT amount (as would be returned by c-indent-line).
+  ;; SHIFT amount.
   (mapcar
    (function
     (lambda (e)
 	   ;; check if we are looking at a method def
 	   (or (not c-method-key)
 	       (progn
-		 (forward-sexp -1)
+		 (c-forward-sexp -1)
 		 (forward-char -1)
 		 (c-backward-syntactic-ws)
 		 (not (or (memq (char-before) '(?- ?+))
 			  ;; or a class category
 			  (progn
-			    (forward-sexp -2)
+			    (c-forward-sexp -2)
 			    (looking-at c-class-key))
 			  )))))
       )))
       ;; while is not associated with a do will throw an error
       (condition-case nil
 	  (progn
-	    (backward-sexp 1)
+	    (c-backward-sexp 1)
 	    (cond
 	     ;; break infloop for illegal C code
 	     ((bobp) (setq do-level 0))
 		  (not (zerop if-level)))
 	(c-backward-syntactic-ws)
 	(condition-case nil
-	    (backward-sexp 1)
+	    (c-backward-sexp 1)
 	  (error
 	   (if at-if
 	       (throw 'orphan-if nil)
 	 ((looking-at "if\\b[^_]")
 	  ;; check for else if... skip over
 	  (let ((here (point)))
-	    (c-safe (forward-sexp -1))
+	    (c-safe (c-forward-sexp -1))
 	    (if (looking-at "\\<else\\>[ \t]+\\<if\\>")
 		nil
 	      (setq if-level (1- if-level))
 (defun c-skip-conditional ()
   ;; skip forward over conditional at point, including any predicate
   ;; statements in parentheses. No error checking is performed.
-  (forward-sexp (cond
-		 ;; else if()
-		 ((looking-at "\\<else\\>[ \t]+\\<if\\>") 3)
-		 ;; do, else, try, finally
-		 ((looking-at "\\<\\(do\\|else\\|try\\|finally\\)\\>") 1)
-		 ;; for, if, while, switch, catch, synchronized
-		 (t 2))))
+  (c-forward-sexp (cond
+		   ;; else if()
+		   ((looking-at "\\<else\\>[ \t]+\\<if\\>") 3)
+		   ;; do, else, try, finally
+		   ((looking-at "\\<\\(do\\|else\\|try\\|finally\\)\\>") 1)
+		   ;; for, if, while, switch, catch, synchronized
+		   (t 2))))
 
 (defun c-skip-case-statement-forward (state &optional lim)
   ;; skip forward over case/default bodies, with optional maximal
 
 (defun c-search-uplist-for-classkey (brace-state)
   ;; search for the containing class, returning a 2 element vector if
-  ;; found. aref 0 contains the bufpos of the class key, and aref 1
-  ;; contains the bufpos of the open brace.
+  ;; found. aref 0 contains the bufpos of the boi of the class key
+  ;; line, and aref 1 contains the bufpos of the open brace.
   (if (null brace-state)
       ;; no brace-state means we cannot be inside a class
       nil
 	    (goto-char search-start)
 	    (let ((search-key (concat c-class-key "\\|" c-extra-toplevel-key))
 		  foundp class match-end)
+	      (if c-inexpr-class-key
+		  (setq search-key (concat search-key "\\|"
+					   c-inexpr-class-key)))
 	      (while (and (not foundp)
 			  (progn
 			    (c-forward-syntactic-ws)
 		   ;; class definition, and not a forward decl, return
 		   ;; arg, template arg list, or an ObjC or Java method.
 		   ((and c-method-key
-			 (re-search-forward c-method-key search-end t))
+			 (re-search-forward c-method-key search-end t)
+			 (not (c-in-literal class)))
 		    (setq foundp nil))
+		   ;; Check if this is an anonymous inner class.
+		   ((and c-inexpr-class-key
+			 (looking-at c-inexpr-class-key))
+		    (while (and (= (c-forward-token-1 1 t) 0)
+				(looking-at "(\\|\\w\\|\\s_\\|\\.")))
+		    (if (eq (point) search-end)
+			;; We're done.  Just trap this case in the cond.
+			nil
+		      ;; False alarm; all conditions aren't satisfied.
+		      (setq foundp nil)))
 		   ;; Its impossible to define a regexp for this, and
 		   ;; nearly so to do it programmatically.
 		   ;;
 			(skip-chars-backward "^<>" search-start)
 			(if (eq (char-before) ?<)
 			    (setq skipchars (concat skipchars ">"))))
-		      (skip-chars-forward skipchars search-end)
+		      (while (progn
+			       (skip-chars-forward skipchars search-end)
+			       (c-in-literal class))
+			(forward-char))
 		      (/= (point) search-end))
 		    (setq foundp nil))
 		   )))
    (c-safe
     (save-excursion
       (goto-char containing-sexp)
-      (forward-sexp -1)
+      (c-forward-sexp -1)
       (let (bracepos)
 	(if (and (or (looking-at "enum[\t\n ]+")
-		     (progn (forward-sexp -1)
+		     (progn (c-forward-sexp -1)
 			    (looking-at "enum[\t\n ]+")))
 		 (setq bracepos (c-safe (scan-lists (point) 1 -1)))
 		 (not (c-crosses-statement-barrier-p (point)
 	    (point)))))
    ;; this will pick up array/aggregate init lists, even if they are nested.
    (save-excursion
-     (let (bufpos okp)
+     (let ((class-key
+	    ;; Pike can have class definitions anywhere, so we must
+	    ;; check for the class key here.
+	    (and (c-major-mode-is 'pike-mode)
+		 (concat c-class-key "\\|" c-extra-toplevel-key)))
+	   bufpos lim braceassignp)
        (while (and (not bufpos)
 		   containing-sexp)
 	 (if (consp containing-sexp)
 	     (setq containing-sexp (car brace-state)
 		   brace-state (cdr brace-state))
-	   ;; see if the open brace is preceded by a = in this statement
 	   (goto-char containing-sexp)
-	   (setq okp t)
-	   (while (and (setq okp (= (c-backward-token-1 1 t) 0))
-		       (not (memq (char-after) '(?= ?{ ?\;)))))
-	   (if (not (and okp (eq (char-after) ?=)))
-	       ;; lets see if we're nested. find the most nested
-	       ;; containing brace
-	       (setq containing-sexp (car brace-state)
-		     brace-state (cdr brace-state))
-	     ;; we've hit the beginning of the aggregate list
-	     (c-beginning-of-statement-1 (c-most-enclosing-brace brace-state))
-	     (setq bufpos (point)))
+	   (if (c-looking-at-inexpr-block)
+	       ;; We're in an in-expression block of some kind.  Do
+	       ;; not check nesting.
+	       (setq containing-sexp nil)
+	     ;; see if the open brace is preceded by = or [...] in
+	     ;; this statement, but watch out for operator=
+	     (setq lim (if (consp (car brace-state))
+			   (cdr (car brace-state))
+			 (car brace-state))
+		   braceassignp 'dontknow)
+	     (while (and (eq braceassignp 'dontknow)
+			 (zerop (c-backward-token-1 1 t lim)))
+	       (cond ((eq (char-after) ?\;)
+		      (setq braceassignp nil))
+		     ((and class-key
+			   (looking-at class-key))
+		      (setq braceassignp nil))
+		     ((eq (char-after) ?=)
+		      ;; We've seen a =, but must check earlier tokens so
+		      ;; that it isn't something that should be ignored.
+		      (setq braceassignp 'maybe)
+		      (while (and (eq braceassignp 'maybe)
+				  (zerop (c-backward-token-1 1 t lim)))
+			(setq braceassignp
+			      (cond
+			       ;; Check for operator =
+			       ((looking-at "operator\\>") nil)
+			       ;; Check for `<opchar>= (Pike)
+			       ((eq (char-after) ?`) nil)
+			       ((looking-at "\\s.") 'maybe)
+			       ;; make sure we're not in a C++ template
+			       ;; argument assignment
+			       ((save-excursion
+				  (let ((here (point))
+					(pos< (progn
+						(skip-chars-backward "^<")
+						(point))))
+				    (and (c-major-mode-is 'c++-mode)
+					 (eq (char-before) ?<)
+					 (not (c-crosses-statement-barrier-p
+					       here pos<))
+					 ;; make sure we're not in a
+					 ;; #include <thing.h>.  Note
+					 ;; *cannot* use
+					 ;; c-backward-token-1 here!
+					 (save-excursion
+					   (forward-sexp -1)
+					   (or (not (eq (char-before) ?#))
+					       (not
+						(looking-at "include[ \t]*"))
+					       ))
+					 )))
+				nil)
+			       (t t)))))
+		     ((eq (char-after) ?\[)
+		      ;; In Java, an initialization brace list may
+		      ;; follow "new Foo[]", so check for [].  Got to
+		      ;; watch out for the C++ "operator[]" defun,
+		      ;; though.
+		      (setq braceassignp
+			    (save-excursion
+			      (c-backward-token-1)
+			      (not (looking-at "operator\\>")))))
+		     ))
+	     (if (memq braceassignp '(nil dontknow))
+		 (if (eq (char-after) ?\;)
+		     ;; Brace lists can't contain a semicolon, so we're done.
+		     (setq containing-sexp nil)
+		   ;; lets see if we're nested. find the most nested
+		   ;; containing brace
+		   (setq containing-sexp (car brace-state)
+			 brace-state (cdr brace-state)))
+	       ;; we've hit the beginning of the aggregate list
+	       (c-beginning-of-statement-1
+		(c-most-enclosing-brace brace-state))
+	       (setq bufpos (point))))
 	   ))
        bufpos))
    ))
 
+(defun c-looking-at-special-brace-list (&optional lim)
+  ;; If we're looking at the start of a pike-style list, ie `({�})',
+  ;; `([�])', `(<�>)' etc, a cons of a cons its starting and ending
+  ;; positions and its entry in c-special-brace-lists is returned, nil
+  ;; otherwise.  The ending position is nil if the list is still open.
+  ;; LIM is the limit for forward search.  The point may either be at
+  ;; the `(' or at the following paren character.  Tries to check the
+  ;; matching closer, but assumes it's correct if no balanced paren is
+  ;; found (i.e. the case `({ ... } ... )' is detected as _not_ being
+  ;; a special brace list).
+  (if c-special-brace-lists
+      (condition-case ()
+	  (save-excursion
+	    (let ((beg (point))
+		  end type)
+	      (c-forward-syntactic-ws)
+	      (if (eq (char-after) ?\()
+		  (progn
+		    (forward-char 1)
+		    (c-forward-syntactic-ws)
+		    (setq type (assq (char-after) c-special-brace-lists)))
+		(if (setq type (assq (char-after) c-special-brace-lists))
+		    (progn
+		      (c-backward-syntactic-ws)
+		      (forward-char -1)
+		      (setq beg (if (eq (char-after) ?\()
+				    (point)
+				  nil)))))
+	      (if (and beg type)
+		  (if (and (c-safe (goto-char beg)
+				   (c-forward-sexp 1)
+				   (setq end (point))
+				   (= (char-before) ?\)))
+			   (c-safe (goto-char beg)
+				   (forward-char 1)
+				   (c-forward-sexp 1)
+				   ;; Kludges needed to handle inner
+				   ;; chars both with and without
+				   ;; paren syntax.
+				   (or (/= (char-syntax (char-before)) ?\))
+				       (= (char-before) (cdr type)))))
+		      (if (or (/= (char-syntax (char-before)) ?\))
+			      (= (progn
+				   (c-forward-syntactic-ws)
+				   (point))
+				 (1- end)))
+			  (cons (cons beg end) type))
+		    (cons (list beg) type)))))
+	(error nil))))
+
+(defun c-looking-at-inexpr-block (&optional lim)
+  ;; Returns non-nil if we're looking at the beginning of a block
+  ;; inside an expression.  The value returned is actually a cons of
+  ;; either 'inlambda, 'inexpr-statement or 'inexpr-class and the
+  ;; position of the beginning of the construct.  LIM limits the
+  ;; backward search.
+  (save-excursion
+    (or lim (setq lim (point-min)))
+    (if (and (eq (char-after) ?{)
+	     (progn (c-backward-syntactic-ws) (> (point) lim))
+	     (eq (char-before) ?\()
+	     (not (and c-special-brace-lists
+		       (c-looking-at-special-brace-list))))
+	(cons 'inexpr-statement (point))
+      (let (res)
+	(while (and (not res)
+		    (= (c-backward-token-1 1 t lim) 0)
+		    (>= (point) lim)
+		    (looking-at "(\\|\\w\\|\\s_\\|\\."))
+	  (setq res
+		(cond ((and c-inexpr-class-key
+			    (looking-at c-inexpr-class-key))
+		       (cons 'inexpr-class (point)))
+		      ((and c-inexpr-block-key
+			    (looking-at c-inexpr-block-key))
+		       (cons 'inexpr-statement (point)))
+		      ((and c-lambda-key
+			    (looking-at c-lambda-key))
+		       (cons 'inlambda (point))))))
+	res))))
+
+(defun c-looking-at-inexpr-block-backward (&optional lim)
+  ;; Returns non-nil if we're looking at the end of an in-expression
+  ;; block, otherwise the same as `c-looking-at-inexpr-block'.
+  (save-excursion
+    (let ((lim (or lim (c-point 'bod))))
+      (c-safe
+       (c-backward-syntactic-ws lim)
+       (if (eq (char-before) ?})	; Recognize only a block currently.
+	   (progn
+	     (c-forward-sexp -1)
+	     (if (>= (point) lim)
+		 (c-looking-at-inexpr-block lim))))))))
+
 
 (defun c-most-enclosing-brace (state)
   ;; return the bufpos of the most enclosing brace that hasn't been
     ;; return the class vector
     inclass-p))
 
+(defsubst c-add-class-syntax (symbol classkey)
+  ;; The inclass and class-close syntactic symbols are added in
+  ;; several places and some work is needed to fix everything.
+  ;; Therefore it's collected here.
+  (save-restriction
+    (widen)
+    (goto-char (aref classkey 1))
+    (if (and (eq symbol 'inclass) (= (point) (c-point 'boi)))
+	(c-add-syntax symbol (point))
+      (c-add-syntax symbol (aref classkey 0))
+      (if (and c-inexpr-class-key (c-looking-at-inexpr-block))
+	  (c-add-syntax 'inexpr-class)))))
+
 
 ;; This function implements the main decision tree for determining the
 ;; syntactic analysis of the current line of code.  Yes, it's huge and
 	     (case-fold-search nil)
 	     (fullstate (c-parse-state))
 	     (state fullstate)
-	     (in-method-intro-p (and (eq major-mode 'objc-mode)
+	     (in-method-intro-p (and (c-major-mode-is 'objc-mode)
 				     c-method-key
 				     (looking-at c-method-key)))
 	     literal containing-sexp char-before-ip char-after-ip lim
 	     syntax placeholder c-in-literal-cache inswitch-p
-	     tmpsymbol keyword injava-inher
+	     tmpsymbol keyword injava-inher special-brace-list
 	     ;; narrow out any enclosing class or extern "C" block
 	     (inclass-p (c-narrow-out-enclosing-class state indent-point))
 	     inenclosing-p)
 	    (if (and inclass-p
 		     (progn
 		       (goto-char (aref inclass-p 0))
-		       (looking-at c-extra-toplevel-key)))
+		       (looking-at (concat c-extra-toplevel-key "[^_]"))))
 		(let ((enclosing (match-string 1)))
 		  (cond
 		   ((string-equal enclosing "extern")
 	 ;; CASE 5: Line is at top level.
 	 ((null containing-sexp)
 	  (cond
-	   ;; CASE 5A: we are looking at a defun, class, or
-	   ;; inline-inclass method opening brace
-	   ((eq char-after-ip ?{)
+	   ;; CASE 5A: we are looking at a defun, brace list, class,
+	   ;; or inline-inclass method opening brace
+	   ((setq special-brace-list
+		  (or (and c-special-brace-lists
+			   (c-looking-at-special-brace-list))
+		      (eq char-after-ip ?{)))
 	    (cond
 	     ;; CASE 5A.1: extern language or namespace construct
 	     ((save-excursion
 		(goto-char indent-point)
 		(skip-chars-forward " \t")
-		(and (c-safe (progn (backward-sexp 2) t))
-		     (looking-at c-extra-toplevel-key)
+		(and (c-safe (progn (c-backward-sexp 2) t))
+		     (looking-at (concat c-extra-toplevel-key "[^_]"))
 		     (setq keyword (match-string 1)
 			   placeholder (point))
 		     (or (and (string-equal keyword "namespace")
 			      (setq tmpsymbol 'namespace-open))
 			 (and (string-equal keyword "extern")
 			      (progn
-				(forward-sexp 1)
+				(c-forward-sexp 1)
 				(c-forward-syntactic-ws)
 				(eq (char-after) ?\"))
 			      (setq tmpsymbol 'extern-lang-open)))
 		(and (bobp)
 		     (c-forward-syntactic-ws indent-point))
 		(if (looking-at "typedef[^_]")
-		    (progn (forward-sexp 1)
+		    (progn (c-forward-sexp 1)
 			   (c-forward-syntactic-ws indent-point)))
 		(setq placeholder (c-point 'boi))
-		(and (or (looking-at "enum[ \t\n]+")
+		(or (consp special-brace-list)
+		    (and (or (looking-at "enum[ \t\n]+")
+			     (save-excursion
+			       (goto-char indent-point)
+			       (while (and (> (point) placeholder)
+					   (= (c-backward-token-1 1 t) 0)
+					   (/= (char-after) ?=)))
+			       (eq (char-after) ?=)))
 			 (save-excursion
-			   (goto-char indent-point)
-			   (while (and (> (point) placeholder)
-				       (= (c-backward-token-1 1 t) 0)
-				       (/= (char-after) ?=)))
-			   (eq (char-after) ?=)))
-		     (save-excursion
-		       (skip-chars-forward "^;(" indent-point)
-		       (not (memq (char-after) '(?\; ?\()))
-		       )))
+			   (while (and (< (point) indent-point)
+				       (= (c-forward-token-1 1 t) 0)
+				       (not (memq (char-after) '(?\; ?\()))))
+			   (not (memq (char-after) '(?\; ?\()))
+			   ))))
 	      (c-add-syntax 'brace-list-open placeholder))
 	     ;; CASE 5A.4: inline defun open
 	     ((and inclass-p (not inenclosing-p))
 	      (c-add-syntax 'inline-open)
-	      (c-add-syntax 'inclass (aref inclass-p 0)))
+	      (c-add-class-syntax 'inclass inclass-p))
 	     ;; CASE 5A.5: ordinary defun open
 	     (t
 	      (goto-char placeholder)
 		  (progn (forward-char -1)
 			 (c-backward-syntactic-ws lim)))
 	      (if (eq (char-before) ?\))
-		  (backward-sexp 1))
+		  (c-backward-sexp 1))
 	      (setq placeholder (point))
 	      (save-excursion
-		(and (c-safe (backward-sexp 1) t)
+		(and (c-safe (c-backward-sexp 1) t)
 		     (looking-at "throw[^_]")
-		     (c-safe (backward-sexp 1) t)
+		     (c-safe (c-backward-sexp 1) t)
 		     (setq placeholder (point))))
 	      (goto-char placeholder)
 	      (c-add-syntax 'member-init-intro (c-point 'boi))
 	     ;; CASE 5B.2: K&R arg decl intro
 	     (c-recognize-knr-p
 	      (c-add-syntax 'knr-argdecl-intro (c-point 'boi))
-	      (and inclass-p (c-add-syntax 'inclass (aref inclass-p 0))))
+	      (if inclass-p (c-add-class-syntax 'inclass inclass-p)))
 	     ;; CASE 5B.3: Nether region after a C++ or Java func
 	     ;; decl, which could include a `throws' declaration.
 	     (t
 		       (back-to-indentation)
 		       (looking-at c-class-key)))
 		;; for Java
-		(and (eq major-mode 'java-mode)
+		(and (c-major-mode-is 'java-mode)
 		     (let ((fence (save-excursion
 				    (c-beginning-of-statement-1 lim)
 				    (point)))
 			   (cond ((looking-at c-Java-special-key)
 				  (setq injava-inher (cons cont (point))
 					done t))
-				 ((or (not (c-safe (forward-sexp -1) t))
+				 ((or (not (c-safe (c-forward-sexp -1) t))
 				      (<= (point) fence))
 				  (setq done t))
 				 )
 	     ;; CASE 5C.2: hanging colon on an inher intro
 	     ((eq char-before-ip ?:)
 	      (c-add-syntax 'inher-intro (c-point 'boi))
-	      (and inclass-p (c-add-syntax 'inclass (aref inclass-p 0))))
+	      (if inclass-p (c-add-class-syntax 'inclass inclass-p)))
 	     ;; CASE 5C.3: in a Java implements/extends
 	     (injava-inher
 	      (let ((where (cdr injava-inher))
 	      (forward-char -1)
 	      (c-backward-syntactic-ws (c-point 'bol))
 	      (if (eq (char-before) ?\))
-		  (backward-sexp 1))
+		  (c-backward-sexp 2)
+		(c-backward-sexp 1))
 	      ;; now continue checking
-	      (beginning-of-line)
 	      (c-backward-syntactic-ws lim))
 	    (cond
 	     ;; CASE 5D.1: hanging member init colon, but watch out
 				 (= (c-backward-token-1 1 t lim) 0))
 		       (c-backward-syntactic-ws lim))
 		     (setq placeholder (point))
+		     (c-backward-syntactic-ws lim)
 		     (eq (char-before) ?:))
 		   (save-excursion
+		     (goto-char placeholder)
 		     (back-to-indentation)
-		     (not (looking-at c-access-key))))
+		     (and
+		      c-access-key
+		      (not (looking-at c-access-key))
+		      (not (looking-at c-class-key)))
+		     ))
 	      (goto-char placeholder)
 	      (c-forward-syntactic-ws)
 	      (c-add-syntax 'member-init-cont (point))
 	      (skip-chars-forward " \t:")
 	      (c-add-syntax 'member-init-cont (point)))
 	     ;; CASE 5D.3: perhaps a multiple inheritance line?
-	     ((looking-at c-inher-key)
+	     ((save-excursion
+		(c-beginning-of-statement-1 lim)
+		(setq placeholder (point))
+		(looking-at c-inher-key))
+	      (goto-char placeholder)
 	      (c-add-syntax 'inher-cont (c-point 'boi)))
 	     ;; CASE 5D.4: perhaps a template list continuation?
 	     ((save-excursion
 		(skip-chars-backward "^<" lim)
 		;; not sure if this is the right test, but it should
 		;; be fast and mostly accurate.
+		(setq placeholder (point))
 		(and (eq (char-before) ?<)
 		     (not (c-in-literal lim))))
 	      ;; we can probably indent it just like an arglist-cont
+	      (goto-char placeholder)
+	      (c-beginning-of-statement-1 lim)
 	      (c-add-syntax 'template-args-cont (point)))
 	     ;; CASE 5D.5: perhaps a top-level statement-cont
 	     (t
 		 c-access-key
 		 (looking-at c-access-key))
 	    (c-add-syntax 'access-label (c-point 'bonl))
-	    (c-add-syntax 'inclass (aref inclass-p 0)))
+	    (c-add-class-syntax 'inclass inclass-p))
 	   ;; CASE 5F: extern-lang-close or namespace-close?
 	   ((and inenclosing-p
 		 (eq char-after-ip ?}))
 		   (save-restriction
 		     (widen)
 		     (forward-char 1)
-		     (and