1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/394839a483bc/
Changeset: 394839a483bc
User: acm
Date: 2013-09-21 14:41:30
Summary: C++: fontify identifier in declaration following "public:"
correctly.
cc-langs.el (c-decl-start-colon-kwd-re): New lang var to match "public",
etc.
(c-decl-prefix-re): Add ":" into the C++ value.
cc-engine.el (c-find-decl-prefix-search): Refactor a bit. Add a check
for a ":" preceded by "public", etc.
Affected #: 2 files
diff -r fbbd5245fbdc4d5ceed93b22be13f47fa78d48a2 -r
394839a483bc044b94a970df3f4657b35282cac6 cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -4755,6 +4755,11 @@
;; inside `c-find-decl-spots'. The point is left at `cfd-match-pos'
;; if there is a match, otherwise at `cfd-limit'.
;;
+ ;; The macro moves point forward to the next putative start of a declaration
+ ;; or cfd-limit. This decl start is the next token after a "declaration
+ ;; prefix". The declaration prefix is the earlier of `cfd-prop-match' and
+ ;; `cfd-re-match'. `cfd-match-pos' is set to the decl prefix.
+ ;;
;; This macro might do hidden buffer changes.
'(progn
@@ -4776,34 +4781,49 @@
(if (> cfd-re-match-end (point))
(goto-char cfd-re-match-end))
- (while (if (setq cfd-re-match-end
- (re-search-forward c-decl-prefix-or-start-re
- cfd-limit 'move))
-
- ;; Match. Check if it's inside a comment or string literal.
- (c-got-face-at
- (if (setq cfd-re-match (match-end 1))
- ;; Matched the end of a token preceding a decl spot.
- (progn
- (goto-char cfd-re-match)
- (1- cfd-re-match))
- ;; Matched a token that start a decl spot.
- (goto-char (match-beginning 0))
- (point))
- c-literal-faces)
-
- ;; No match. Finish up and exit the loop.
- (setq cfd-re-match cfd-limit)
- nil)
-
- ;; Skip out of comments and string literals.
- (while (progn
- (goto-char (c-next-single-property-change
- (point) 'face nil cfd-limit))
- (and (< (point) cfd-limit)
- (c-got-face-at (point) c-literal-faces)))))
-
- ;; If we matched at the decl start, we have to back up over the
+;;;; NEW STOUGH, 2013-09-21
+ ;; Each time round, the next `while' moves forward over a pseudo match
+ ;; of `c-decl-prefix-or-start-re' which is either inside a literal, or
+ ;; is a ":" not preceded by "public", etc..
`cfd-re-match' and
+ ;; `cfd-re-match-end' get set.
+ (while
+ (progn
+ (setq cfd-re-match-end (re-search-forward c-decl-prefix-or-start-re
+ cfd-limit 'move))
+ (cond
+ ((null cfd-re-match-end)
+ ;; No match. Finish up and exit the loop.
+ (setq cfd-re-match cfd-limit)
+ nil)
+ ((c-got-face-at
+ (if (setq cfd-re-match (match-end 1))
+ ;; Matched the end of a token preceding a decl spot.
+ (progn
+ (goto-char cfd-re-match)
+ (1- cfd-re-match))
+ ;; Matched a token that start a decl spot.
+ (goto-char (match-beginning 0))
+ (point))
+ c-literal-faces)
+ ;; Pseudo match inside a comment or string literal. Skip out
+ ;; of comments and string literals.
+ (while (progn
+ (goto-char (c-next-single-property-change
+ (point) 'face nil cfd-limit))
+ (and (< (point) cfd-limit)
+ (c-got-face-at (point) c-literal-faces))))
+ t) ; Continue the loop over pseudo matches.
+ ((and (match-string 1)
+ (string= (match-string 1) ":")
+ (save-excursion
+ (or (/= (c-backward-token-2 2) 0) ; no search limit. :-(
+ (not (looking-at c-decl-start-colon-kwd-re)))))
+ ;; Found a ":" which isn't part of "public:", etc.
+ t)
+ (t nil)))) ;; Found a real match. Exit the pseudo-match loop.
+;;;; END OF NEW STOUGH
+
+ ;; If our match was at the decl start, we have to back up over the
;; preceding syntactic ws to set `cfd-match-pos' and to catch
;; any decl spots in the syntactic ws.
(unless cfd-re-match
diff -r fbbd5245fbdc4d5ceed93b22be13f47fa78d48a2 -r
394839a483bc044b94a970df3f4657b35282cac6 cc-langs.el
--- a/cc-langs.el
+++ b/cc-langs.el
@@ -2578,6 +2578,15 @@
;;; Additional constants for parser-level constructs.
+(c-lang-defconst c-decl-start-colon-kwd-re
+ "Regexp matching a keyword that is followed by a colon, where
+ the whole construct can precede a declaration.
+ E.g. \"public:\" in C++."
+ t "\\<\\>"
+ c++ (c-make-keywords-re t (c-lang-const c-protection-kwds)))
+(c-lang-defvar c-decl-start-colon-kwd-re
+ (c-lang-const c-decl-start-colon-kwd-re))
+
(c-lang-defconst c-decl-prefix-re
"Regexp matching something that might precede a declaration, cast or
label, such as the last token of a preceding statement or declaration.
@@ -2617,8 +2626,11 @@
java "\\([\{\}\(;,<]+\\)"
;; Match "<" in C++ to get the first argument in a template arglist.
;; In that case there's an additional check in `c-find-decl-spots'
- ;; that it got open paren syntax.
- c++ "\\([\{\}\(\);,<]+\\)"
+ ;; that it got open paren syntax. Match ":" to aid in picking up
+ ;; "public:", etc. This involves additional checks in
+ ;; `c-find-decl-prefix-search' to prevent a match of identifiers
+ ;; or labels.
+ c++ "\\([\{\}\(\);:,<]+\\)"
;; Additionally match the protection directives in Objective-C.
;; Note that this doesn't cope with the longer directives, which we
;; would have to match from start to end since they don't end with
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.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches