aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2016-04-29 13:35:01 +0000
committerAlan Mackenzie2016-04-29 13:35:01 +0000
commit48b24c9b031ba593426d4e9980b360c273f57166 (patch)
treeb0bd4f7b5147e4a22964a56b1505130225dbd4eb
parent5c3534ffdcce41b1aab7bd158cf07224446caa9d (diff)
downloademacs-48b24c9b031ba593426d4e9980b360c273f57166.tar.gz
emacs-48b24c9b031ba593426d4e9980b360c273f57166.zip
Correct indentation of ids in a C++ enum after a protection keyword.
Also correct the misfontification of the last enum identifier. * lisp/progmodes/cc-engine.el (c-forward-keyword-prefixed-id): setq c-last-identifier-range to nil to ensure that only types recognized by this macro are set for fontification as types. (c-backward-typed-enum-colon): Function renamed from c-backward-colon-prefixed-type. On finding a colon in the backward search, check it is preceded by an identifier rather than a keyword.
-rw-r--r--lisp/progmodes/cc-engine.el18
1 files changed, 11 insertions, 7 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 62bc236706d..b2fe9b27e38 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -5806,6 +5806,7 @@ comment at the start of cc-engine.el for more info."
5806 ;; 5806 ;;
5807 ;; This macro might do hidden buffer changes. 5807 ;; This macro might do hidden buffer changes.
5808 `(let (res) 5808 `(let (res)
5809 (setq c-last-identifier-range nil)
5809 (while (if (setq res ,(if (eq type 'type) 5810 (while (if (setq res ,(if (eq type 'type)
5810 `(c-forward-type) 5811 `(c-forward-type)
5811 `(c-forward-name))) 5812 `(c-forward-name)))
@@ -8928,11 +8929,11 @@ comment at the start of cc-engine.el for more info."
8928 (not (looking-at "="))))) 8929 (not (looking-at "=")))))
8929 b-pos))) 8930 b-pos)))
8930 8931
8931(defun c-backward-colon-prefixed-type () 8932(defun c-backward-typed-enum-colon ()
8932 ;; We're at the token after what might be a type prefixed with a colon. Try 8933 ;; We're at a "{" which might be the opening brace of a enum which is
8933 ;; moving backward over this type and the colon. On success, return t and 8934 ;; strongly typed (by a ":" followed by a type). If this is the case, leave
8934 ;; leave point before colon; on failure, leave point unchanged. Will clobber 8935 ;; point before the colon and return t. Otherwise leave point unchanged and return nil.
8935 ;; match data. 8936 ;; Match data will be clobbered.
8936 (let ((here (point)) 8937 (let ((here (point))
8937 (colon-pos nil)) 8938 (colon-pos nil))
8938 (save-excursion 8939 (save-excursion
@@ -8941,7 +8942,10 @@ comment at the start of cc-engine.el for more info."
8941 (or (not (looking-at "\\s)")) 8942 (or (not (looking-at "\\s)"))
8942 (c-go-up-list-backward)) 8943 (c-go-up-list-backward))
8943 (cond 8944 (cond
8944 ((eql (char-after) ?:) 8945 ((and (eql (char-after) ?:)
8946 (save-excursion
8947 (c-backward-syntactic-ws)
8948 (c-on-identifier)))
8945 (setq colon-pos (point)) 8949 (setq colon-pos (point))
8946 (forward-char) 8950 (forward-char)
8947 (c-forward-syntactic-ws) 8951 (c-forward-syntactic-ws)
@@ -8965,7 +8969,7 @@ comment at the start of cc-engine.el for more info."
8965 (let ((here (point)) 8969 (let ((here (point))
8966 up-sexp-pos before-identifier) 8970 up-sexp-pos before-identifier)
8967 (when c-recognize-post-brace-list-type-p 8971 (when c-recognize-post-brace-list-type-p
8968 (c-backward-colon-prefixed-type)) 8972 (c-backward-typed-enum-colon))
8969 (while 8973 (while
8970 (and 8974 (and
8971 (eq (c-backward-token-2) 0) 8975 (eq (c-backward-token-2) 0)