1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/a8a9fbb96c60/
Changeset: a8a9fbb96c60
User: acm
Date: 2017-09-15 15:40:14+00:00
Summary: Cope better with C++ and Objective-C protection keywords in class
declarations
This fix fixes the fontification of method inside a class at the time it is
typed, when there is a protection keyword clause preceding it.
* cc-engine.el (c-forward-keyword-clause): Handle protection keywords.
(c-looking-at-decl-block): Avoid scanning forward over protection keyword
clauses too eagerly.
* cc-langs.el (c-protection-key c-post-protection-token): New lang defconsts
and defvars.
* cc-mode.el (c-fl-decl-start): When we encounter a protection keyword
following a semicolon or brace, move forward over it before attempting to
parse a type.
Affected #: 3 files
diff -r e8243bf18226f0dc79f526d38a369fa78a76edf1 -r
a8a9fbb96c60e0d68e7aee22ffaaee192a1fc966 cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -6937,7 +6937,7 @@
;; recognized are those specified by `c-type-list-kwds',
;; `c-ref-list-kwds', `c-colon-type-list-kwds',
;; `c-paren-nontype-kwds', `c-paren-type-kwds', `c-<>-type-kwds',
- ;; and `c-<>-arglist-kwds'.
+ ;; `c-<>-arglist-kwds', and `c-protection-kwds'.
;;
;; This function records identifier ranges on
;; `c-record-type-identifiers' and `c-record-ref-identifiers' if
@@ -7007,6 +7007,17 @@
(not (looking-at c-symbol-start))
(c-safe (c-forward-sexp) t))
(c-forward-syntactic-ws)
+ (setq safe-pos (point)))
+
+ ((and (c-keyword-member kwd-sym 'c-protection-kwds)
+ (or (null c-post-protection-token)
+ (and (looking-at c-post-protection-token)
+ (save-excursion
+ (goto-char (match-end 0))
+ (not (c-end-of-current-token))))))
+ (if c-post-protection-token
+ (goto-char (match-end 0)))
+ (c-forward-syntactic-ws)
(setq safe-pos (point))))
(when (c-keyword-member kwd-sym 'c-colon-type-list-kwds)
@@ -10178,8 +10189,16 @@
;; Could be more restrictive wrt invalid keywords,
;; but that'd only occur in invalid code so there's
;; no use spending effort on it.
- (let ((end (match-end 0)))
- (unless (c-forward-keyword-clause 0)
+ (let ((end (match-end 0))
+ (kwd-sym (c-keyword-sym (match-string 0))))
+ (unless
+ (and kwd-sym
+ ;; Moving over a protection kwd and the following
+ ;; ":" (in C++ Mode) to the next token could take
+ ;; us all the way up to `kwd-start', leaving us
+ ;; no chance to update `first-specifier-pos'.
+ (not (c-keyword-member kwd-sym 'c-protection-kwds))
+ (c-forward-keyword-clause 0))
(goto-char end)
(c-forward-syntactic-ws)))
diff -r e8243bf18226f0dc79f526d38a369fa78a76edf1 -r
a8a9fbb96c60e0d68e7aee22ffaaee192a1fc966 cc-langs.el
--- a/cc-langs.el
+++ b/cc-langs.el
@@ -2267,6 +2267,18 @@
c++ '("private" "protected" "public")
objc '("@private" "@protected" "@public"))
+(c-lang-defconst c-protection-key
+ ;; A regexp match an element of `c-protection-kwds' cleanly.
+ t (c-make-keywords-re t (c-lang-const c-protection-kwds)))
+(c-lang-defvar c-protection-key (c-lang-const c-protection-key))
+
+(c-lang-defconst c-post-protection-token
+ "The token which (may) follow a protection keyword,
+e.g. the \":\" in C++ Mode's \"public:\". nil if there is no
such token."
+ t nil
+ c++ ":")
+(c-lang-defvar c-post-protection-token (c-lang-const c-post-protection-token))
+
(c-lang-defconst c-block-decls-with-vars
"Keywords introducing declarations that can contain a block which
might be followed by variable declarations, e.g. like \"foo\" in
diff -r e8243bf18226f0dc79f526d38a369fa78a76edf1 -r
a8a9fbb96c60e0d68e7aee22ffaaee192a1fc966 cc-mode.el
--- a/cc-mode.el
+++ b/cc-mode.el
@@ -1506,14 +1506,17 @@
(> (point) bod-lim)
(progn (c-forward-syntactic-ws)
(setq bo-decl (point))
- ;; Are we looking at a keyword such as "template" or
- ;; "typedef" which can decorate a type, or the type itself?
- (when (or (looking-at c-prefix-spec-kwds-re)
- (c-forward-type t))
- ;; We've found another candidate position.
- (setq new-pos (min new-pos bo-decl))
- (goto-char bo-decl))
- t)
+ (or (not (looking-at c-protection-key))
+ (c-forward-keyword-clause 1)))
+ (progn
+ ;; Are we looking at a keyword such as "template" or
+ ;; "typedef" which can decorate a type, or the type itself?
+ (when (or (looking-at c-prefix-spec-kwds-re)
+ (c-forward-type t))
+ ;; We've found another candidate position.
+ (setq new-pos (min new-pos bo-decl))
+ (goto-char bo-decl))
+ t)
;; Try and go out a level to search again.
(progn
(c-backward-syntactic-ws bod-lim)
Repository URL:
https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from
bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.