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

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

[elpa] externals/csharp-mode 5e47b77 260/459: Fix error handling multili


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode 5e47b77 260/459: Fix error handling multiline compiler-directives.
Date: Sun, 22 Aug 2021 13:59:40 -0400 (EDT)

branch: externals/csharp-mode
commit 5e47b7764b3f4c97c260a902e8072d444dbd0f1b
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>

    Fix error handling multiline compiler-directives.
    
    Caused by changes upstream in cc-mode.
    Fix by copying removed functions locally.
---
 csharp-mode.el | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/csharp-mode.el b/csharp-mode.el
index d039313..feaf68b 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -756,8 +756,9 @@ to work properly with code that includes attributes."
              ;; Match a char before the string starter to make
              ;; `c-skip-comments-and-strings' work correctly.
              (concat ".\\(" c-string-limit-regexp "\\)")
-             '((when (fboundp 'c-font-lock-invalid-string)
-                 (c-font-lock-invalid-string))))
+             '((if (fboundp 'c-font-lock-invalid-string)
+                   (c-font-lock-invalid-string)
+                 (csharp-mode-font-lock-invalid-string))))
 
 
            ;; Fontify keyword constants.
@@ -2471,6 +2472,36 @@ are the string substitutions (see `format')."
 ;; these defuns.
 ;;
 
+;; verabatim copy of c-font-lock-invalid-string before it was removed
+;; from emacs/cc-mode in Git commit bb591f139f0602af292c772f974dcc14dabb1deb.
+
+(defun csharp-mode-font-lock-invalid-string ()
+  ;; Assuming the point is after the opening character of a string,
+  ;; fontify that char with `font-lock-warning-face' if the string
+  ;; decidedly isn't terminated properly.
+  ;;
+  ;; This function does hidden buffer changes.
+  (let ((start (1- (point))))
+    (save-excursion
+      (and (eq (elt (parse-partial-sexp start (c-point 'eol)) 8) start)
+          (if (if (eval-when-compile (integerp ?c))
+                  ;; Emacs
+                  (integerp c-multiline-string-start-char)
+                ;; XEmacs
+                (characterp c-multiline-string-start-char))
+              ;; There's no multiline string start char before the
+              ;; string, so newlines aren't allowed.
+              (not (eq (char-before start) c-multiline-string-start-char))
+            ;; Multiline strings are allowed anywhere if
+            ;; c-multiline-string-start-char is t.
+            (not c-multiline-string-start-char))
+          (if c-string-escaped-newlines
+              ;; There's no \ before the newline.
+              (not (eq (char-before (point)) ?\\))
+            ;; Escaped newlines aren't supported.
+            t)
+          (c-put-font-lock-face start (1+ start) 'font-lock-warning-face)))))
+
 (defun c-looking-at-inexpr-block (lim containing-sexp &optional check-at-end)
   ;; Return non-nil if we're looking at the beginning of a block
   ;; inside an expression.  The value returned is actually a cons of



reply via email to

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