aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2013-10-13 19:54:46 +0000
committerAlan Mackenzie2013-10-13 19:54:46 +0000
commit7a068717166757eacc702cb499dc803be0645211 (patch)
tree4d145c8eb55a32c77373ba88d5a9e292e298b489
parent3ccc2d283e149f838b00bde2f841cc70316ecc74 (diff)
downloademacs-7a068717166757eacc702cb499dc803be0645211.tar.gz
emacs-7a068717166757eacc702cb499dc803be0645211.zip
Fix indentation/fontification of Java enum with "implements"/generic.
* progmodes/cc-engine.el (c-backward-over-enum-header): Extracted from the three other places and enhanced to handle generics. (c-inside-bracelist-p): Uses new function above. * progmodes/cc-fonts.el (c-font-lock-declarations): Uses new function above. (c-font-lock-enum-tail): Uses new function above.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/progmodes/cc-engine.el45
-rw-r--r--lisp/progmodes/cc-fonts.el38
3 files changed, 47 insertions, 48 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1abd0482ec6..e3f32150ee6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12013-10-13 Alan Mackenzie <acm@muc.de>
2
3 Fix indentation/fontification of Java enum with
4 "implements"/generic.
5
6 * progmodes/cc-engine.el (c-backward-over-enum-header): Extracted
7 from the three other places and enhanced to handle generics.
8 (c-inside-bracelist-p): Uses new function above.
9 * progmodes/cc-fonts.el (c-font-lock-declarations): Uses new
10 function above.
11 (c-font-lock-enum-tail): Uses new function above.
12
12013-10-13 Kenichi Handa <handa@gnu.org> 132013-10-13 Kenichi Handa <handa@gnu.org>
2 14
3 * international/mule-cmds.el (select-safe-coding-system): Remove a 15 * international/mule-cmds.el (select-safe-coding-system): Remove a
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index b3a6a0e3f03..d624d1eaed2 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -8471,6 +8471,32 @@ comment at the start of cc-engine.el for more info."
8471 (not (looking-at "="))))) 8471 (not (looking-at "=")))))
8472 b-pos))) 8472 b-pos)))
8473 8473
8474(defun c-backward-over-enum-header ()
8475 ;; We're at a "{". Move back to the enum-like keyword that starts this
8476 ;; declaration and return t, otherwise don't move and return nil.
8477 (let ((here (point))
8478 up-sexp-pos before-identifier)
8479 (while
8480 (and
8481 (eq (c-backward-token-2) 0)
8482 (or (not (looking-at "\\s)"))
8483 (c-go-up-list-backward))
8484 (cond
8485 ((and (looking-at c-symbol-key) (c-on-identifier))
8486 (setq before-identifier t))
8487 ((and before-identifier
8488 (looking-at c-postfix-decl-spec-key))
8489 (setq before-identifier nil)
8490 t)
8491 ((looking-at c-brace-list-key) nil)
8492 ((and c-recognize-<>-arglists
8493 (eq (char-after) ?<)
8494 (looking-at "\\s("))
8495 t)
8496 (t nil))))
8497 (or (looking-at c-brace-list-key)
8498 (progn (goto-char here) nil))))
8499
8474(defun c-inside-bracelist-p (containing-sexp paren-state) 8500(defun c-inside-bracelist-p (containing-sexp paren-state)
8475 ;; return the buffer position of the beginning of the brace list 8501 ;; return the buffer position of the beginning of the brace list
8476 ;; statement if we're inside a brace list, otherwise return nil. 8502 ;; statement if we're inside a brace list, otherwise return nil.
@@ -8485,22 +8511,9 @@ comment at the start of cc-engine.el for more info."
8485 ;; This function might do hidden buffer changes. 8511 ;; This function might do hidden buffer changes.
8486 (or 8512 (or
8487 ;; This will pick up brace list declarations. 8513 ;; This will pick up brace list declarations.
8488 (c-safe 8514 (save-excursion
8489 (save-excursion 8515 (goto-char containing-sexp)
8490 (goto-char containing-sexp) 8516 (c-backward-over-enum-header))
8491 (let (before-identifier)
8492 (while
8493 (progn
8494 (c-forward-sexp -1)
8495 (cond
8496 ((c-on-identifier) (setq before-identifier t))
8497 ((and before-identifier
8498 (looking-at c-postfix-decl-spec-key))
8499 (setq before-identifier nil)
8500 t)
8501 ((looking-at c-brace-list-key) nil)
8502 (t nil))))
8503 (looking-at c-brace-list-key))))
8504 ;; this will pick up array/aggregate init lists, even if they are nested. 8517 ;; this will pick up array/aggregate init lists, even if they are nested.
8505 (save-excursion 8518 (save-excursion
8506 (let ((class-key 8519 (let ((class-key
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 4f9289c307d..bcd4a5f28f8 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1471,22 +1471,9 @@ casts and declarations are fontified. Used on level 2 and higher."
1471 (let ((paren-state (c-parse-state))) 1471 (let ((paren-state (c-parse-state)))
1472 (and 1472 (and
1473 (numberp (car paren-state)) 1473 (numberp (car paren-state))
1474 (c-safe 1474 (save-excursion
1475 (save-excursion 1475 (goto-char (car paren-state))
1476 (goto-char (car paren-state)) 1476 (c-backward-over-enum-header)))))
1477 (let (before-identifier)
1478 (while
1479 (progn
1480 (c-forward-sexp -1)
1481 (cond
1482 ((c-on-identifier) (setq before-identifier t))
1483 ((and before-identifier
1484 (looking-at c-postfix-decl-spec-key))
1485 (setq before-identifier nil)
1486 t)
1487 ((looking-at c-brace-list-key) nil) ; "enum"
1488 (t nil))))
1489 (looking-at c-brace-list-key)))))))
1490 (c-forward-token-2) 1477 (c-forward-token-2)
1491 nil) 1478 nil)
1492 1479
@@ -1574,22 +1561,9 @@ casts and declarations are fontified. Used on level 2 and higher."
1574 (when (and 1561 (when (and
1575 encl-pos 1562 encl-pos
1576 (eq (char-after encl-pos) ?\{) 1563 (eq (char-after encl-pos) ?\{)
1577 (c-safe 1564 (save-excursion
1578 (save-excursion 1565 (goto-char encl-pos)
1579 (goto-char encl-pos) 1566 (c-backward-over-enum-header)))
1580 (let (before-identifier)
1581 (while
1582 (progn
1583 (c-forward-sexp -1)
1584 (cond
1585 ((c-on-identifier) (setq before-identifier t))
1586 ((and before-identifier
1587 (looking-at c-postfix-decl-spec-key))
1588 (setq before-identifier nil)
1589 t)
1590 ((looking-at c-brace-list-key) nil) ; "enum"
1591 (t nil))))
1592 (looking-at c-brace-list-key)))))
1593 (c-syntactic-skip-backward "^{," nil t) 1567 (c-syntactic-skip-backward "^{," nil t)
1594 (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start) 1568 (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start)
1595 1569