branch: elpa/yaml-mode
commit bc66879a9a9c2e0789ce1decfa185925c1f60a3f
Author: Wilfred Hughes <[email protected]>
Commit: Wilfred Hughes <[email protected]>
Use the syntax table for highlighting comments.
Fixes https://github.com/yoshiki/yaml-mode/issues/19
---
yaml-mode.el | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/yaml-mode.el b/yaml-mode.el
index 33b059f..60b277b 100644
--- a/yaml-mode.el
+++ b/yaml-mode.el
@@ -120,9 +120,6 @@ that key is pressed to begin a block literal."
(defconst yaml-blank-line-re "^ *$"
"Regexp matching a line containing only (valid) whitespace.")
-(defconst yaml-comment-re "\\(?:^\\|\\s-+\\)\\(#.*\\)"
- "Regexp matching a line containing a YAML comment or delimiter.")
-
(defconst yaml-directive-re "^\\(?:--- \\)? *%\\(\\w+\\)"
"Regexp matching a line contatining a YAML directive.")
@@ -220,6 +217,7 @@ that key is pressed to begin a block literal."
"Simple mode to edit YAML.
\\{yaml-mode-map}"
+ :syntax-table yaml-mode-syntax-table
(set (make-local-variable 'comment-start) "# ")
(set (make-local-variable 'comment-start-skip) "#+ *")
(set (make-local-variable 'indent-line-function) 'yaml-indent-line)
@@ -227,26 +225,26 @@ that key is pressed to begin a block literal."
(set (make-local-variable 'font-lock-defaults)
'(yaml-font-lock-keywords
nil nil nil nil
- (font-lock-syntactic-keywords . yaml-font-lock-syntactic-keywords))))
+ (font-lock-syntactic-keywords . yaml-font-lock-syntactic-keywords)))
+ (font-lock-fontify-buffer))
;; Font-lock support
(defvar yaml-font-lock-keywords
(list
- (cons yaml-comment-re '(1 font-lock-comment-face))
(cons yaml-constant-scalars-re '(1 font-lock-constant-face))
(cons yaml-tag-re '(0 font-lock-type-face))
- (cons yaml-node-anchor-alias-re '(0 font-lock-function-name-face t))
- (cons yaml-hash-key-re '(1 font-lock-variable-name-face t))
+ (cons yaml-node-anchor-alias-re '(0 font-lock-function-name-face))
+ (cons yaml-hash-key-re '(1 font-lock-variable-name-face))
(cons yaml-document-delimiter-re '(0 font-lock-comment-face))
(cons yaml-directive-re '(1 font-lock-builtin-face))
- '(yaml-font-lock-block-literals 0 font-lock-string-face t)
+ '(yaml-font-lock-block-literals 0 font-lock-string-face)
'("^[\t]+" 0 'yaml-tab-face t))
"Additional expressions to highlight in YAML mode.")
(defvar yaml-font-lock-syntactic-keywords
- (list '(yaml-syntactic-block-literals 0 "." t))
+ (list '(yaml-syntactic-block-literals 0 "."))
"Additional syntax features to highlight in YAML mode.")