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

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

[nongnu] elpa/zig-mode c5315ff 026/104: Apply font-lock-doc-face to doc


From: ELPA Syncer
Subject: [nongnu] elpa/zig-mode c5315ff 026/104: Apply font-lock-doc-face to doc comments (for issue #5)
Date: Sun, 29 Aug 2021 11:36:56 -0400 (EDT)

branch: elpa/zig-mode
commit c5315ff33668d1f545c83242f81e0a6a2f5c7959
Author: Matthew D. Steele <mdsteele@alum.mit.edu>
Commit: Matthew D. Steele <mdsteele@alum.mit.edu>

    Apply font-lock-doc-face to doc comments (for issue #5)
---
 zig-mode.el | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/zig-mode.el b/zig-mode.el
index eeb012c..221a3a4 100644
--- a/zig-mode.el
+++ b/zig-mode.el
@@ -1,6 +1,6 @@
 ;;; zig-mode.el --- A major mode for the Zig programming language -*- 
lexical-binding: t -*-
 
-;; Version: 0.0.5
+;; Version: 0.0.6
 ;; Author: Andrea Orru <andreaorru1991@gmail.com>, Andrew Kelley 
<superjoe30@gmail.com>
 ;; Keywords: zig, languages
 ;; Package-Requires: ((emacs "24"))
@@ -163,6 +163,14 @@
          (zig-syntax-propertize-newline-if-in-multiline-str end)))))
    (point) end))
 
+(defun zig-mode-syntactic-face-function (state)
+  (if (nth 3 state) 'font-lock-string-face
+    (save-excursion
+      (goto-char (nth 8 state))
+      (if (looking-at "///[^/]")
+          'font-lock-doc-face
+        'font-lock-comment-face))))
+
 ;;;###autoload
 (define-derived-mode zig-mode c-mode "Zig"
   "A major mode for the zig programming language."
@@ -171,7 +179,10 @@
   (setq-local comment-start "// ")
   (setq-local comment-end "")
   (setq-local syntax-propertize-function 'zig-syntax-propertize)
-  (setq font-lock-defaults '(zig-font-lock-keywords)))
+  (setq font-lock-defaults '(zig-font-lock-keywords
+                             nil nil nil nil
+                             (font-lock-syntactic-face-function
+                              . zig-mode-syntactic-face-function))))
 
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.zig\\'" . zig-mode))



reply via email to

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