[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to add syntax highlighting inside comments for an existing major
From: |
martin rudalics |
Subject: |
Re: How to add syntax highlighting inside comments for an existing major mode |
Date: |
Thu, 11 Oct 2007 14:06:41 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
> I am trying to customize some syntax highlighting for an existing
> major mode. What I would like to do is to display different type of
> comments with different faces.
>
> In this mode, comments are lines that begins with one or several
> «#». What I would like to display differently those which begin with
> «#####» than those which begin with «####», etc.
>
> I tried the 'font-lock-add-keywords' way, but it doesn't seem to work
> inside comments, with something like that :
>
> (font-lock-add-keywords 'ess-mode
> '(("^##### .*$" . my-beautiful-face)))
>
> Do you have any idea for a proper way to do such a thing ?
Write your own `font-lock-syntactic-face-function' and do
(setq font-lock-defaults
'(...
(font-lock-syntactic-face-function
. my-font-lock-syntactic-face-function))))
(defun my-font-lock-syntactic-face-function (state)
(if (nth 3 state)
(...)
;; Here investigate STATE and decide which face to use.
))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: How to add syntax highlighting inside comments for an existing major mode,
martin rudalics <=