emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master db0a3b2: Always mark "<" and ">" in #include direct


From: Alan Mackenzie
Subject: [Emacs-diffs] master db0a3b2: Always mark "<" and ">" in #include directives with text properties.
Date: Tue, 07 Apr 2015 11:04:21 +0000

branch: master
commit db0a3b2c974642d04e763db64fcb49ef3154f5a8
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    Always mark "<" and ">" in #include directives with text properties.
    
    * lisp/progmodes/c-fonts.el (c-cpp-matchers): Replace a font-lock "anchored
    matcher" with an invocation of c-make-font-lock-search-function to allow
    fontification when there's no trailing space on an "#include <..>" line.
---
 lisp/progmodes/cc-fonts.el |   45 ++++++++++++++++++++++---------------------
 1 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 9a1273d..44172b0 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -539,28 +539,29 @@ stuff.  Used on level 1 and higher."
                  (let* ((re (c-make-keywords-re nil
                               (c-lang-const c-cpp-include-directives)))
                         (re-depth (regexp-opt-depth re)))
-                   `((,(concat noncontinued-line-end
-                               (c-lang-const c-opt-cpp-prefix)
-                               re
-                               (c-lang-const c-syntactic-ws)
-                               "\\(<[^>\n\r]*>?\\)")
-                      (,(+ ncle-depth re-depth sws-depth 1)
-                       font-lock-string-face)
-
-                      ;; Use an anchored matcher to put paren syntax
-                      ;; on the brackets.
-                      (,(byte-compile
-                         `(lambda (limit)
-                            (let ((beg (match-beginning
-                                        ,(+ ncle-depth re-depth sws-depth 1)))
-                                  (end (1- (match-end ,(+ ncle-depth re-depth
-                                                          sws-depth 1)))))
-                              (if (eq (char-after end) ?>)
-                                  (progn
-                                    (c-mark-<-as-paren beg)
-                                    (c-mark->-as-paren end))
-                                (c-unmark-<->-as-paren beg)))
-                            nil)))))))
+                   ;; We used to use a font-lock "anchored matcher" here for
+                   ;; the paren syntax.  This failed when the ">" was at EOL,
+                   ;; since `font-lock-fontify-anchored-keywords' terminated
+                   ;; its loop at EOL without executing our lambda form at
+                   ;; all.
+                   `((,(c-make-font-lock-search-function
+                        (concat noncontinued-line-end
+                                (c-lang-const c-opt-cpp-prefix)
+                                re
+                                (c-lang-const c-syntactic-ws)
+                                "\\(<[^>\n\r]*>?\\)")
+                        `(,(+ ncle-depth re-depth sws-depth 1)
+                          font-lock-string-face t)
+                        `((let ((beg (match-beginning
+                                      ,(+ ncle-depth re-depth sws-depth 1)))
+                                (end (1- (match-end ,(+ ncle-depth re-depth
+                                                        sws-depth 1)))))
+                            (if (eq (char-after end) ?>)
+                                (progn
+                                  (c-mark-<-as-paren beg)
+                                  (c-mark->-as-paren end))
+                              (c-unmark-<->-as-paren beg)))
+                          nil))))))
 
              ;; #define.
              ,@(when (c-lang-const c-opt-cpp-macro-define)



reply via email to

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