summaryrefslogtreecommitdiff
path: root/rust-mode.el
diff options
context:
space:
mode:
authorFelix S Klock II <pnkfelix@pnkfx.org>2015-07-05 22:05:52 +0200
committerFelix S Klock II <pnkfelix@pnkfx.org>2015-07-05 22:05:52 +0200
commitf1b6007ab5c9acb5c2b07452f5f38caf85ec537f (patch)
treebadcc33e14f05db603a99f05751b5c1550e9bccf /rust-mode.el
parent5ed467549abe81415241b0ea45e2ae87584b588c (diff)
parentd1ed01519655b6b262d6d21cdfb29f166b697eb3 (diff)
downloadrust-mode-f1b6007ab5c9acb5c2b07452f5f38caf85ec537f.tar.gz
Merge pull request #71 from birkenfeld/doc-comments
Distinguish face for doc-comments
Diffstat (limited to 'rust-mode.el')
-rw-r--r--rust-mode.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/rust-mode.el b/rust-mode.el
index c45d5c1..7fcc09e 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -480,6 +480,16 @@
;; Handle raw strings:
`((rust-look-for-raw-string (1 "|") (4 "_" nil t) (5 "|" nil t) (6 "|" nil t)))))
+(defun rust-mode-syntactic-face-function (state)
+ "Syntactic face function to distinguish doc comments from other comments."
+ (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
+ ))))
+
(defun rust-fill-prefix-for-comment-start (line-start)
"Determine what to use for `fill-prefix' based on what is at the beginning of a line."
(let ((result
@@ -740,7 +750,11 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
;; Fonts
(add-to-list 'font-lock-extend-region-functions 'rust-extend-region-raw-string)
- (setq-local font-lock-defaults '(rust-mode-font-lock-keywords nil nil nil nil (font-lock-syntactic-keywords . rust-mode-font-lock-syntactic-keywords)))
+ (setq-local font-lock-defaults '(rust-mode-font-lock-keywords
+ nil nil nil nil
+ (font-lock-syntactic-keywords . rust-mode-font-lock-syntactic-keywords)
+ (font-lock-syntactic-face-function . rust-mode-syntactic-face-function)
+ ))
;; Misc
(setq-local comment-start "// ")