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

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

[elpa] externals/csharp-mode dbbd17a 312/459: Merge pull request #171 fr


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode dbbd17a 312/459: Merge pull request #171 from josteink/fontification-lighter
Date: Sun, 22 Aug 2021 13:59:51 -0400 (EDT)

branch: externals/csharp-mode
commit dbbd17ae11c6a08cbf9237b60a4ab01c73a9bded
Merge: a753601 f774b55
Author: Theodor Thornhill <theo@thornhill.no>
Commit: GitHub <noreply@github.com>

    Merge pull request #171 from josteink/fontification-lighter
    
    Make fontification a little less 'constant-heavy'
---
 csharp-mode-tests.el | 16 +++++++++---
 csharp-mode.el       | 72 +++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 78 insertions(+), 10 deletions(-)

diff --git a/csharp-mode-tests.el b/csharp-mode-tests.el
index 13c7238..f18cf02 100644
--- a/csharp-mode-tests.el
+++ b/csharp-mode-tests.el
@@ -90,6 +90,14 @@
    "var package = true;"
    "package" 'font-lock-variable-name-face))
 
+(ert-deftest fontification-of-functions ()
+  (require 'assess)
+  (assess-face-in-text= "var foo = bar.Baz()"
+                        "Baz" 'font-lock-function-name-face)
+  (assess-face-in-text= "var foo = bar.Baz<Quux>()"
+                        "Baz" 'font-lock-function-name-face
+                        "Quux" 'font-lock-type-face))
+
 (ert-deftest fontification-of-import ()
   (require 'assess)
   (assess-face-in-text=
@@ -162,9 +170,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 +181,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..3a106f7 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -53,12 +53,6 @@
   csharp (append '((?@ . "w"))
                 (c-lang-const c-identifier-syntax-modifications)))
 
-(c-lang-defconst c-basic-matchers-after
-  csharp (append nil
-     ;; cc-mode defaults
-     (c-lang-const c-basic-matchers-after)))
-
-
 (c-lang-defconst c-symbol-start
   csharp (concat "[" c-alpha "_@]"))
 
@@ -241,6 +235,72 @@
                                    (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))
+           ))
+
+(c-lang-defconst c-basic-matchers-after
+  csharp (append
+          ;; merge with cc-mode defaults
+          (c-lang-const c-basic-matchers-after)
+
+          ;; function names
+          `(("\\.\\([A-Za-z0-9_]+\\)[<(]" 1 font-lock-function-name-face t))
+          ))
+
 (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]