branch: elpa/zig-mode commit c5315ff33668d1f545c83242f81e0a6a2f5c7959 Author: Matthew D. Steele <mdste...@alum.mit.edu> Commit: Matthew D. Steele <mdste...@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 <andreaorru1...@gmail.com>, Andrew Kelley <superjo...@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))