changeset 75027:9f636bd65206

Update CC Mode to version 5.31.4. The detailed changes are those recorded in the ChangeLog for 2007-01-01.
author Alan Mackenzie <acm@muc.de>
date Mon, 01 Jan 2007 22:11:28 +0000
parents a39dfae2c4f7
children 0922d91aab88
files lisp/progmodes/cc-align.el lisp/progmodes/cc-awk.el lisp/progmodes/cc-cmds.el lisp/progmodes/cc-defs.el lisp/progmodes/cc-engine.el lisp/progmodes/cc-langs.el lisp/progmodes/cc-mode.el lisp/progmodes/cc-styles.el lisp/progmodes/cc-vars.el
diffstat 9 files changed, 675 insertions(+), 350 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/cc-align.el	Mon Jan 01 21:49:04 2007 +0000
+++ b/lisp/progmodes/cc-align.el	Mon Jan 01 22:11:28 2007 +0000
@@ -90,6 +90,29 @@
 		       (c-after-special-operator-id))))
 	c-basic-offset)))
 
+(defun c-lineup-gnu-DEFUN-intro-cont (langelem)
+  "Line up the continuation lines of a DEFUN macro in the Emacs C source.
+These lines are indented as though they were `knr-argdecl-intro' lines.
+Return nil when we're not in such a construct.
+
+This function is for historical compatibility with how previous CC Modes (5.28
+and earlier) indented such lines.
+
+Here is an example:
+
+DEFUN (\"forward-char\", Fforward_char, Sforward_char, 0, 1, \"p\",
+       doc: /* Move point right N characters (left if N is negative).
+On reaching end of buffer, stop and signal error.  */)
+     (n)                      <- c-lineup-gnu-DEFUN-into-cont
+     Lisp_Object n;           <- c-lineup-gnu-DEFUN-into-cont
+
+Works with: topmost-intro-cont."
+  (save-excursion
+    (let (case-fold-search)
+      (goto-char (c-langelem-pos langelem))
+      (if (looking-at "\\<DEFUN\\>")
+	  (c-calc-offset '(knr-argdecl-intro))))))
+
 (defun c-block-in-arglist-dwim (arglist-start)
   ;; This function implements the DWIM to avoid far indentation of
   ;; brace block constructs in arguments in `c-lineup-arglist' etc.
--- a/lisp/progmodes/cc-awk.el	Mon Jan 01 21:49:04 2007 +0000
+++ b/lisp/progmodes/cc-awk.el	Mon Jan 01 22:11:28 2007 +0000
@@ -720,7 +720,7 @@
             (not (search-forward-regexp c-awk-regexp-sign-re (1+ /point) t))
           (search-forward-regexp c-awk-div-sign-re (1+ /point) t))
         ;; A division sign.
-      (progn (goto-char (1+ /point)) nil)
+	(progn (goto-char (1+ /point)) nil)
       ;; A regexp opener
       ;; Jump over the regexp innards, setting the match data.
       (goto-char /point)
--- a/lisp/progmodes/cc-cmds.el	Mon Jan 01 21:49:04 2007 +0000
+++ b/lisp/progmodes/cc-cmds.el	Mon Jan 01 22:11:28 2007 +0000
@@ -53,6 +53,7 @@
 (cc-bytecomp-defun c-forward-subword)
 (cc-bytecomp-defun c-backward-subword)
 
+;; Indentation / Display syntax functions
 (defvar c-fix-backslashes t)
 
 (defun c-indent-line (&optional syntax quiet ignore-point-pos)
@@ -252,6 +253,7 @@
 	(forward-line)))))
 
 
+;; Minor mode functions.
 (defun c-update-modeline ()
   (let ((fmt (format "/%s%s%s%s"
 		     (if c-electric-flag "l" "")
@@ -843,13 +845,17 @@
 	       (eq literal 'c)
 	       (memq 'comment-close-slash c-cleanup-list)
 	       (eq last-command-char ?/)
+	       (looking-at (concat "[ \t]*\\("
+				   (regexp-quote comment-end) "\\)?$"))
 	; (eq c-block-comment-ender "*/") ; C-style comments ALWAYS end in */
 	       (save-excursion
-		 (back-to-indentation)
-		 (looking-at (concat c-current-comment-prefix "[ \t]*$"))))
-      (end-of-line)
-      (delete-horizontal-space)
-      (or (eq (char-before) ?*) (insert-char ?* 1))) ; Do I need a t (retain sticky properties) here?
+		 (save-restriction
+		   (narrow-to-region (point-min) (point))
+		   (back-to-indentation)
+		   (looking-at (concat c-current-comment-prefix "[ \t]*$")))))
+      (kill-region (progn (forward-line 0) (point))
+		   (progn (end-of-line) (point)))
+      (insert-char ?* 1)) ; the / comes later. ; Do I need a t (retain sticky properties) here?
 
     (setq indentp (and (not arg)
 		       c-syntactic-indentation
@@ -1253,7 +1259,11 @@
 		     (backward-char)
 		     (skip-chars-backward " \t")
 		     (setq beg (point))
-		     (c-save-buffer-state () (c-on-identifier))))
+		     (c-save-buffer-state () (c-on-identifier))
+		     ;; Don't add a space into #define FOO()....
+		     (not (and (c-beginning-of-macro)
+			       (c-forward-over-cpp-define-id)
+			       (eq (point) beg)))))
 	      (save-excursion
 		(delete-region beg end)
 		(goto-char beg)
@@ -1308,6 +1318,7 @@
 	(delete-char -2)))))
 
 
+;; "nomenclature" functions + c-scope-operator.
 (defun c-forward-into-nomenclature (&optional arg)
   "Compatibility alias for `c-forward-subword'."
   (interactive "p")
@@ -1328,6 +1339,160 @@
   (interactive "*")
   (insert-and-inherit "::"))
 
