diff options
| author | Alan Mackenzie | 2010-10-30 12:24:06 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2010-10-30 12:24:06 +0000 |
| commit | 4f9e41e40c91d20a681c0b987d4e514eb917f6c7 (patch) | |
| tree | c98d6c876728b8c224bd6e25c73c022599d66f33 | |
| parent | 99e65b2d2e79edf3ed0c4f00916098d4ea3767f4 (diff) | |
| download | emacs-4f9e41e40c91d20a681c0b987d4e514eb917f6c7.tar.gz emacs-4f9e41e40c91d20a681c0b987d4e514eb917f6c7.zip | |
progmodes/cc-fonts.el (c-font-lock-enum-tail): New function which
fontifies the tail of an enum.
(c-basic-matchers-after): Insert a call to the above new function.
This fixes bug #7264.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 46 |
2 files changed, 50 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5344909c3a5..f4cb5eee9fd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2010-10-30 Alan Mackenzie <acm@muc.de> | ||
| 2 | |||
| 3 | * progmodes/cc-fonts.el (c-font-lock-enum-tail): New function | ||
| 4 | which fontifies the tail of an enum. | ||
| 5 | (c-basic-matchers-after): Insert a call to the above new function. | ||
| 6 | This fixes bug #7264. | ||
| 7 | |||
| 1 | 2010-10-30 Glenn Morris <rgm@gnu.org> | 8 | 2010-10-30 Glenn Morris <rgm@gnu.org> |
| 2 | 9 | ||
| 3 | * cus-start.el: Add :set properties for minor modes menu-bar-mode, | 10 | * cus-start.el: Add :set properties for minor modes menu-bar-mode, |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index 39501f7f9bc..d2e5657d34a 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -1048,6 +1048,9 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1048 | ;; Start of containing declaration (if any); limit for searching | 1048 | ;; Start of containing declaration (if any); limit for searching |
| 1049 | ;; backwards for it. | 1049 | ;; backwards for it. |
| 1050 | decl-start decl-search-lim | 1050 | decl-start decl-search-lim |
| 1051 | ;; Start of containing declaration (if any); limit for searching | ||
| 1052 | ;; backwards for it. | ||
| 1053 | decl-start decl-search-lim | ||
| 1051 | ;; The result from `c-forward-decl-or-cast-1'. | 1054 | ;; The result from `c-forward-decl-or-cast-1'. |
| 1052 | decl-or-cast | 1055 | decl-or-cast |
| 1053 | ;; The maximum of the end positions of all the checked type | 1056 | ;; The maximum of the end positions of all the checked type |
| @@ -1318,6 +1321,40 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1318 | 1321 | ||
| 1319 | nil))) | 1322 | nil))) |
| 1320 | 1323 | ||
| 1324 | (defun c-font-lock-enum-tail (limit) | ||
| 1325 | ;; Fontify an enum's identifiers when POINT is within the enum's brace | ||
| 1326 | ;; block. | ||
| 1327 | ;; | ||
| 1328 | ;; This function will be called from font-lock for a region bounded by POINT | ||
| 1329 | ;; and LIMIT, as though it were to identify a keyword for | ||
| 1330 | ;; font-lock-keyword-face. It always returns NIL to inhibit this and | ||
| 1331 | ;; prevent a repeat invocation. See elisp/lispref page "Search-based | ||
| 1332 | ;; Fontification". | ||
| 1333 | ;; | ||
| 1334 | ;; Note that this function won't attempt to fontify beyond the end of the | ||
| 1335 | ;; current enum block, if any. | ||
| 1336 | (let* ((paren-state (c-parse-state)) | ||
| 1337 | (encl-pos (c-most-enclosing-brace paren-state)) | ||
| 1338 | (start (point)) | ||
| 1339 | ) | ||
| 1340 | (when (and | ||
| 1341 | encl-pos | ||
| 1342 | (eq (char-after encl-pos) ?\{) | ||
| 1343 | (save-excursion | ||
| 1344 | (goto-char encl-pos) | ||
| 1345 | (c-backward-syntactic-ws) | ||
| 1346 | (c-simple-skip-symbol-backward) | ||
| 1347 | (or (looking-at c-brace-list-key) ; "enum" | ||
| 1348 | (progn (c-backward-syntactic-ws) | ||
| 1349 | (c-simple-skip-symbol-backward) | ||
| 1350 | (looking-at c-brace-list-key))))) | ||
| 1351 | (c-syntactic-skip-backward "^{," nil t) | ||
| 1352 | (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start) | ||
| 1353 | |||
| 1354 | (c-forward-syntactic-ws) | ||
| 1355 | (c-font-lock-declarators limit t nil))) | ||
| 1356 | nil) | ||
| 1357 | |||
| 1321 | (c-lang-defconst c-simple-decl-matchers | 1358 | (c-lang-defconst c-simple-decl-matchers |
| 1322 | "Simple font lock matchers for types and declarations. These are used | 1359 | "Simple font lock matchers for types and declarations. These are used |
| 1323 | on level 2 only and so aren't combined with `c-complex-decl-matchers'." | 1360 | on level 2 only and so aren't combined with `c-complex-decl-matchers'." |
| @@ -1582,11 +1619,14 @@ on level 2 only and so aren't combined with `c-complex-decl-matchers'." | |||
| 1582 | generic casts and declarations are fontified. Used on level 2 and | 1619 | generic casts and declarations are fontified. Used on level 2 and |
| 1583 | higher." | 1620 | higher." |
| 1584 | 1621 | ||
| 1585 | t `(;; Fontify the identifiers inside enum lists. (The enum type | 1622 | t `(,@(when (c-lang-const c-brace-id-list-kwds) |
| 1623 | ;; Fontify the remaining identifiers inside an enum list when we start | ||
| 1624 | ;; inside it. | ||
| 1625 | `(c-font-lock-enum-tail | ||
| 1626 | ;; Fontify the identifiers inside enum lists. (The enum type | ||
| 1586 | ;; name is handled by `c-simple-decl-matchers' or | 1627 | ;; name is handled by `c-simple-decl-matchers' or |
| 1587 | ;; `c-complex-decl-matchers' below. | 1628 | ;; `c-complex-decl-matchers' below. |
| 1588 | ,@(when (c-lang-const c-brace-id-list-kwds) | 1629 | (,(c-make-font-lock-search-function |
| 1589 | `((,(c-make-font-lock-search-function | ||
| 1590 | (concat | 1630 | (concat |
| 1591 | "\\<\\(" | 1631 | "\\<\\(" |
| 1592 | (c-make-keywords-re nil (c-lang-const c-brace-id-list-kwds)) | 1632 | (c-make-keywords-re nil (c-lang-const c-brace-id-list-kwds)) |