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

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

[elpa] externals/csharp-mode 7fa38d2 170/459: Extend syntax propertize f


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode 7fa38d2 170/459: Extend syntax propertize function for vliterals
Date: Sun, 22 Aug 2021 13:59:20 -0400 (EDT)

branch: externals/csharp-mode
commit 7fa38d2ac265672d82613e6a508fc5baa4a0f8e3
Author: Vasilij Schneidermann <v.schneidermann@gmail.com>
Commit: Vasilij Schneidermann <v.schneidermann@gmail.com>

    Extend syntax propertize function for vliterals
---
 csharp-mode.el | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/csharp-mode.el b/csharp-mode.el
index 60d431b..7f73889 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -1145,10 +1145,42 @@ a square parentasis block [ ... ]."
 
            ))
 
+;; verbatim string literals can be multiline
+(c-lang-defconst c-multiline-string-start-char
+  csharp ?@)
+
 (defun csharp-mode-syntax-propertize-function (beg end)
-  "Highlight text after #region or #pragma as comment."
+  "Apply syntax table properties to special constructs.
+Currently handled:
+
+- Fontify verbatim literal strings correctly
+- Highlight text after #region or #pragma as comment"
   (save-excursion
     (goto-char beg)
+    (while (search-forward "@\"" end t)
+      (let ((in-comment-or-string-p (save-excursion
+                                      (goto-char (match-beginning 0))
+                                      (or (nth 3 (syntax-ppss))
+                                          (nth 4 (syntax-ppss))))))
+        (when (not in-comment-or-string-p)
+          (let (done)
+            (while (and (not done) (< (point) end))
+              (skip-chars-forward "^\"\\\\" end)
+              (cond
+               ((= (following-char) ?\\)
+                (put-text-property (point) (1+ (point))
+                                   'syntax-table (string-to-syntax "."))
+                (forward-char 1))
+               ((= (following-char) ?\")
+                (forward-char 1)
+                (if (= (following-char) ?\")
+                    (progn
+                      (put-text-property (1- (point)) (point)
+                                         'syntax-table (string-to-syntax "/"))
+                      (forward-char 1))
+                  (setq done t)))))))))
+
+    (goto-char beg)
     (while (re-search-forward "^\\s-*#\\(region\\|pragma\\) " end t)
       (when (looking-at "\\w")
         (put-text-property (point) (1+ (point))



reply via email to

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