+
+;; Movement (etc.) by defuns.
+(defun c-in-function-trailer-p (&optional lim)
+  ;; Return non-nil if point is between the closing brace and the semicolon of
+  ;; a brace construct which needs a semicolon, e.g. within the "variables"
+  ;; portion of a declaration like "struct foo {...} bar ;".
+  ;;
+  ;; Return the position of the main declaration.  Otherwise, return nil.
+  ;; Point is assumed to be at the top level and outside of any macro or
+  ;; literal.
+  ;;
+  ;; If LIM is non-nil, it is the bound on a the backward search for the
+  ;; beginning of the declaration.
+  ;;
+  ;; This function might do hidden buffer changes.
+  (and c-opt-block-decls-with-vars-key
+       (save-excursion
+	 (c-syntactic-skip-backward "^;}" lim)
+	 (and (eq (char-before) ?\})
+	      (eq (car (c-beginning-of-decl-1 lim)) 'previous)
+	      (looking-at c-opt-block-decls-with-vars-key)
+	      (point)))))
+
+(defun c-where-wrt-brace-construct ()
+  ;; Determine where we are with respect to functions (or other brace
+  ;; constructs, included in the term "function" in the rest of this comment).
+  ;; Point is assumed to be outside any macro or literal.
+  ;; This is used by c-\(begining\|end\)-of-defun.
+  ;;
+  ;; Return one of these symbols:
+  ;; at-header       : we're at the start of a function's header.
+  ;; in-header       : we're inside a function's header, this extending right
+  ;;                   up to the brace.  This bit includes any k&r declarations.
+  ;; in-block        : we're inside a function's brace block.
+  ;; in-trailer      : we're in the area between the "}" and ";" of something
+  ;;                  like "struct foo {...} bar, baz;".
+  ;; at-function-end : we're just after the closing brace (or semicolon) that
+  ;;                   terminates the function.
+  ;; outwith-function: we're not at or in any function.  Being inside a
+  ;;                   non-brace construct also counts as 'outwith-function'.
+  ;;
+  ;; This function might do hidden buffer changes.
+  (save-excursion
+    (let* (pos
+	   kluge-start
+	   decl-result brace-decl-p
+	   (start (point))
+	   (paren-state (c-parse-state))
+	   (least-enclosing (c-least-enclosing-brace paren-state)))
+
+      (cond
+       ((and least-enclosing
+	     (eq (char-after least-enclosing) ?\{))
+	'in-block)
+       ((c-in-function-trailer-p)
+	'in-trailer)
+       ((and (not least-enclosing)
+	     (consp paren-state)
+	     (consp (car paren-state))
+	     (eq start (cdar paren-state)))
+	'at-function-end)
+       (t
+	;; Find the start of the current declaration.  NOTE: If we're in the
+	;; variables after a "struct/eval" type block, we don't get to the
+	;; real declaration here - we detect and correct for this later.
+
+	;;If we're in the parameters' parens, move back out of them.
+	(if least-enclosing (goto-char least-enclosing))
+	;; Kluge so that c-beginning-of-decl-1 won't go back if we're already
+	;; at a declaration.
+	(if (or (and (eolp) (not (eobp))) ; EOL is matched by "\\s>"
+		(not (looking-at
+"\\([;#]\\|\\'\\|\\s(\\|\\s)\\|\\s\"\\|\\s\\\\|\\s$\\|\\s<\\|\\s>\\|\\s!\\)")))
+	    (forward-char))
+	(setq kluge-start (point))
+	(setq decl-result
+	      (car (c-beginning-of-decl-1
+		    (and least-enclosing ; LIMIT for c-b-of-decl-1
+			 (c-safe-position least-enclosing paren-state)))))
+
+	;; Has the declaration we've gone back to got braces?
+	(setq pos (point))	      ; the search limit for c-recognize-knr-p
+	(setq brace-decl-p
+	      (save-excursion
+		    (and (c-syntactic-re-search-forward "[;{]" nil t t)
+			 (or (eq (char-before) ?\{)
+			     (and c-recognize-knr-p
+				  ;; Might have stopped on the
+				  ;; ';' in a K&R argdecl.  In
+				  ;; that case the declaration
+				  ;; should contain a block.
+				  (c-in-knr-argdecl pos))))))
+
+	(cond
+	 ((= (point) kluge-start)	; might be BOB or unbalanced parens.
+	  'outwith-function)
+	 ((eq decl-result 'same)
+	  (if brace-decl-p
+	      (if (eq (point) start)
+		  'at-header
+		'in-header)
+	    'outwith-function))
+	 ((eq decl-result 'previous)
+	  (if (and (not brace-decl-p)
+		   (c-in-function-trailer-p))
+	      'at-function-end
+	    'outwith-function))
+	 (t (error
+	     "c-where-wrt-brace-construct: c-beginning-of-decl-1 returned %s"
+	     decl-result))))))))
+
+(defun c-backward-to-nth-BOF-{ (n where)
+  ;; Skip to the opening brace of the Nth function before point.  If
+  ;; point is inside a function, this counts as the first.  Point must be
+  ;; outside any comment/string or macro.
+  ;;
+  ;; N must be strictly positive.
+  ;; WHERE describes the position of point, one of the symbols `at-header',
+  ;; `in-header', `in-block', `in-trailer', `at-function-end',
+  ;; `outwith-function' as returned by c-where-wrt-brace-construct.
+  ;;
+  ;; If we run out of functions, leave point at BOB.  Return zero on success,
+  ;; otherwise the number of {s still to go.
+  ;;
+  ;; This function may do hidden buffer changes
+  (cond
+   ;; What we do to go back the first defun depends on where we start.
+   ((bobp))
+   ((eq where 'in-block)
+    (goto-char (c-least-enclosing-brace (c-parse-state)))
+    (setq n (1- n)))
+   ((eq where 'in-header)
+    (c-syntactic-re-search-forward "{")
+    (backward-char)
+    (setq n (1- n)))
+   (;; (or (eq where 'at-header) (eq where 'outwith-function)
+;; 	(eq where 'at-function-end) (eq where 'in-trailer))
+    (memq where '(at-header outwith-function at-function-end in-trailer))
+    (c-syntactic-skip-backward "^}")
+    (when (eq (char-before) ?\})
+      (backward-sexp)
+      (setq n (1- n))))
+   (t (error "Unknown `where' %s in c-backward-to-nth-EOF-{" where)))
+
+   ;; Each time round the loop, go back to a "{" at the outermost level.
+  (while (and (> n 0) (not (bobp)))
+    (c-parse-state)		       ; This call speeds up the following one
+					; by a factor of ~6.  Hmmm.  2006/4/5.
+    (c-syntactic-skip-backward "^}")
+    (when (eq (char-before) ?\})
+      (backward-sexp)
+      (setq n (1- n))))
+   n)
+
 (defun c-beginning-of-defun (&optional arg)
   "Move backward to the beginning of a defun.
 Every top level declaration that contains a brace paren block is
@@ -1344,88 +1509,99 @@
   (interactive "p")
   (or arg (setq arg 1))
 
-  (if (< arg 0)
-      (when (c-end-of-defun (- arg))
-	(c-save-buffer-state nil (c-forward-syntactic-ws))
-	t)
-
-    (c-save-buffer-state (paren-state lim pos)
-      (catch 'exit
-	(while (> arg 0)
-	  ;; Note: Partial code duplication in `c-end-of-defun' and
-	  ;; `c-declaration-limits'.
-
-	  (setq paren-state (c-parse-state))
-	  (unless (c-safe
-		    (goto-char (c-least-enclosing-brace paren-state))
-		    ;; If we moved to the outermost enclosing paren
-		    ;; then we can use c-safe-position to set the
-		    ;; limit.  Can't do that otherwise since the
-		    ;; earlier paren pair on paren-state might very
-		    ;; well be part of the declaration we should go
-		    ;; to.
-		    (setq lim (c-safe-position (point) paren-state))
-		    t)
-	    ;; At top level.  Make sure we aren't inside a literal.
-	    (setq pos (c-literal-limits
-		       (c-safe-position (point) paren-state)))
-	    (if pos (goto-char (car pos))))
-
-	  (while (let ((start (point)))
-		   (c-beginning-of-decl-1 lim)
-		   (if (= (point) start)
-		       ;; Didn't move.  Might be due to bob or unbalanced
-		       ;; parens.  Try to continue if it's the latter.
-		       (unless (c-safe (goto-char
-					(c-down-list-backward (point))))
-			 ;; Didn't work, so it's bob then.
-			 (goto-char (point-min))
-			 (throw 'exit nil)))
-
-		   (save-excursion
-		     ;; Check if the declaration contains a brace
-		     ;; block.  If not, we try another one.
-		     (setq pos (point))
-		     (not (and (c-syntactic-re-search-forward "[;{]" nil t t)
-			       (or (eq (char-before) ?{)
-				   (and c-recognize-knr-p
-					;; Might have stopped on the
-					;; ';' in a K&R argdecl.  In
-					;; that case the declaration
-					;; should contain a block.
-					(c-in-knr-argdecl pos)))))))
-	    (setq lim nil))
-
-	  ;; Check if `c-beginning-of-decl-1' put us after the block
-	  ;; in a declaration that doesn't end there.  We're searching
-	  ;; back and forth over the block here, which can be
-	  ;; expensive.
-	  (setq pos (point))
-	  (if (and c-opt-block-decls-with-vars-key
-		   (progn
-		     (c-backward-syntactic-ws)
-		     (eq (char-before) ?}))
-		   (eq (car (c-beginning-of-decl-1))
-		       'previous)
-		   (save-excursion
-		     (c-end-of-decl-1)
-		     (> (point) pos)))
-	      nil
-	    (goto-char pos))
-
-	  (setq pos (point))
-	  ;; Try to be line oriented; position point at the closest
-	  ;; preceding boi that isn't inside a comment, but if we hit
-	  ;; the previous declaration then we use the current point
-	  ;; instead.
-	  (while (and (/= (point) (c-point 'boi))
-		      (c-backward-single-comment)))
-	  (if (/= (point) (c-point 'boi))
-	      (goto-char pos))
-
-	  (setq arg (1- arg)))))
-    (c-keep-region-active)
-    (= arg 0)))
+  (c-save-buffer-state
+      ((start (point))
+       where paren-state pos)
+
+    ;; Move back out of any macro/comment/string we happen to be in.
+    (c-beginning-of-macro)
+    (setq pos (c-literal-limits))
+    (if pos (goto-char (car pos)))
+
+    (setq where (c-where-wrt-brace-construct))
+
+    (if (< arg 0)
+	;; Move forward to the closing brace of a function.
+	(progn
+	  (if ;; (or (eq where 'at-function-end) (eq where 'outwith-function))
+	      (memq where '(at-function-end outwith-function))
+	      (setq arg (1+ arg)))
+	  (if (< arg 0)
+	      (setq arg (c-forward-to-nth-EOF-} (- arg) where)))
+	  ;; Move forward to the next opening brace....
+	  (when (and (= arg 0)
+		     (c-syntactic-re-search-forward "{" nil t))
+	    (backward-char)
+	    ;; ... and backward to the function header.
+	    (c-beginning-of-decl-1)
+	    t))
+
+      ;; Move backward to the opening brace of a function.
+      (when (and (> arg 0)
+		 (eq (setq arg (c-backward-to-nth-BOF-{ arg where)) 0))
+
+	;; Go backward to this function's header.
+	(c-beginning-of-decl-1)
+
+	(setq pos (point))
+	;; We're now there, modulo comments and whitespace.
+	;; Try to be line oriented; position point at the closest
+	;; preceding boi that isn't inside a comment, but if we hit
+	;; the previous declaration then we use the current point
+	;; instead.
+	(while (and (/= (point) (c-point 'boi))
+		    (c-backward-single-comment)))
+	(if (/= (point) (c-point 'boi))
+	    (goto-char pos)))
+
+      (c-keep-region-active)
+      (= arg 0))))
+
+(defun c-forward-to-nth-EOF-} (n where)
+  ;; Skip to the closing brace of the Nth function after point.  If
+  ;; point is inside a function, this counts as the first.  Point must be
+  ;; outside any comment/string or macro.
+  ;;
+  ;; N must be strictly positive.
+  ;; WHERE describes the position of point, one of the symbols `at-header',
+  ;; `in-header', `in-block', `in-trailer', `at-function-end',
+  ;; `outwith-function' as returned by c-where-wrt-brace-construct.
+  ;;
+  ;; If we run out of functions, leave point at EOB.  Return zero on success,
+  ;; otherwise the number of }s still to go.
+  ;;
+  ;; This function may do hidden buffer changes.
+
+  (cond
+  ;; What we do to go forward over the first defun depends on where we
+  ;; start.  We go to the closing brace of that defun, even when we go
+  ;; backwards to it (in a "struct foo {...} bar ;").
+   ((eobp))
+   ((eq where 'in-block)
+    (goto-char (c-least-enclosing-brace (c-parse-state)))
+    (forward-sexp)
+    (setq n (1- n)))
+   ((eq where 'in-trailer)
+    (c-syntactic-skip-backward "^}")
+    (setq n (1- n)))
+   (;; (or (eq where 'at-function-end) (eq where 'outwith-function)
+;; 	(eq where 'at-header) (eq where 'in-header))
+    (memq where '(at-function-end outwith-function at-header in-header))
+    (c-syntactic-re-search-forward "{")
+    (backward-char)
+    (forward-sexp)
+    (setq n (1- n)))
+   (t (error "c-forward-to-nth-EOF-}: `where' is %s" where)))
+
+  ;; Each time round the loop, go forward to a "}" at the outermost level.
+  (while (and (> n 0) (not (eobp)))
+					;(c-parse-state)	; This call speeds up the following one by a factor
+					; of ~6.  Hmmm.  2006/4/5.
+    (when (c-syntactic-re-search-forward "{" nil 'eob)
+      (backward-char)
+      (forward-sexp))
+    (setq n (1- n)))
+  n)
 
 (defun c-end-of-defun (&optional arg)
   "Move forward to the end of a top level declaration.
@@ -1435,82 +1611,56 @@
 
 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")
   (or arg (setq arg 1))
 
-  (if (< arg 0)
-      (when (c-beginning-of-defun (- arg))
-	(c-save-buffer-state nil (c-backward-syntactic-ws))
-	t)
-
-    (c-save-buffer-state (paren-state lim pos)
-      (catch 'exit
-	(while (> arg 0)
-	  ;; Note: Partial code duplication in `c-beginning-of-defun'
-	  ;; and `c-declaration-limits'.
-
-	  (setq paren-state (c-parse-state))
-	  (unless (c-safe
-		    (goto-char (c-least-enclosing-brace paren-state))
-		    ;; If we moved to the outermost enclosing paren
-		    ;; then we can use c-safe-position to set the
-		    ;; limit.  Can't do that otherwise since the
-		    ;; earlier paren pair on paren-state might very
-		    ;; well be part of the declaration we should go
-		    ;; to.
-		    (setq lim (c-safe-position (point) paren-state))
-		    t)
-	    ;; At top level.  Make sure we aren't inside a literal.
-	    (setq pos (car-safe (c-literal-limits
-				 (c-safe-position (point) paren-state))))
-	    (if pos (goto-char pos)))
-
-	  ;; Have to move to the start first so that `c-end-of-decl-1'
-	  ;; has the correct start position.
-	  (setq pos (point))
-	  (when (memq (car (c-beginning-of-decl-1 lim))
-		      '(previous macro))
-	    ;; We moved back over the previous defun or a macro.  Move
-	    ;; to the next token; it's the start of the next
-	    ;; declaration.  We can also be directly after the block
-	    ;; in a `c-opt-block-decls-with-vars-key' declaration, but
-	    ;; then we won't move significantly far here.
-	    (goto-char pos)
-	    (c-forward-token-2 0))
-
-	  (while (let ((start (point)))
-		   (c-end-of-decl-1)
-		   (if (= (point) start)
-		       ;; Didn't move.  Might be due to eob or unbalanced
-		       ;; parens.  Try to continue if it's the latter.
-		       (if (c-safe (goto-char (c-up-list-forward (point))))
-			   t
-			 ;; Didn't work, so it's eob then.
-			 (goto-char (point-max))
-			 (throw 'exit nil))
-
-		     (save-excursion
-		       ;; Check if the declaration contains a brace
-		       ;; block.  If not, we try another one.
-		       (setq pos (point))
-		       (goto-char start)
-		       (not (c-syntactic-re-search-forward "{" pos t t))))))
-
-	  (setq pos (point))
-	  ;; Try to be line oriented; position point after the next
-	  ;; newline that isn't inside a comment, but if we hit the
-	  ;; next declaration then we use the current point instead.
-	  (while (and (not (bolp))
-		      (not (looking-at "\\s *$"))
-		      (c-forward-single-comment)))
-	  (cond ((bolp))
-		((looking-at "\\s *$")
-		 (forward-line 1))
-		(t
-		 (goto-char pos)))
-
-	  (setq arg (1- arg)))))
+  (c-save-buffer-state
+      ((start (point))
+       where paren-state pos)
+
+    ;; Move back out of any macro/comment/string we happen to be in.
+    (c-beginning-of-macro)
+    (setq pos (c-literal-limits))
+    (if pos (goto-char (car pos)))
+
+    (setq where (c-where-wrt-brace-construct))
+
+    (if (< arg 0)
+	;; Move backwards to the } of a function
+	(progn
+	  (if ;; (or (eq where 'at-header) (eq where 'outwith-function))
+	      (memq where '(at-header outwith-function))
+	      (setq arg (1+ arg)))
+	  (if (< arg 0)
+	      (setq arg (c-backward-to-nth-BOF-{ (- arg) where)))
+	  (when (and (= arg 0)
+		     (c-syntactic-skip-backward "^}")
+		     (eq (char-before) ?\}))
+	    t))
+
+      ;; Move forward to the } of a function
+      (if (> arg 0)
+	  (setq arg (c-forward-to-nth-EOF-} arg where))))
+
+    ;; Do we need to move forward from the brace to the semicolon?
+    (when (eq arg 0)
+      (if (c-in-function-trailer-p)	; after "}" of struct/enum, etc.
+	  (c-syntactic-re-search-forward ";"))
+
+      (setq pos (point))
+      ;; We're there now, modulo comments and whitespace.
+      ;; Try to be line oriented; position point after the next
+      ;; newline that isn't inside a comment, but if we hit the
+      ;; next declaration then we use the current point instead.
+      (while (and (not (bolp))
+		  (not (looking-at "\\s *$"))
+		  (c-forward-single-comment)))
+      (cond ((bolp))
+	    ((looking-at "\\s *$")
+	     (forward-line 1))
+	    (t
+	     (goto-char pos))))
+
     (c-keep-region-active)
     (= arg 0)))
 
@@ -1646,6 +1796,7 @@
       (push-mark (cdr decl-limits) nil t))))
 
 
+;; Movement by statements.
 (defun c-in-comment-line-prefix-p ()
   ;; Point is within a comment.  Is it also within a comment-prefix?
   ;; Space at BOL which precedes a comment-prefix counts as part of it.
@@ -2429,7 +2580,6 @@
 	(if (/= count 0) (setq count (1- count))))
       (c-keep-region-active))))
 
-
 
 ;; set up electric character functions to work with pending-del,
 ;; (a.k.a. delsel) mode.  All symbols get the t value except
@@ -2455,6 +2605,7 @@
 (put 'c-electric-delete-forward 'pending-delete   'supersede) ; pending-del
 
 
+;; Inserting/indenting comments
 (defun c-calc-comment-indent (entry)
   ;; This function might do hidden buffer changes.
   (if (symbolp entry)
@@ -2550,6 +2701,7 @@
       (current-column))))
 
 
+;; Movement by CPP conditionals.
 (defun c-up-conditional (count)
   "Move back to the containing preprocessor conditional, leaving mark behind.
 A prefix argument acts as a repeat count.  With a negative argument,
@@ -3621,9 +3773,12 @@
     ;; Restore point on undo.  It's necessary since we do a lot of
     ;; hidden inserts and deletes below that should be as transparent
     ;; as possible.
-    (if (and buffer-undo-list (not (eq buffer-undo-list t)))
+      (if (and buffer-undo-list (not (eq buffer-undo-list t)))
 	(setq buffer-undo-list (cons (point) buffer-undo-list)))
 
+    ;; Determine the limits and type of the containing literal (if any):
+    ;; C-LIT-LIMITS, C-LIT-TYPE;  and the limits of the current paragraph:
+    ;; BEG and END.
     (c-save-buffer-state ()
       (save-restriction
 	;; Widen to catch comment limits correctly.
@@ -3651,6 +3806,13 @@
 
     (unwind-protect
 	(progn
+	  ;; For each of the possible types of text (string, C comment ...)
+	  ;; determine BEG and END, the region we will narrow to.  If we're in
+	  ;; a literal, constrain BEG and END to the limits of this literal.
+	  ;;
+	  ;; For some of these text types, particularly a block comment, we
+	  ;; may need to massage whitespace near literal delimiters, so that
+	  ;; these don't get filled inappropriately.
 	  (cond
 
 	   ((eq c-lit-type 'c++)	; Line comment.
@@ -3675,21 +3837,27 @@
 
 	   ((eq c-lit-type 'c)		; Block comment.
 	    (when (>= end (cdr c-lit-limits))
-	      ;; The region includes the comment ender which we might
-	      ;; want to keep together with the last word.
-	      (unless (save-excursion
-			(goto-char (cdr c-lit-limits))
-			(beginning-of-line)
-			(and (looking-at (concat "[ \t]*\\("
-						 c-current-comment-prefix
-						 "\\)\\*/"))
-			     (eq (cdr c-lit-limits) (match-end 0))
-			     ;; The comment ender is on a line of its
-			     ;; own.  Keep it that way.
-			     (set-marker end (point))))
-
-		;; The comment ender should hang.  Replace all space between
-		;; it and the last word either by one or two 'x's (when
+	      ;; The region includes the comment ender.  If it's on its own
+	      ;; line, it stays on its own line.  If it's got company on the
+	      ;; line, it keeps (at least one word of) it.  "=====*/" counts
+	      ;; as a comment ender here, but "===== */" doesn't and "foo*/"
+	      ;; doesn't.
+	      (unless
+		  (save-excursion
+		    (goto-char (cdr c-lit-limits))
+		    (beginning-of-line)
+		    (and (search-forward-regexp
+			  (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)")
+			  (- (cdr c-lit-limits) 2) t)
+			 (not (search-forward-regexp
+			       "\\(\\s \\|\\sw\\)"
+			       (- (cdr c-lit-limits) 2) 'limit))
+			     ;; The comment ender IS on its own line.  Exclude
+			     ;; this line from the filling.
+			 (set-marker end (c-point 'bol))))
+
+		;; The comment ender is hanging.  Replace all space between it
+		;; and the last word either by one or two 'x's (when
 		;; FILL-PARAGRAPH is non-nil), or a row of x's the same width
 		;; as the whitespace (when auto filling), and include it in
 		;; the region.  We'll change them back to whitespace
@@ -3706,23 +3874,26 @@
 		       spaces)
 
 		  (save-excursion
+		    ;; Insert a CR after the "*/", adjust END
 		    (goto-char (cdr c-lit-limits))
 		    (setq tmp-post (point-marker))
 		    (insert ?\n)
 		    (set-marker end (point))
+
 		    (forward-line -1)	; last line of the comment
 		    (if (and (looking-at (concat "[ \t]*\\(\\("
 						 c-current-comment-prefix
 						 "\\)[ \t]*\\)"))
 			     (eq ender-start (match-end 0)))
-			;; The comment ender is prefixed by nothing
-			;; but a comment line prefix.  Remove it
-			;; along with surrounding ws.
+			;; The comment ender is prefixed by nothing but a
+			;; comment line prefix.  IS THIS POSSIBLE?  (ACM,
+			;; 2006/4/28).  Remove it along with surrounding ws.
 			(setq spaces (- (match-end 1) (match-end 2)))
 		      (goto-char ender-start))
 		    (skip-chars-backward " \t\r\n") ; Surely this can be
 					; " \t"? "*/" is NOT alone on the line (ACM, 2005/8/18)
 
+		    ;; What's being tested here?  2006/4/20.  FIXME!!!
 		    (if (/= (point) ender-start)
 			(progn
 			  (if (<= here (point))
@@ -4172,49 +4343,63 @@
 When point is inside a comment, continue it with the appropriate
 comment prefix (see the `c-comment-prefix-regexp' and
 `c-block-comment-prefix' variables for details).  The end of a
-C++-style line comment doesn't count as inside it."
+C++-style line comment doesn't count as inside it.
+
+When point is inside a string, only insert a backslash when it is also
+inside a preprocessor directive."
 
   (interactive "*")
   (let* (c-lit-limits c-lit-type
 	 (c-macro-start c-macro-start))
 
-    (if (c-save-buffer-state ()
-	  (setq c-lit-limits (c-literal-limits nil nil t)
-		c-lit-type (c-literal-type c-lit-limits))
-	  (or (eq c-lit-type 'c)
-	      (and (eq c-lit-type 'c++)
-		   (< (save-excursion
-			(skip-chars-forward " \t")
-			(point))
-		      (1- (cdr (setq c-lit-limits (c-collect-line-comments
-						   c-lit-limits))))))
-	      (and (or (not (looking-at "\\s *$"))
-		       (eq (char-before) ?\\))
-		   (c-query-and-set-macro-start)
-		   (<= (save-excursion
-			 (goto-char c-macro-start)
-			 (if (looking-at c-opt-cpp-start)
-			     (goto-char (match-end 0)))
-			 (point))
-		       (point)))))
-
-	(let ((comment-multi-line t)
-	      (fill-prefix nil))
-	  (c-indent-new-comment-line nil t))
-
-      (delete-horizontal-space)
-      (newline)
-
+    (c-save-buffer-state ()
+      (setq c-lit-limits (c-literal-limits nil nil t)
+	    c-lit-type (c-literal-type c-lit-limits))
+      (when (eq c-lit-type 'c++)
+	(setq c-lit-limits (c-collect-line-comments c-lit-limits)))
+      (c-query-and-set-macro-start))
+
+    (cond
+     ((or (eq c-lit-type 'c)
+	  (and (eq c-lit-type 'c++) ; C++ comment, but not at the very end of it.
+	       (< (save-excursion
+		    (skip-chars-forward " \t")
+		    (point))
+		  (1- (cdr c-lit-limits))))
+	  (and (numberp c-macro-start)	; Macro, but not at the very end of
+					; it, not in a string, and not in the
+					; cpp keyword.
+	       (not (eq c-lit-type 'string))
+	       (or (not (looking-at "\\s *$"))
+		   (eq (char-before) ?\\))
+	       (<= (save-excursion
+		     (goto-char c-macro-start)
+		     (if (looking-at c-opt-cpp-start)
+			 (goto-char (match-end 0)))
+		     (point))
+		   (point))))
+      (let ((comment-multi-line t)
+	    (fill-prefix nil))
+	(c-indent-new-comment-line nil t)))
+
+     ((eq c-lit-type 'string)
+      (if (and (numberp c-macro-start)
+	       (not (eq (char-before) ?\\)))
+	  (insert ?\\))
+      (newline))
+
+     (t (delete-horizontal-space)
+	(newline)
       ;; c-indent-line may look at the current indentation, so let's
       ;; start out with the same indentation as the previous line.
-      (let ((col (save-excursion
-		   (forward-line -1)
-		   (while (and (looking-at "[ \t]*\\\\?$")
-			       (= (forward-line -1) 0)))
-		   (current-indentation))))
-	(indent-to col))
-
-      (indent-according-to-mode))))
+	(let ((col (save-excursion
+		     (backward-char)
+		     (forward-line 0)
+		     (while (and (looking-at "[ \t]*\\\\?$")
+				 (= (forward-line -1) 0)))
+		     (current-indentation))))
+	  (indent-to col))
+     (indent-according-to-mode)))))
 
 (defun c-context-open-line ()
   "Insert a line break suitable to the context and leave point before it.
--- a/lisp/progmodes/cc-defs.el	Mon Jan 01 21:49:04 2007 +0000
+++ b/lisp/progmodes/cc-defs.el	Mon Jan 01 22:11:28 2007 +0000
@@ -95,7 +95,7 @@
 
 ;;; Variables also used at compile time.
 
-(defconst c-version "5.31.3"
+(defconst c-version "5.31.4"
   "CC Mode version number.")
 
 (defconst c-version-sym (intern c-version))
@@ -764,7 +764,7 @@
 ;; call `c-beginning-of-statement-1'.
 ;;
 ;; The macro `c-vsemi-status-unknown-p' will typically check the cacheing
-;; scheme used by the `c-at-vsemp-p-fn', hence the name - the status is
+;; scheme used by the `c-at-vsemi-p-fn', hence the name - the status is
 ;; "unknown" if there is no cache entry current for the line. 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
@@ -1620,7 +1620,7 @@
 
 (defmacro c-lang-defconst (name &rest args)
   "Set the language specific values of the language constant NAME.
-The second argument can be an optional docstring.  The rest of the
+The second argument can optionally be a docstring.  The rest of the
 arguments are one or more repetitions of LANG VAL where LANG specifies
 the language(s) that VAL applies to.  LANG is the name of the
 language, i.e. the mode name without the \"-mode\" suffix, or a list
@@ -1717,7 +1717,7 @@
 	;; Emacs has a weird bug where it seems to fail to read
 	;; backquote lists from byte compiled files correctly (,@
 	;; forms, to be specific), so make sure the bindings in the
-	;; expansion below doesn't contain any backquote stuff.
+	;; expansion below don't contain any backquote stuff.
 	;; (XEmacs handles it correctly and doesn't need this for that
 	;; reason, but we also use this expansion handle
 	;; `c-lang-defconst-eval-immediately' and to register
--- a/lisp/progmodes/cc-engine.el	Mon Jan 01 21:49:04 2007 +0000
+++ b/lisp/progmodes/cc-engine.el	Mon Jan 01 22:11:28 2007 +0000
@@ -255,6 +255,18 @@
 	     (forward-char)
 	     t))))
 
+(defun c-forward-over-cpp-define-id ()
+  ;; Assuming point is at the "#" that introduces a preprocessor
+  ;; directive, it's moved forward to the end of the identifier which is
+  ;; "#define"d (or whatever c-opt-cpp-macro-define specifies).  Non-nil
+  ;; is returned in this case, in all other cases nil is returned and
+  ;; point isn't moved.
+  ;;
+  ;; This function might do hidden buffer changes.
+  (when (and c-opt-cpp-macro-define-id
+	     (looking-at c-opt-cpp-macro-define-id))
+    (goto-char (match-end 0))))
+
 (defun c-forward-to-cpp-define-body ()
   ;; Assuming point is at the "#" that introduces a preprocessor
   ;; directive, it's moved forward to the start of the definition body
@@ -2442,14 +2454,14 @@
 		(= (c-backward-token-2 0) 0))
 
        (cond ((and (looking-at c-overloadable-operators-regexp)
-		   (or (not c-opt-op-identitier-prefix)
+		   (or (not c-opt-op-identifier-prefix)
 		       (and (= (c-backward-token-2 1) 0)
-			    (looking-at c-opt-op-identitier-prefix))))
+			    (looking-at c-opt-op-identifier-prefix))))
 	      (point))
 
 	     ((save-excursion
-		(and c-opt-op-identitier-prefix
-		     (looking-at c-opt-op-identitier-prefix)
+		(and c-opt-op-identifier-prefix
+		     (looking-at c-opt-op-identifier-prefix)
 		     (= (c-forward-token-2 1) 0)
 		     (looking-at c-overloadable-operators-regexp)))
 	      (point))))
@@ -3843,7 +3855,7 @@
 	;; good start position for the search, so do it.
 	(c-find-decl-prefix-search)))
 
-    ;; Now loop.  We already got the first match.
+    ;; Now loop.  Round what?  (ACM, 2006/7/5).  We already got the first match.
 
     (while (progn
 	     (while (and
@@ -4534,41 +4546,42 @@
 	  (goto-char start)
 	  nil)
 
-      (while (and
+      (while (progn
 	      (c-syntactic-skip-backward "^<;{}" limit t)
 
-	      (if (eq (char-before) ?<)
-		  t
-		;; Stopped at bob or a char that isn't allowed in an
-		;; arglist, so we've failed.
-		(goto-char start)
-		nil)
-
-	      (if (> (point)
-		     (progn (c-beginning-of-current-token)
-			    (point)))
-		  ;; If we moved then the "<" was part of some
-		  ;; multicharacter token.
-		  t
-
-		(backward-char)
-		(let ((beg-pos (point)))
-		  (if (c-forward-<>-arglist all-types)
-		      (cond ((= (point) start)
-			     ;; Matched the arglist.  Break the while.
-			     (goto-char beg-pos)
-			     nil)
-			    ((> (point) start)
-			     ;; We started from a non-paren ">" inside an
-			     ;; arglist.
-			     (goto-char start)
-			     nil)
-			    (t
-			     ;; Matched a shorter arglist.  Can be a nested
-			     ;; one so continue looking.
-			     (goto-char beg-pos)
-			     t))
-		    t)))))
+	      (and
+	       (if (eq (char-before) ?<)
+		   t
+		 ;; Stopped at bob or a char that isn't allowed in an
+		 ;; arglist, so we've failed.
+		 (goto-char start)
+		 nil)
+
+	       (if (> (point)
+		      (progn (c-beginning-of-current-token)
+			     (point)))
+		   ;; If we moved then the "<" was part of some
+		   ;; multicharacter token.
+		   t
+
+		 (backward-char)
+		 (let ((beg-pos (point)))
+		   (if (c-forward-<>-arglist all-types)
+		       (cond ((= (point) start)
+			      ;; Matched the arglist.  Break the while.
+			      (goto-char beg-pos)
+			      nil)
+			     ((> (point) start)
+			      ;; We started from a non-paren ">" inside an
+			      ;; arglist.
+			      (goto-char start)
+			      nil)
+			     (t
+			      ;; Matched a shorter arglist.  Can be a nested
+			      ;; one so continue looking.
+			      (goto-char beg-pos)
+			      t))
+		     t))))))
 
       (/= (point) start))))
 
@@ -5793,17 +5806,32 @@
       nil))))
 
 (defun c-forward-label (&optional assume-markup preceding-token-end limit)
-  ;; Assuming the point is at the beginning of a token, check if it
-  ;; starts a label and if so move over it and return t, otherwise
-  ;; don't move and return nil.  The end of the label is taken to be
-  ;; the end of the first submatch in `c-opt-extra-label-key' if it
-  ;; matched, otherwise it's the colon.  The point is directly after
-  ;; the end on return.  The terminating char is marked with
-  ;; `c-decl-end' to improve recognition of the following declaration
-  ;; or statement.
+  ;; Assuming that point is at the beginning of a token, check if it starts a
+  ;; label and if so move over it and return t, otherwise don't move and
+  ;; return nil.  "Label" here means "most things with a colon".
+  ;;
+  ;; More precisely, a "label" is regarded as one of:
+  ;; (i) a goto target like "foo:";
+  ;; (ii) A case label - either the entire construct "case FOO:" or just the
+  ;;   bare "case", should the colon be missing;
+  ;; (iii) a keyword which needs a colon, like "default:" or "private:";
+  ;; (iv) One of QT's "extended" C++ variants of
+  ;; "private:"/"protected:"/"public:"/"more:" looking like "public slots:".
+  ;; (v) One of the keywords matched by `c-opt-extra-label-key' (without any
+  ;;   colon).  Currently (2006-03), this applies only to Objective C's
+  ;;   keywords "@private", "@protected", and "@public".
+  ;;
+  ;; One of the things which will NOT be recognised as a label is a bit-field
+  ;; element of a struct, something like "int foo:5".
+  ;;
+  ;; The end of the label is taken to be just after the colon, or the end of
+  ;; the first submatch in `c-opt-extra-label-key'.  The point is directly
+  ;; after the end on return.  The terminating char gets marked with
+  ;; `c-decl-end' to improve recognition of the following declaration or
+  ;; statement.
   ;;
   ;; If ASSUME-MARKUP is non-nil, it's assumed that the preceding
-  ;; label, if any, has been marked up like that.
+  ;; label, if any, has already been marked up like that.
   ;;
   ;; If PRECEDING-TOKEN-END is given, it should be the first position
   ;; after the preceding token, i.e. on the other side of the
@@ -5819,8 +5847,11 @@
   ;;
   ;; This function might do hidden buffer changes.
 
-  (let ((start (point)))
+  (let ((start (point))
+	qt-symbol-idx
+	macro-start)			; if we're in one.
     (cond
+     ;; "case" or "default" (Doesn't apply to AWK). 
      ((looking-at c-label-kwds-regexp)
       (let ((kwd-end (match-end 1)))
 	;; Record only the keyword itself for fontification, since in
@@ -5840,7 +5871,7 @@
 		 (match-beginning 2))
 
 	    (progn
-	      (goto-char (match-beginning 2))
+	      (goto-char (match-beginning 2)) ; just after the :
 	      (c-put-c-type-property (1- (point)) 'c-decl-end)
 	      t)
 
@@ -5851,6 +5882,7 @@
 	  (goto-char kwd-end)
 	  t)))
 
+     ;; @private, @protected, @public, in Objective C, or similar.
      ((and c-opt-extra-label-key
 	   (looking-at c-opt-extra-label-key))
       ;; For a `c-opt-extra-label-key' match, we record the whole
@@ -5862,7 +5894,8 @@
       (c-put-c-type-property (1- (point)) 'c-decl-end)
       t)
 
-     ((and c-recognize-colon-labels
+     ;; All other cases of labels.
+     ((and c-recognize-colon-labels	; nil for AWK and IDL, otherwise t.
 
 	   ;; A colon label must have something before the colon.
 	   (not (eq (char-after) ?:))
@@ -5890,7 +5923,8 @@
 		 (save-excursion
 		   (goto-char (1- preceding-token-end))
 		   (c-beginning-of-current-token)
-		   (looking-at c-label-prefix-re))
+		   (or (looking-at c-label-prefix-re)
+		       (looking-at c-block-stmt-1-key)))
 
 		 (and (eq (char-before preceding-token-end) ?\))
 		      (c-after-conditional)))
@@ -5899,7 +5933,8 @@
 	       (save-excursion
 		 (goto-char (1- preceding-token-end))
 		 (c-beginning-of-current-token)
-		 (looking-at c-label-prefix-re))
+		 (or (looking-at c-label-prefix-re)
+		     (looking-at c-block-stmt-1-key)))
 
 	       (cond
 		((eq (char-before preceding-token-end) ?\))
@@ -5907,26 +5942,52 @@
 
 		((eq (char-before preceding-token-end) ?:)
 		 ;; Might be after another label, so check it recursively.
-		 (save-excursion
-		   (goto-char (1- preceding-token-end))
-		   ;; Essentially the same as the
-		   ;; `c-syntactic-re-search-forward' regexp below.
-		   (c-syntactic-skip-backward "^-]:?;}=*/%&|,<>!@+" nil t)
-		   (let ((pte (point))
-			 ;; If the caller turned on recording for us,
-			 ;; it shouldn't apply when we check the
-			 ;; preceding label.
-			 c-record-type-identifiers)
-		     (c-forward-syntactic-ws)
-		     (c-forward-label nil pte start))))))))
-
-	   ;; Check that the next nonsymbol token is ":".  Allow '('
-	   ;; for the sake of macro arguments.  FIXME: Should build
-	   ;; this regexp from the language constants.
-	   (c-syntactic-re-search-forward
-	    "[[:?;{=*/%&|,<>!@+-]" limit t t)
-	   (eq (char-before) ?:)
-	   (not (eq (char-after) ?:)))
+		 (save-restriction
+		   (save-excursion
+		     (goto-char (1- preceding-token-end))
+		     ;; Essentially the same as the
+		     ;; `c-syntactic-re-search-forward' regexp below.
+		     (setq macro-start
+			   (save-excursion (and (c-beginning-of-macro)
+						(point))))
+		     (if macro-start (narrow-to-region macro-start (point-max)))
+		     (c-syntactic-skip-backward "^-]:?;}=*/%&|,<>!@+" nil t)
+		     ;; Note: the following should work instead of the
+		     ;; narrow-to-region above.  Investigate why not,
+		     ;; sometime.  ACM, 2006-03-31.
+		     ;; (c-syntactic-skip-backward "^-]:?;}=*/%&|,<>!@+"
+		     ;;				    macro-start t)
+		     (let ((pte (point))
+			   ;; If the caller turned on recording for us,
+			   ;; it shouldn't apply when we check the
+			   ;; preceding label.
+			   c-record-type-identifiers)
+		       ;; A label can't start at a cpp directive.  Check for
+		       ;; this, since c-forward-syntactic-ws would foul up on it.
+		       (unless (and c-opt-cpp-prefix (looking-at c-opt-cpp-prefix))
+			 (c-forward-syntactic-ws)
+			 (c-forward-label nil pte start))))))))))
+
+	   ;; Check that the next nonsymbol token is ":", or that we're in one
+	   ;; of QT's "slots" declarations.  Allow '(' for the sake of macro
+	   ;; arguments.  FIXME: Should build this regexp from the language
+	   ;; constants.
+	   (when (c-syntactic-re-search-forward
+		  "[ \t[:?;{=*/%&|,<>!@+-]" limit t t) ; not at EOB
+	     (backward-char)
+	     (setq qt-symbol-idx
+		   (and (c-major-mode-is 'c++-mode)
+			(string-match
+			 "\\(p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|more\\)\\>"
+			 (buffer-substring start (point)))))
+	     (c-forward-syntactic-ws limit)
+	     (when (or (looking-at ":\\([^:]\\|\\'\\)") ; A single colon.
+		       (and qt-symbol-idx
+			    (search-forward-regexp "\\=slots\\>" limit t)
+			    (progn (c-forward-syntactic-ws limit)
+				   (looking-at ":\\([^:]\\|\\'\\)")))) ; A single colon
+	       (forward-char)		; to after the colon.
+	       t)))
 
       (save-restriction
 	(narrow-to-region start (point))
@@ -6145,8 +6206,8 @@
 	      ;; so that we don't get stuck on that instead of the
 	      ;; function arglist.
 	      (c-forward-sexp))
-	     ((and c-opt-op-identitier-prefix
-		   (looking-at c-opt-op-identitier-prefix))
+	     ((and c-opt-op-identifier-prefix
+		   (looking-at c-opt-op-identifier-prefix))
 	      ;; Don't trip up on "operator ()".
 	      (c-forward-token-2 2 t)))
        (and (< (point) beg)
@@ -6263,10 +6324,10 @@
     (and c-overloadable-operators-regexp
 	 (zerop (c-backward-token-2 1 nil lim))
 	 (looking-at c-overloadable-operators-regexp)
-	 (or (not c-opt-op-identitier-prefix)
+	 (or (not c-opt-op-identifier-prefix)
 	     (and
 	      (zerop (c-backward-token-2 1 nil lim))
-	      (looking-at c-opt-op-identitier-prefix)))
+	      (looking-at c-opt-op-identifier-prefix)))
 	 (point))))
 
 (defsubst c-backward-to-block-anchor (&optional lim)
@@ -6314,7 +6375,7 @@
 		 ;; operator token preceded by "operator".
 		 (save-excursion
 		   (and (c-safe (c-backward-sexp) t)
-			(looking-at c-opt-op-identitier-prefix)))
+			(looking-at c-opt-op-identifier-prefix)))
 		 (and (eq (char-before) ?<)
 		      (c-with-syntax-table c++-template-syntax-table
 			(if (c-safe (goto-char (c-up-list-forward (point))))
@@ -6354,6 +6415,10 @@
       ;; construct, i.e. if it isn't preceded by ';', '}', ':', bob,
       ;; or an open paren.
       (let ((beg (point)) tentative-move)
+	;; Go back one "statement" each time round the loop until we're just
+	;; after a ;, }, or :, or at BOB or the start of a macro or start of
+	;; an ObjC method.  This will move over a multiple declaration whose
+	;; components are comma separated.
 	(while (and
 		;; Must check with c-opt-method-key in ObjC mode.
 		(not (and c-opt-method-key
@@ -6397,25 +6462,39 @@
 			   knr-argdecl-start))
 	    (goto-char fallback-pos))))
 
-      ;; `c-beginning-of-statement-1' counts each brace block as a
-      ;; separate statement, so the result will be 'previous if we've
-      ;; moved over any.  If they were brace list initializers we might
-      ;; not have moved over a declaration boundary though, so change it
-      ;; to 'same if we've moved past a '=' before '{', but not ';'.
-      ;; (This ought to be integrated into `c-beginning-of-statement-1',
-      ;; so we avoid this extra pass which potentially can search over a
-      ;; large amount of text.)
+      ;; `c-beginning-of-statement-1' counts each brace block as a separate
+      ;; statement, so the result will be 'previous if we've moved over any.
+      ;; So change our result back to 'same if necessary.
+      ;;
+      ;; If they were brace list initializers we might not have moved over a
+      ;; declaration boundary though, so change it to 'same if we've moved
+      ;; past a '=' before '{', but not ';'.  (This ought to be integrated
+      ;; into `c-beginning-of-statement-1', so we avoid this extra pass which
+      ;; potentially can search over a large amount of text.).  Take special
+      ;; pains not to get mislead by C++'s "operator=", and the like.
       (if (and (eq move 'previous)
 	       (c-with-syntax-table (if (c-major-mode-is 'c++-mode)
 					c++-template-syntax-table
 				      (syntax-table))
 		 (save-excursion
-		   (and (c-syntactic-re-search-forward "[;={]" start t t t)
-			(eq (char-before) ?=)
-			(c-syntactic-re-search-forward "[;{]" start t t)
-			(eq (char-before) ?{)
-			(c-safe (goto-char (c-up-list-forward (point))) t)
-			(not (c-syntactic-re-search-forward ";" start t t))))))
+		   (and
+		    (progn
+		      (while  ; keep going back to "[;={"s until we either find
+			    ; no more, or get to one which isn't an "operator ="
+			  (and (c-syntactic-re-search-forward "[;={]" start t t t)
+			       (eq (char-before) ?=)
+			       c-overloadable-operators-regexp
+			       c-opt-op-identifier-prefix
+			       (save-excursion
+				 (eq (c-backward-token-2) 0)
+				 (looking-at c-overloadable-operators-regexp)
+				 (eq (c-backward-token-2) 0)
+				 (looking-at c-opt-op-identifier-prefix))))
+		      (eq (char-before) ?=))
+		    (c-syntactic-re-search-forward "[;{]" start t t)
+		    (eq (char-before) ?{)
+		    (c-safe (goto-char (c-up-list-forward (point))) t)
+		    (not (c-syntactic-re-search-forward ";" start t t))))))
 	  (cons 'same nil)
 	(cons move nil)))))
 
@@ -6725,8 +6804,8 @@
 			(setq braceassignp
 			      (cond
 			       ;; Check for operator =
-			       ((and c-opt-op-identitier-prefix
-				     (looking-at c-opt-op-identitier-prefix))
+			       ((and c-opt-op-identifier-prefix
+				     (looking-at c-opt-op-identifier-prefix))
 				nil)
 			       ;; Check for `<opchar>= in Pike.
 			       ((and (c-major-mode-is 'pike-mode)
@@ -7000,6 +7079,11 @@
 			  stop-at-boi-only
 			  containing-sexp
 			  paren-state)
+  ;; Add the indicated SYNTAX-SYMBOL to `c-syntactic-context', extending it as
+  ;; needed with further syntax elements of the types `substatement',
+  ;; `inexpr-statement', `arglist-cont-nonempty', `statement-block-intro', and
+  ;; `defun-block-intro'.
+  ;; 
   ;; Do the generic processing to anchor the given syntax symbol on
   ;; the preceding statement: Skip over any labels and containing
   ;; statements on the same line, and then search backward until we
@@ -8085,7 +8169,9 @@
 	      (and (eq (char-before) ?})
 		   (save-excursion
 		     (let ((start (point)))
-		       (if c-state-cache
+		       (if (and c-state-cache
+				(consp (car c-state-cache))
+				(eq (cdar c-state-cache) (point)))
 			   ;; Speed up the backward search a bit.
 			   (goto-char (caar c-state-cache)))
 		       (c-beginning-of-decl-1 containing-sexp)
@@ -8103,26 +8189,30 @@
 
 	   ;; CASE 5J: we are at the topmost level, make
 	   ;; sure we skip back past any access specifiers
-	   ((save-excursion
-	      (setq placeholder (point))
-	      (or (memq char-before-ip '(?\; ?{ ?} nil))
-		  (c-at-vsemi-p before-ws-ip)
-		  (when (and (eq char-before-ip ?:)
-			     (eq (c-beginning-of-statement-1 lim)
-				 'label))
-		    (c-backward-syntactic-ws lim)
-		    (setq placeholder (point)))
-		  (and (c-major-mode-is 'objc-mode)
-		       (catch 'not-in-directive
-			 (c-beginning-of-statement-1 lim)
-			 (setq placeholder (point))
-			 (while (and (c-forward-objc-directive)
-				     (< (point) indent-point))
-			   (c-forward-syntactic-ws)
-			   (if (>= (point) indent-point)
-			       (throw 'not-in-directive t))
-			   (setq placeholder (point)))
-			 nil))))
+	   ((and
+	     ;; A macro continuation line is never at top level.
+	     (not (and macro-start
+		       (> indent-point macro-start)))
+	     (save-excursion
+	       (setq placeholder (point))
+	       (or (memq char-before-ip '(?\; ?{ ?} nil))
+		   (c-at-vsemi-p before-ws-ip)
+		   (when (and (eq char-before-ip ?:)
+			      (eq (c-beginning-of-statement-1 lim)
+				  'label))
+		     (c-backward-syntactic-ws lim)
+		     (setq placeholder (point)))
+		   (and (c-major-mode-is 'objc-mode)
+			(catch 'not-in-directive
+			  (c-beginning-of-statement-1 lim)
+			  (setq placeholder (point))
+			  (while (and (c-forward-objc-directive)
+				      (< (point) indent-point))
+			    (c-forward-syntactic-ws)
+			    (if (>= (point) indent-point)
+				(throw 'not-in-directive t))
+			    (setq placeholder (point)))
+			  nil)))))
 	    ;; For historic reasons we anchor at bol of the last
 	    ;; line of the previous declaration.  That's clearly
 	    ;; highly bogus and useless, and it makes our lives hard
@@ -8177,6 +8267,11 @@
 	    (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
 	    (c-add-syntax 'template-args-cont (c-point 'boi)))
 
+	   ;; CASE 5Q: we are at a statement within a macro.
+	   (macro-start
+	    (c-beginning-of-statement-1 containing-sexp)
+	    (c-add-stmt-syntax 'statement nil t containing-sexp paren-state))
+
 	   ;; CASE 5M: we are at a topmost continuation line
 	   (t
 	    (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
--- a/lisp/progmodes/cc-langs.el	Mon Jan 01 21:49:04 2007 +0000
+++ b/lisp/progmodes/cc-langs.el	Mon Jan 01 22:11:28 2007 +0000
@@ -685,6 +685,16 @@
 (c-lang-defvar c-opt-cpp-macro-define-start
   (c-lang-const c-opt-cpp-macro-define-start))
 
+(c-lang-defconst c-opt-cpp-macro-define-id
+  ;; Regexp matching everything up to the end of the identifier defined
+  ;; by a cpp define.
+  t (if (c-lang-const c-opt-cpp-macro-define)
+	(concat (c-lang-const c-opt-cpp-prefix)	; #
+		(c-lang-const c-opt-cpp-macro-define) ; define
+		"[ \t]+\\(\\sw\\|_\\)+")))
+(c-lang-defvar c-opt-cpp-macro-define-id
+  (c-lang-const c-opt-cpp-macro-define-id))
+
 (c-lang-defconst c-cpp-expr-directives
   "List if cpp directives (without the prefix) that are followed by an
 expression."
@@ -882,7 +892,7 @@
 
 (c-lang-defconst c-overloadable-operators
   "List of the operators that are overloadable, in their \"identifier
-form\".  See also `c-op-identitier-prefix'."
+form\".  See also `c-op-identifier-prefix'."
   t    nil
   c++  '("new" "delete" ;; Can be followed by "[]" but we ignore that.
 	 "+" "-" "*" "/" "%"
@@ -905,7 +915,7 @@
 (c-lang-defvar c-overloadable-operators-regexp
   (c-lang-const c-overloadable-operators-regexp))
 
-(c-lang-defconst c-opt-op-identitier-prefix
+(c-lang-defconst c-opt-op-identifier-prefix
   "Regexp matching the token before the ones in
 `c-overloadable-operators' when operators are specified in their
 \"identifier form\".  This typically matches \"operator\" in C++ where
@@ -916,8 +926,15 @@
 This regexp is assumed to not match any non-operator identifier."
   t   nil
   c++ (c-make-keywords-re t '("operator")))
-(c-lang-defvar c-opt-op-identitier-prefix
-  (c-lang-const c-opt-op-identitier-prefix))
+(c-lang-defvar c-opt-op-identifier-prefix
+  (c-lang-const c-opt-op-identifier-prefix))
+
+;; Note: the following alias is an old name which was a mis-spelling.  It has
+;; been corrected above and throughout cc-engine.el.  It will be removed at
+;; some release very shortly in the future.  ACM, 2006-04-14.
+(defalias 'c-opt-op-identitier-prefix 'c-opt-op-identifier-prefix)
+(make-obsolete-variable 'c-opt-op-identitier-prefix 'c-opt-op-identifier-prefix
+			"CC Mode 5.31.4, 2006-04-14")
 
 (c-lang-defconst c-other-op-syntax-tokens
   "List of the tokens made up of characters in the punctuation or
--- a/lisp/progmodes/cc-mode.el	Mon Jan 01 21:49:04 2007 +0000
+++ b/lisp/progmodes/cc-mode.el	Mon Jan 01 22:11:28 2007 +0000
@@ -288,8 +288,9 @@
 			       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)
+  ;; (April 2006): RMS has now approved these commands as defaults.
+  (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)
@@ -728,8 +729,8 @@
     ;; We prevent this by temporarily removing `mode' from the Local Variables
     ;; section.
     (if (or c-file-style c-file-offsets)
-	(c-tentative-buffer-changes
-	  (let ((hack-local-variables-hook nil))
+	(let ((hack-local-variables-hook nil) (inhibit-read-only t))
+	  (c-tentative-buffer-changes
 	    (c-remove-any-local-eval-or-mode-variables)
 	    (hack-local-variables))
 	  nil))))
--- a/lisp/progmodes/cc-styles.el	Mon Jan 01 21:49:04 2007 +0000
+++ b/lisp/progmodes/cc-styles.el	Mon Jan 01 22:11:28 2007 +0000
@@ -68,7 +68,10 @@
 			 (arglist-intro . c-lineup-arglist-intro-after-paren)
 			 (arglist-close . c-lineup-arglist)
 			 (inline-open . 0)
-			 (brace-list-open . +)))
+			 (brace-list-open . +)
+			 (topmost-intro-cont
+			  . (first c-lineup-topmost-intro-cont
+				   c-lineup-gnu-DEFUN-intro-cont))))
      (c-special-indent-hook . c-gnu-impose-minimum)
      (c-block-comment-prefix . ""))
 
--- a/lisp/progmodes/cc-vars.el	Mon Jan 01 21:49:04 2007 +0000
+++ b/lisp/progmodes/cc-vars.el	Mon Jan 01 22:11:28 2007 +0000
@@ -622,10 +622,10 @@
  empty-defun-braces  -- Clean up empty defun braces by placing the
                         braces on the same line.  Clean up occurs when
                         the defun closing brace is typed.
- one-liner-defun     -- If the code inside a function body is a single
-                        line then remove any newlines between that
-                        line and the defun braces so that the whole
-                        body becomes a single line.
+ one-liner-defun     -- If the code inside a function body can fit in
+                        a single line, then remove any newlines
+                        between that line and the defun braces so that
+                        the whole body becomes a single line.
                         `c-max-one-liner-length' gives the maximum
                         length allowed for the resulting line.  Clean
                         up occurs when the closing brace is typed.
@@ -1604,7 +1604,8 @@
 
 (defvar c-indentation-style nil
   "Name of the currently installed style.
-Don't change this directly; call `c-set-style' instead.")
+Don't change this directly; call `c-set-style' instead, or set the variable
+`c-file-style' in the file's Local Variable list.")
 
 (defvar c-current-comment-prefix nil
   "The current comment prefix regexp.