aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2017-07-27 17:56:23 +0000
committerAlan Mackenzie2017-07-27 17:56:23 +0000
commiteaa5dc9d102d10c79f10bee1994ad922b8fcf9c4 (patch)
treec57927ad89a09bc01269f62d946e4e05f5161192
parent30e6e558701ebc781cdca3b9d61d995004cfef7d (diff)
downloademacs-eaa5dc9d102d10c79f10bee1994ad922b8fcf9c4.tar.gz
emacs-eaa5dc9d102d10c79f10bee1994ad922b8fcf9c4.zip
Fix C++ class initializers not always being fontified at mode start.
The problem here happened when an "outer list" of declarations moved beyond an "inner list" containing class initializers. These weren't being checked for by the code. Also, fix places in c-get-fontification-context where point is undefined. * lisp/progmodes/cc-fonts.el (c-get-fontification-context): when argument not-front-decl is set, test for class initializers. Also, anchor point in places where it is moved and is otherwise undefined.
-rw-r--r--lisp/progmodes/cc-fonts.el13
1 files changed, 10 insertions, 3 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index e8552af8ed8..b35d33a5fd3 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1231,13 +1231,16 @@ casts and declarations are fontified. Used on level 2 and higher."
1231 ;; Got a cached hit in some other type of arglist. 1231 ;; Got a cached hit in some other type of arglist.
1232 (type 1232 (type
1233 (cons 'arglist t)) 1233 (cons 'arglist t))
1234 (not-front-decl 1234 ((and not-front-decl
1235 ;; The point is within the range of a previously 1235 ;; The point is within the range of a previously
1236 ;; encountered type decl expression, so the arglist 1236 ;; encountered type decl expression, so the arglist
1237 ;; is probably one that contains declarations. 1237 ;; is probably one that contains declarations.
1238 ;; However, if `c-recognize-paren-inits' is set it 1238 ;; However, if `c-recognize-paren-inits' is set it
1239 ;; might also be an initializer arglist. 1239 ;; might also be an initializer arglist.
1240 ;; 1240 (or (not c-recognize-paren-inits)
1241 (save-excursion
1242 (goto-char match-pos)
1243 (not (c-back-over-member-initializers)))))
1241 ;; The result of this check is cached with a char 1244 ;; The result of this check is cached with a char
1242 ;; property on the match token, so that we can look 1245 ;; property on the match token, so that we can look
1243 ;; it up again when refontifying single lines in a 1246 ;; it up again when refontifying single lines in a
@@ -1248,17 +1251,21 @@ casts and declarations are fontified. Used on level 2 and higher."
1248 ;; Got an open paren preceded by an arith operator. 1251 ;; Got an open paren preceded by an arith operator.
1249 ((and (eq (char-before match-pos) ?\() 1252 ((and (eq (char-before match-pos) ?\()
1250 (save-excursion 1253 (save-excursion
1254 (goto-char match-pos)
1251 (and (zerop (c-backward-token-2 2)) 1255 (and (zerop (c-backward-token-2 2))
1252 (looking-at c-arithmetic-op-regexp)))) 1256 (looking-at c-arithmetic-op-regexp))))
1253 (cons nil nil)) 1257 (cons nil nil))
1254 ;; In a C++ member initialization list. 1258 ;; In a C++ member initialization list.
1255 ((and (eq (char-before match-pos) ?,) 1259 ((and (eq (char-before match-pos) ?,)
1256 (c-major-mode-is 'c++-mode) 1260 (c-major-mode-is 'c++-mode)
1257 (save-excursion (c-back-over-member-initializers))) 1261 (save-excursion
1262 (goto-char match-pos)
1263 (c-back-over-member-initializers)))
1258 (c-put-char-property (1- match-pos) 'c-type 'c-not-decl) 1264 (c-put-char-property (1- match-pos) 'c-type 'c-not-decl)
1259 (cons 'not-decl nil)) 1265 (cons 'not-decl nil))
1260 ;; At start of a declaration inside a declaration paren. 1266 ;; At start of a declaration inside a declaration paren.
1261 ((save-excursion 1267 ((save-excursion
1268 (goto-char match-pos)
1262 (and (memq (char-before match-pos) '(?\( ?\,)) 1269 (and (memq (char-before match-pos) '(?\( ?\,))
1263 (c-go-up-list-backward match-pos) 1270 (c-go-up-list-backward match-pos)
1264 (eq (char-after) ?\() 1271 (eq (char-after) ?\()