emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/progmodes/cc-engine.el, v [EMACS_22_


From: Alan Mackenzie
Subject: [Emacs-diffs] Changes to emacs/lisp/progmodes/cc-engine.el, v [EMACS_22_BASE]
Date: Sat, 25 Aug 2007 16:50:27 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Branch:         EMACS_22_BASE
Changes by:     Alan Mackenzie <acmacm> 07/08/25 16:50:27

Index: cc-engine.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-engine.el,v
retrieving revision 1.56.2.2
retrieving revision 1.56.2.3
diff -u -b -r1.56.2.2 -r1.56.2.3
--- cc-engine.el        8 Aug 2007 07:31:11 -0000       1.56.2.2
+++ cc-engine.el        25 Aug 2007 16:50:26 -0000      1.56.2.3
@@ -4067,7 +4067,6 @@
        ;; Changing the amount of (already existing) whitespace - don't do 
anything.
        ((and (c-partial-ws-p beg end)
             (or (= beg end)            ; removal of WS
-                ; (string-match "\\s *\\'" (nth 5 c-maybe-stale-found-type))
                 (string-match "^[ \t\n\r\f\v]*$" (nth 5 
c-maybe-stale-found-type)))))
 
        ;; The syntactic relationship which defined a "found type" has been
@@ -5891,7 +5890,7 @@
   ;;   "private:"/"protected:"/"public:"/"more:" looking like "public slots:".
   ;;   Returns the symbol `qt-2kwds-colon'.
   ;; (v) QT's construct "signals:".  Returns the symbol `qt-1kwd-colon'.
-  ;; (v) One of the keywords matched by `c-opt-extra-label-key' (without any
+  ;; (vi) 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".  Returns t.
   ;;
@@ -6117,8 +6116,7 @@
                                     (match-end 0)))))
 
          (c-put-c-type-property (1- (point-max)) 'c-decl-end)
-         (goto-char (point-max))
-         )))
+         (goto-char (point-max)))))
 
      (t
       ;; Not a label.
@@ -7197,6 +7195,23 @@
 ;; auto newline analysis.
 (defvar c-auto-newline-analysis nil)
 
+(defun c-brace-anchor-point (bracepos)
+  ;; BRACEPOS is the position of a brace in a construct like "namespace
+  ;; Bar {".  Return the anchor point in this construct; this is the
+  ;; earliest symbol on the brace's line which isn't earlier than
+  ;; "namespace".
+  ;;
+  ;; Currently (2007-08-17), "like namespace" means "matches
+  ;; c-other-block-decl-kwds".  It doesn't work with "class" or "struct"
+  ;; or anything like that.
+  (save-excursion
+    (let ((boi (c-point 'boi bracepos)))
+      (goto-char bracepos)
+      (while (and (> (point) boi)
+                 (not (looking-at c-other-decl-block-key)))
+       (c-backward-token-2))
+      (if (> (point) boi) (point) boi))))
+
 (defsubst c-add-syntax (symbol &rest args)
   ;; A simple function to prepend a new syntax element to
   ;; `c-syntactic-context'.  Using `setq' on it is unsafe since it
@@ -7229,8 +7244,12 @@
   ;;
   ;; Point is assumed to be at the prospective anchor point for the
   ;; given SYNTAX-SYMBOL.  More syntax entries are added if we need to
-  ;; skip past open parens and containing statements.  All the added
-  ;; syntax elements will get the same anchor point.
+  ;; skip past open parens and containing statements.  Most of the added
+  ;; syntax elements will get the same anchor point - the exception is
+  ;; for an anchor in a construct like "namespace"[*] - this is as early
+  ;; as possible in the construct but on the same line as the {.
+  ;;
+  ;; [*] i.e. with a keyword matching c-other-block-decl-kwds.
   ;;
   ;; SYNTAX-EXTRA-ARGS are a list of the extra arguments for the
   ;; syntax symbol.  They are appended after the anchor point.
@@ -7255,7 +7274,11 @@
          ;; now at the start.
          on-label)
 
-      (apply 'c-add-syntax syntax-symbol nil syntax-extra-args)
+      ;; Use point as the anchor point for "namespace", "extern", etc.
+      (apply 'c-add-syntax syntax-symbol
+            (if (rassq syntax-symbol c-other-decl-block-key-in-symbols-alist)
+                (point) nil)
+            syntax-extra-args)
 
       ;; Loop while we have to back out of containing blocks.
       (while
@@ -7375,21 +7398,30 @@
                (setq step-type 'same
                      on-label nil))
 
+           ;; Stepped out of a brace block.
            (setq step-type (c-beginning-of-statement-1 containing-sexp)
                  on-label (eq step-type 'label))
 
            (if (and (eq step-type 'same)
                     (/= paren-pos (point)))
-               (save-excursion
+               (let (inexpr)
+                 (cond
+                  ((save-excursion
                  (goto-char paren-pos)
-                 (let ((inexpr (c-looking-at-inexpr-block
-                                (c-safe-position containing-sexp
-                                                 paren-state)
+                     (setq inexpr (c-looking-at-inexpr-block
+                                   (c-safe-position containing-sexp 
paren-state)
                                 containing-sexp)))
-                   (if (and inexpr
-                            (not (eq (car inexpr) 'inlambda)))
-                       (c-add-syntax 'statement-block-intro nil)
-                     (c-add-syntax 'defun-block-intro nil))))
+                   (c-add-syntax (if (eq (car inexpr) 'inlambda)
+                                     'defun-block-intro
+                                   'statement-block-intro)
+                                 nil))
+                  ((looking-at c-other-decl-block-key)
+                   (c-add-syntax
+                    (cdr (assoc (match-string 1)
+                                c-other-decl-block-key-in-symbols-alist))
+                    (max (c-point 'boi paren-pos) (point))))
+                  (t (c-add-syntax 'defun-block-intro nil))))
+                            
              (c-add-syntax 'statement-block-intro nil)))
 
          (if (= paren-pos boi)
@@ -7402,10 +7434,13 @@
 
       ;; Fill in the current point as the anchor for all the symbols
       ;; added above.
-      (let ((p c-syntactic-context))
+      (let ((p c-syntactic-context) q)
        (while (not (eq p syntax-last))
-         (if (cdr (car p))
-             (setcar (cdr (car p)) (point)))
+         (setq q (cdr (car p))) ; e.g. (nil 28) [from (arglist-cont-nonempty 
nil 28)]
+         (while q
+           (unless (car q)
+             (setcar q (point)))
+           (setq q (cdr q)))
          (setq p (cdr p))))
       )))
 
@@ -8360,9 +8395,7 @@
                (if (c-keyword-member containing-decl-kwd
                                      'c-other-block-decl-kwds)
                    (progn
-                     (goto-char containing-decl-open)
-                     (unless (= (point) (c-point 'boi))
-                       (goto-char containing-decl-start))
+                     (goto-char (c-brace-anchor-point containing-decl-open))
                      (c-add-stmt-syntax
                       (if (string-equal (symbol-name containing-decl-kwd)
                                         "extern")




reply via email to

[Prev in Thread] Current Thread [Next in Thread]