emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r102156: progmodes/cc-fonts.el (c-fon


From: Alan Mackenzie
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102156: progmodes/cc-fonts.el (c-font-lock-enum-tail): New function which
Date: Sat, 30 Oct 2010 12:24:06 +0000
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102156
committer: Alan Mackenzie <address@hidden>
branch nick: trunk
timestamp: Sat 2010-10-30 12:24:06 +0000
message:
  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.
modified:
  lisp/ChangeLog
  lisp/progmodes/cc-fonts.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-10-30 02:27:44 +0000
+++ b/lisp/ChangeLog    2010-10-30 12:24:06 +0000
@@ -1,3 +1,10 @@
+2010-10-30  Alan Mackenzie  <address@hidden>
+
+       * 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.
+
 2010-10-30  Glenn Morris  <address@hidden>
 
        * cus-start.el: Add :set properties for minor modes menu-bar-mode,

=== modified file 'lisp/progmodes/cc-fonts.el'
--- a/lisp/progmodes/cc-fonts.el        2010-10-24 15:27:37 +0000
+++ b/lisp/progmodes/cc-fonts.el        2010-10-30 12:24:06 +0000
@@ -1048,6 +1048,9 @@
          ;; Start of containing declaration (if any); limit for searching
          ;; backwards for it.
          decl-start decl-search-lim
+         ;; Start of containing declaration (if any); limit for searching
+         ;; backwards for it.
+         decl-start decl-search-lim
          ;; The result from `c-forward-decl-or-cast-1'.
          decl-or-cast
          ;; The maximum of the end positions of all the checked type
@@ -1318,6 +1321,40 @@
 
       nil)))
 
+(defun c-font-lock-enum-tail (limit)
+  ;; Fontify an enum's identifiers when POINT is within the enum's brace
+  ;; block.
+  ;;
+  ;; This function will be called from font-lock for a region bounded by POINT
+  ;; and LIMIT, as though it were to identify a keyword for
+  ;; font-lock-keyword-face.  It always returns NIL to inhibit this and
+  ;; prevent a repeat invocation.  See elisp/lispref page "Search-based
+  ;; Fontification".
+  ;;
+  ;; Note that this function won't attempt to fontify beyond the end of the
+  ;; current enum block, if any.
+  (let* ((paren-state (c-parse-state))
+        (encl-pos (c-most-enclosing-brace paren-state))
+        (start (point))
+       )
+    (when (and
+          encl-pos
+          (eq (char-after encl-pos) ?\{)
+          (save-excursion
+            (goto-char encl-pos)
+            (c-backward-syntactic-ws)
+            (c-simple-skip-symbol-backward)
+            (or (looking-at c-brace-list-key) ; "enum"
+                (progn (c-backward-syntactic-ws)
+                       (c-simple-skip-symbol-backward)
+                       (looking-at c-brace-list-key)))))
+      (c-syntactic-skip-backward "^{," nil t)
+      (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start)
+
+      (c-forward-syntactic-ws)
+      (c-font-lock-declarators limit t nil)))
+  nil)
+
 (c-lang-defconst c-simple-decl-matchers
   "Simple font lock matchers for types and declarations.  These are used
 on level 2 only and so aren't combined with `c-complex-decl-matchers'."
@@ -1582,11 +1619,14 @@
 generic casts and declarations are fontified.  Used on level 2 and
 higher."
 
-  t `(;; Fontify the identifiers inside enum lists.  (The enum type
+  t `(,@(when (c-lang-const c-brace-id-list-kwds)
+      ;; Fontify the remaining identifiers inside an enum list when we start
+      ;; inside it.
+         `(c-font-lock-enum-tail
+      ;; Fontify the identifiers inside enum lists.  (The enum type
       ;; name is handled by `c-simple-decl-matchers' or
       ;; `c-complex-decl-matchers' below.
-      ,@(when (c-lang-const c-brace-id-list-kwds)
-         `((,(c-make-font-lock-search-function
+           (,(c-make-font-lock-search-function
               (concat
                "\\<\\("
                (c-make-keywords-re nil (c-lang-const c-brace-id-list-kwds))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]