1

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)))
telaviv
  • 406
  • 1
  • 7
  • 14

1 Answers1

2

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:

  • M-: (info "(elisp) Syntax Descriptors") RET
  • M-: (info "(elisp) Syntax Flags") RET
  • M-: (info "(elisp) Syntax Class Table") RET

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)
phils
  • 71,335
  • 11
  • 153
  • 198