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

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

[elpa] externals/csharp-mode 5a7828f 298/459: Add xml like doc comments


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode 5a7828f 298/459: Add xml like doc comments font locking
Date: Sun, 22 Aug 2021 13:59:48 -0400 (EDT)

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

    Add xml like doc comments font locking
---
 csharp-mode.el | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/csharp-mode.el b/csharp-mode.el
index 4a04b32..1f0c010 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -518,6 +518,30 @@
        res))))
 ;;; End of monkey patch
 
+;;; Doc comments
+
+(defconst csharpxml-font-lock-doc-comments
+  ;; Most of this is taken from the javadoc example, however, we don't use the
+  ;; '@foo' syntax, so I removed that. Supports the XML tags only
+  `((,(concat "</?\\sw"                        ; XML tags.
+             "\\("
+             (concat "\\sw\\|\\s \\|[=\n\r*.:]\\|"
+                     "\"[^\"]*\"\\|'[^']*'")
+             "\\)*>")
+     0 ,c-doc-markup-face-name prepend nil)
+    ("&\\(\\sw\\|[.:]\\)+;"            ; XML entities.
+     0 ,c-doc-markup-face-name prepend nil)
+    (,(lambda (limit)
+       (c-find-invalid-doc-markup "[<>&]\\|{@" limit))
+     0 'font-lock-warning-face prepend nil)))
+
+(defconst csharpxml-font-lock-keywords
+  `((,(lambda (limit)
+       (c-font-lock-doc-comments "///" limit
+         csharpxml-font-lock-doc-comments)))))
+
+;;; End of doc comments
+
 (defvar csharp-mode-syntax-table
   (funcall (c-lang-const c-make-mode-syntax-table csharp))
   "Syntax table used in csharp-mode buffers.")
@@ -552,6 +576,7 @@ Key bindings:
   (c-common-init 'csharp-mode)
   (easy-menu-add csharp-menu)
   (c-set-style "csharp")
+  (setq-local c-doc-comment-style '((csharp-mode . csharpxml)))
   (c-run-mode-hooks 'c-mode-common-hook 'csharp-mode-hook))
 
 (provide 'csharp-mode)



reply via email to

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