aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/cc-fonts.el
diff options
context:
space:
mode:
authorJoakim Verona2012-01-23 15:10:06 +0100
committerJoakim Verona2012-01-23 15:10:06 +0100
commit0322b140eead7c94de7f0f6d19a90bd15690b4eb (patch)
tree950c011783cc896d0450084cb5155e54548bfe5b /lisp/progmodes/cc-fonts.el
parentd5114bfea3ea4c37c57e2af0f3b095be9fcd8bac (diff)
parentcb5850f27c1b4d26957d58e2da2314dd12498671 (diff)
downloademacs-0322b140eead7c94de7f0f6d19a90bd15690b4eb.tar.gz
emacs-0322b140eead7c94de7f0f6d19a90bd15690b4eb.zip
upstream
Diffstat (limited to 'lisp/progmodes/cc-fonts.el')
-rw-r--r--lisp/progmodes/cc-fonts.el48
1 files changed, 43 insertions, 5 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index e7d00815708..2d116e1ecdc 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -446,10 +446,12 @@
446 ;; `parse-sexp-lookup-properties' (when it exists). 446 ;; `parse-sexp-lookup-properties' (when it exists).
447 (parse-sexp-lookup-properties 447 (parse-sexp-lookup-properties
448 (cc-eval-when-compile 448 (cc-eval-when-compile
449 (boundp 'parse-sexp-lookup-properties)))) 449 (boundp 'parse-sexp-lookup-properties)))
450 (BOD-limit
451 (c-determine-limit 1000)))
450 (goto-char 452 (goto-char
451 (let ((here (point))) 453 (let ((here (point)))
452 (if (eq (car (c-beginning-of-decl-1)) 'same) 454 (if (eq (car (c-beginning-of-decl-1 BOD-limit)) 'same)
453 (point) 455 (point)
454 here))) 456 here)))
455 ,(c-make-font-lock-search-form regexp highlights)) 457 ,(c-make-font-lock-search-form regexp highlights))
@@ -1240,6 +1242,7 @@ casts and declarations are fontified. Used on level 2 and higher."
1240 ;; it finds any. That's necessary so that we later will 1242 ;; it finds any. That's necessary so that we later will
1241 ;; stop inside them to fontify types there. 1243 ;; stop inside them to fontify types there.
1242 (c-parse-and-markup-<>-arglists t) 1244 (c-parse-and-markup-<>-arglists t)
1245 lbrace ; position of some {.
1243 ;; The font-lock package in Emacs is known to clobber 1246 ;; The font-lock package in Emacs is known to clobber
1244 ;; `parse-sexp-lookup-properties' (when it exists). 1247 ;; `parse-sexp-lookup-properties' (when it exists).
1245 (parse-sexp-lookup-properties 1248 (parse-sexp-lookup-properties
@@ -1351,7 +1354,6 @@ casts and declarations are fontified. Used on level 2 and higher."
1351 (or (looking-at c-typedef-key) 1354 (or (looking-at c-typedef-key)
1352 (goto-char start-pos))) 1355 (goto-char start-pos)))
1353 1356
1354 ;; Now analyze the construct.
1355 ;; In QT, "more" is an irritating keyword that expands to nothing. 1357 ;; In QT, "more" is an irritating keyword that expands to nothing.
1356 ;; We skip over it to prevent recognition of "more slots: <symbol>" 1358 ;; We skip over it to prevent recognition of "more slots: <symbol>"
1357 ;; as a bitfield declaration. 1359 ;; as a bitfield declaration.
@@ -1360,6 +1362,8 @@ casts and declarations are fontified. Used on level 2 and higher."
1360 (concat "\\(more\\)\\([^" c-symbol-chars "]\\|$\\)"))) 1362 (concat "\\(more\\)\\([^" c-symbol-chars "]\\|$\\)")))
1361 (goto-char (match-end 1)) 1363 (goto-char (match-end 1))
1362 (c-forward-syntactic-ws)) 1364 (c-forward-syntactic-ws))
1365
1366 ;; Now analyze the construct.
1363 (setq decl-or-cast (c-forward-decl-or-cast-1 1367 (setq decl-or-cast (c-forward-decl-or-cast-1
1364 match-pos context last-cast-end)) 1368 match-pos context last-cast-end))
1365 1369
@@ -1428,6 +1432,39 @@ casts and declarations are fontified. Used on level 2 and higher."
1428 (c-fontify-recorded-types-and-refs) 1432 (c-fontify-recorded-types-and-refs)
1429 nil) 1433 nil)
1430 1434
1435 ;; Restore point, since at this point in the code it has been
1436 ;; left undefined by c-forward-decl-or-cast-1 above.
1437 ((progn (goto-char start-pos) nil))
1438
1439 ;; If point is inside a bracelist, there's no point checking it
1440 ;; being at a declarator.
1441 ((let ((paren-state (c-parse-state)))
1442 (setq lbrace (c-cheap-inside-bracelist-p paren-state)))
1443 ;; Move past this bracelist to prevent an endless loop.
1444 (goto-char lbrace)
1445 (unless (c-safe (progn (forward-list) t))
1446 (goto-char start-pos)
1447 (c-forward-token-2))
1448 nil)
1449
1450 ;; If point is just after a ")" which is followed by an
1451 ;; identifier which isn't a label, or at the matching "(", we're
1452 ;; at either a macro invocation, a cast, or a
1453 ;; for/while/etc. statement. The cast case is handled above.
1454 ;; None of these cases can contain a declarator.
1455 ((or (and (eq (char-before match-pos) ?\))
1456 (c-on-identifier)
1457 (save-excursion (not (c-forward-label))))
1458 (and (eq (char-after) ?\()
1459 (save-excursion
1460 (and
1461 (progn (c-backward-token-2) (c-on-identifier))
1462 (save-excursion (not (c-forward-label)))
1463 (progn (c-backward-token-2)
1464 (eq (char-after) ?\())))))
1465 (c-forward-token-2) ; Must prevent looping.
1466 nil)
1467
1431 ((and (not c-enums-contain-decls) 1468 ((and (not c-enums-contain-decls)
1432 ;; An optimization quickly to eliminate scans of long enum 1469 ;; An optimization quickly to eliminate scans of long enum
1433 ;; declarations in the next cond arm. 1470 ;; declarations in the next cond arm.
@@ -1441,13 +1478,14 @@ casts and declarations are fontified. Used on level 2 and higher."
1441 (progn 1478 (progn
1442 (c-backward-token-2) 1479 (c-backward-token-2)
1443 (looking-at c-brace-list-key))))))) 1480 (looking-at c-brace-list-key)))))))
1444 t) 1481 (c-forward-token-2)
1482 nil)
1445 1483
1446 (t 1484 (t
1447 ;; Are we at a declarator? Try to go back to the declaration 1485 ;; Are we at a declarator? Try to go back to the declaration
1448 ;; to check this. If we get there, check whether a "typedef" 1486 ;; to check this. If we get there, check whether a "typedef"
1449 ;; is there, then fontify the declarators accordingly. 1487 ;; is there, then fontify the declarators accordingly.
1450 (let ((decl-search-lim (max (- (point) 50000) (point-min))) 1488 (let ((decl-search-lim (c-determine-limit 1000))
1451 paren-state bod-res encl-pos is-typedef 1489 paren-state bod-res encl-pos is-typedef
1452 c-recognize-knr-p) ; Strictly speaking, bogus, but it 1490 c-recognize-knr-p) ; Strictly speaking, bogus, but it
1453 ; speeds up lisp.h tremendously. 1491 ; speeds up lisp.h tremendously.