branch: elpa/yaml-mode
commit 75c8f360995446541239cd3125b74d073880a3d5
Author: Vasilij Schneidermann <v.schneiderm...@gmail.com>
Commit: Vasilij Schneidermann <v.schneiderm...@gmail.com>

    Unhighlight foo#bar tokens
    
    Closes #26
---
 yaml-mode.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/yaml-mode.el b/yaml-mode.el
index 9cb8cfc..a04fc13 100644
--- a/yaml-mode.el
+++ b/yaml-mode.el
@@ -226,6 +226,9 @@ that key is pressed to begin a block literal."
        '(yaml-font-lock-keywords
          nil nil nil nil
          (font-lock-syntactic-keywords . yaml-font-lock-syntactic-keywords)))
+
+  (set (make-local-variable 'syntax-propertize-function)
+       'yaml-mode-syntax-propertize-function)
   (if (fboundp 'font-lock-flush)
       (font-lock-flush)
     (with-no-warnings
@@ -249,6 +252,18 @@ that key is pressed to begin a block literal."
   (list '(yaml-syntactic-block-literals 0 "."))
   "Additional syntax features to highlight in YAML mode.")
 
+(defun yaml-mode-syntax-propertize-function (beg end)
+  "Unhighlight foo#bar tokens between BEG and END."
+  (save-excursion
+    (goto-char beg)
+    (while (search-forward "#" end t)
+      (save-excursion
+        (forward-char -1)
+        ;; both ^# and [ \t]# are comments
+        (when (and (not (bolp))
+                   (not (memq (preceding-char) '(?\s ?\t))))
+          (put-text-property (point) (1+ (point))
+                             'syntax-table (string-to-syntax "_")))))))
 
 (defun yaml-font-lock-block-literals (bound)
   "Find lines within block literals.

Reply via email to