cssemacscommentscheetah

In emacs how do I add a second type of commenting to a css derived mode?


I have a templating css file type that allows comments to start with '##' No matter what I try though It doesn't seem to recognize this in my derived-mode. Here is what i have so far

(define-derived-mode cheetah-css-mode css-mode "cheetah-css"
   (make-face 'cheetah-css-variable-face)
   (font-lock-add-keywords
    nil
    '(("\\(##.*\\)\n" font-lock-comment-face)) (font-lock-mode 1)))

Solution

  • What you actually want to do is modify the syntax table for your mode to identify ## as a comment. Then Emacs will be able to treat it as such in all respects (and not just highlighting).

    See:

    Try this in your derived mode definition:

    (modify-syntax-entry ?# "' 12b" cheetah-css-mode-syntax-table)
    (modify-syntax-entry ?\n "> b" cheetah-css-mode-syntax-table)