]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix C++ class initializers not always being fontified at mode start.
authorAlan Mackenzie <acm@muc.de>
Thu, 27 Jul 2017 17:56:23 +0000 (17:56 +0000)
committerAlan Mackenzie <acm@muc.de>
Thu, 27 Jul 2017 17:56:23 +0000 (17:56 +0000)
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.

lisp/progmodes/cc-fonts.el

index e8552af8ed8c339f2eed3c894c503e487bc74f6e..b35d33a5fd3e4ad9f5b357c9d3ddbad80a0bfa00 100644 (file)
@@ -1231,13 +1231,16 @@ casts and declarations are fontified.  Used on level 2 and higher."
          ;; Got a cached hit in some other type of arglist.
          (type
           (cons 'arglist t))
-         (not-front-decl
+         ((and not-front-decl
           ;; The point is within the range of a previously
           ;; encountered type decl expression, so the arglist
           ;; is probably one that contains declarations.
           ;; However, if `c-recognize-paren-inits' is set it
           ;; might also be an initializer arglist.
-          ;;
+               (or (not c-recognize-paren-inits)
+                   (save-excursion
+                     (goto-char match-pos)
+                     (not (c-back-over-member-initializers)))))
           ;; The result of this check is cached with a char
           ;; property on the match token, so that we can look
           ;; it up again when refontifying single lines in a
@@ -1248,17 +1251,21 @@ casts and declarations are fontified.  Used on level 2 and higher."
          ;; Got an open paren preceded by an arith operator.
          ((and (eq (char-before match-pos) ?\()
                (save-excursion
+                 (goto-char match-pos)
                  (and (zerop (c-backward-token-2 2))
                       (looking-at c-arithmetic-op-regexp))))
           (cons nil nil))
          ;; In a C++ member initialization list.
          ((and (eq (char-before match-pos) ?,)
                (c-major-mode-is 'c++-mode)
-               (save-excursion (c-back-over-member-initializers)))
+               (save-excursion
+                 (goto-char match-pos)
+                 (c-back-over-member-initializers)))
           (c-put-char-property (1- match-pos) 'c-type 'c-not-decl)
           (cons 'not-decl nil))
          ;; At start of a declaration inside a declaration paren.
          ((save-excursion
+            (goto-char match-pos)
             (and (memq (char-before match-pos) '(?\( ?\,))
                  (c-go-up-list-backward match-pos)
                  (eq (char-after) ?\()