;; 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.
(if (> cfd-re-match-end (point))
- (while (if (setq cfd-re-match-end
- (re-search-forward c-decl-prefix-or-start-re
- ;; Match. Check if it's inside a comment or string literal.
- (if (setq cfd-re-match (match-end 1))
- ;; Matched the end of a token preceding a decl spot.
- (goto-char cfd-re-match)
- ;; Matched a token that start a decl spot.
- (goto-char (match-beginning 0))
- ;; No match. Finish up and exit the loop.
- (setq cfd-re-match cfd-limit)
- ;; Skip out of comments and string literals.
- (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.
+ (setq cfd-re-match-end (re-search-forward c-decl-prefix-or-start-re
+ ((null cfd-re-match-end)
+ ;; No match. Finish up and exit the loop.
+ (setq cfd-re-match cfd-limit)
+ (if (setq cfd-re-match (match-end 1))
+ ;; Matched the end of a token preceding a decl spot.
+ (goto-char cfd-re-match)
+ ;; Matched a token that start a decl spot.
+ (goto-char (match-beginning 0))
+ ;; Pseudo match inside a comment or string literal. Skip out
+ ;; of comments and string literals.
+ (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.
+ (string= (match-string 1) ":")
+ (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 nil)))) ;; Found a real match. Exit the pseudo-match loop.
+ ;; 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.