]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix indentation/fontification of Java enum with "implements".
authorAlan Mackenzie <acm@muc.de>
Sat, 28 Sep 2013 17:17:01 +0000 (17:17 +0000)
committerAlan Mackenzie <acm@muc.de>
Sat, 28 Sep 2013 17:17:01 +0000 (17:17 +0000)
* progmodes/cc-langs.el (c-postfix-decl-spec-key): New variable, a
regexp which matches "implements", etc., in Java.
* progmodes/cc-engine.el (c-inside-bracelist-p): Check for extra
specifier clauses coming after "enum".
* progmodes/cc-fonts.el (c-font-lock-declarations)
(c-font-lock-enum-tail): Check for extra specifier clauses coming
after "enum".

lisp/ChangeLog
lisp/progmodes/cc-engine.el
lisp/progmodes/cc-fonts.el
lisp/progmodes/cc-langs.el

index 0affac1deaae0b8a06ed501c2a1fceaf98708c88..9a04acfa6863fdf021664209a90448a1e0da6f09 100644 (file)
@@ -1,3 +1,15 @@
+2013-09-28  Alan Mackenzie  <acm@muc.de>
+
+       Fix indentation/fontification of Java enum with "implements".
+
+       * progmodes/cc-langs.el (c-postfix-decl-spec-key): New variable, a
+       regexp which matches "implements", etc., in Java.
+       * progmodes/cc-engine.el (c-inside-bracelist-p): Check for extra
+       specifier clauses coming after "enum".
+       * progmodes/cc-fonts.el (c-font-lock-declarations)
+       (c-font-lock-enum-tail): Check for extra specifier clauses coming
+       after "enum".
+
 2013-09-28  Jan Djärv  <jan.h.d@swipnet.se>
 
        * faces.el (region): Change ns_selection_color to
index ce83efd114b3d96dfb6a19f0cafabb4ff8ffc5f1..b3a6a0e3f03a26b5a7118bfbf8b9cae2f1ee9baa 100644 (file)
@@ -8486,17 +8486,21 @@ comment at the start of cc-engine.el for more info."
   (or
    ;; This will pick up brace list declarations.
    (c-safe
-    (save-excursion
-      (goto-char containing-sexp)
-      (c-forward-sexp -1)
-      (let (bracepos)
-       (if (and (or (looking-at c-brace-list-key)
-                    (progn (c-forward-sexp -1)
-                           (looking-at c-brace-list-key)))
-                (setq bracepos (c-down-list-forward (point)))
-                (not (c-crosses-statement-barrier-p (point)
-                                                    (- bracepos 2))))
-           (point)))))
+     (save-excursion
+       (goto-char containing-sexp)
+       (let (before-identifier)
+        (while
+            (progn
+              (c-forward-sexp -1)
+              (cond
+               ((c-on-identifier) (setq before-identifier t))
+               ((and before-identifier
+                     (looking-at c-postfix-decl-spec-key))
+                (setq before-identifier nil)
+                t)
+               ((looking-at c-brace-list-key) nil)
+               (t nil))))
+        (looking-at c-brace-list-key))))
    ;; this will pick up array/aggregate init lists, even if they are nested.
    (save-excursion
      (let ((class-key
index 4e8ce6bac2824eeddfb3485e7421b6ef816f74f1..4f9289c307d684210ea3d397e7058319af3219e6 100644 (file)
@@ -1471,13 +1471,22 @@ casts and declarations are fontified.  Used on level 2 and higher."
                   (let ((paren-state (c-parse-state)))
                     (and
                      (numberp (car paren-state))
-                     (save-excursion
-                       (goto-char (car paren-state))
-                       (c-backward-token-2)
-                       (or (looking-at c-brace-list-key)
-                           (progn
-                             (c-backward-token-2)
-                             (looking-at c-brace-list-key)))))))
+                     (c-safe
+                       (save-excursion
+                         (goto-char (car paren-state))
+                         (let (before-identifier)
+                           (while
+                               (progn
+                                 (c-forward-sexp -1)
+                                 (cond
+                                  ((c-on-identifier) (setq before-identifier t))
+                                  ((and before-identifier
+                                        (looking-at c-postfix-decl-spec-key))
+                                   (setq before-identifier nil)
+                                   t)
+                                  ((looking-at c-brace-list-key) nil) ; "enum"
+                                  (t nil))))
+                           (looking-at c-brace-list-key)))))))
              (c-forward-token-2)
              nil)
 
@@ -1565,14 +1574,22 @@ casts and declarations are fontified.  Used on level 2 and higher."
     (when (and
           encl-pos
           (eq (char-after encl-pos) ?\{)
-          (save-excursion
-            (goto-char encl-pos)
-            (c-backward-syntactic-ws)
-            (c-simple-skip-symbol-backward)
-            (or (looking-at c-brace-list-key) ; "enum"
-                (progn (c-backward-syntactic-ws)
-                       (c-simple-skip-symbol-backward)
-                       (looking-at c-brace-list-key)))))
+          (c-safe
+            (save-excursion
+              (goto-char encl-pos)
+              (let (before-identifier)
+                (while
+                    (progn
+                     (c-forward-sexp -1)
+                     (cond
+                      ((c-on-identifier) (setq before-identifier t))
+                      ((and before-identifier
+                            (looking-at c-postfix-decl-spec-key))
+                       (setq before-identifier nil)
+                       t)
+                      ((looking-at c-brace-list-key) nil) ; "enum"
+                      (t nil))))
+                (looking-at c-brace-list-key)))))
       (c-syntactic-skip-backward "^{," nil t)
       (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start)
 
index c1e8a1524dccc9e6fd9a98d9e731ac4e4c593491..bf72ab879aff16e41c50963b3bf964f3506c295b 100644 (file)
@@ -2040,6 +2040,12 @@ declarations."
         ;; In CORBA PSDL:
         "as" "const" "implements" "of" "ref"))
 
+(c-lang-defconst c-postfix-decl-spec-key
+  ;; Regexp matching the keywords in `c-postfix-decl-spec-kwds'.
+  t (c-make-keywords-re t (c-lang-const c-postfix-decl-spec-kwds)))
+(c-lang-defvar c-postfix-decl-spec-key
+  (c-lang-const c-postfix-decl-spec-key))
+
 (c-lang-defconst c-nonsymbol-sexp-kwds
   "Keywords that may be followed by a nonsymbol sexp before whatever
 construct it's part of continues."