emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/csharp-mode b85033a 309/459: Make fontification a littl


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode b85033a 309/459: Make fontification a little less 'constant-heavy'
Date: Sun, 22 Aug 2021 13:59:50 -0400 (EDT)

branch: externals/csharp-mode
commit b85033a1b54f1f558ab382a07f5ebceb16fe6172
Author: Theodor Thornhill <theo@thornhill.no>
Commit: Theodor Thornhill <theo@thornhill.no>

    Make fontification a little less 'constant-heavy'
---
 csharp-mode-tests.el |  8 ++++----
 csharp-mode.el       | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/csharp-mode-tests.el b/csharp-mode-tests.el
index 13c7238..865d277 100644
--- a/csharp-mode-tests.el
+++ b/csharp-mode-tests.el
@@ -162,9 +162,9 @@
                         "using" 'font-lock-keyword-face
                         "Reference" 'font-lock-type-face
                         "Under_scored" 'font-lock-type-face
-                        "WithNumbers09" 'font-lock-constant-face
+                        "WithNumbers09" 'font-lock-variable-name-face
                         "Ok" 'font-lock-type-face
-                        "WithNumbers09" 'font-lock-constant-face
+                        "WithNumbers09" 'font-lock-variable-name-face
                         "OkV2" 'font-lock-type-face
                         ))
 
@@ -173,9 +173,9 @@
                         "namespace" 'font-lock-keyword-face
                         "Reference" 'font-lock-type-face
                         "Under_scored" 'font-lock-type-face
-                        "WithNumbers09" 'font-lock-constant-face
+                        "WithNumbers09" 'font-lock-variable-name-face
                         "Ok" 'font-lock-type-face
-                        "WithNumbers09" 'font-lock-constant-face
+                        "WithNumbers09" 'font-lock-variable-name-face
                         "Ok" 'font-lock-type-face
                         ))
 
diff --git a/csharp-mode.el b/csharp-mode.el
index a640ee9..2cd428f 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -241,6 +241,63 @@
                                    (cpp-macro             . 
c-lineup-dont-change)
                                    (substatement-open     . 0)))))
 
+(c-lang-defconst c-basic-matchers-before
+  "Font lock matchers for basic keywords, labels, references and various
+other easily recognizable things that should be fontified before generic
+casts and declarations are fontified.  Used on level 2 and higher."
+  csharp `(
+           ;; Put warning face on unclosed strings
+           ,@(if (version< emacs-version "27.0")
+                 ;; Taken from 26.1 branch
+                 `(,(c-make-font-lock-search-function
+                    (concat ".\\(" c-string-limit-regexp "\\)")
+                    '((c-font-lock-invalid-string))))
+               `(("\\s|" 0 font-lock-warning-face t nil)))
+
+           ;; Invalid single quotes
+           c-font-lock-invalid-single-quotes
+
+           ;; Fontify keyword constants
+           ,@(when (c-lang-const c-constant-kwds)
+              (let ((re (c-make-keywords-re nil (c-lang-const 
c-constant-kwds))))
+                `((eval . (list ,(concat "\\<\\(" re "\\)\\>")
+                                1 c-constant-face-name)))))
+
+           ;; Fontify all keywords except the primitive types.
+           ,`(,(concat "\\<" (c-lang-const c-regular-keywords-regexp))
+             1 font-lock-keyword-face)
+
+           ,@(when (c-lang-const c-opt-identifier-concat-key)
+              `(,(c-make-font-lock-search-function
+                  ;; Search for identifiers preceded by ".".  The anchored
+                  ;; matcher takes it from there.
+                  (concat (c-lang-const c-opt-identifier-concat-key)
+                          (c-lang-const c-simple-ws) "*"
+                          (concat "\\("
+                                  ;; "[" c-upper "]"
+                                  "[" (c-lang-const c-symbol-chars) "]*"
+                                  "\\|"
+                                  "\\)"))
+                  `((let (id-end)
+                      (goto-char (1+ (match-beginning 0)))
+                      (while (and (eq (char-before) ?.)
+                                  (progn
+                                    (backward-char)
+                                    (c-backward-syntactic-ws)
+                                    (setq id-end (point))
+                                    (< (skip-chars-backward
+                                        ,(c-lang-const c-symbol-chars))
+                                       0))
+                                  (not (get-text-property (point) 'face)))
+                        (c-put-font-lock-face (point) id-end
+                                              font-lock-variable-name-face)
+                        (c-backward-syntactic-ws)))
+                    nil
+                    (goto-char (match-end 0))))))
+
+           (eval . (list "\\(!\\)[^=]" 1 c-negation-char-face-name))
+           ))
+
 (defcustom csharp-font-lock-extra-types
   (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw"))
   (c-make-font-lock-extra-types-blurb "C#" "csharp-mode" (concat))



reply via email to

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