help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: changing precedence in font-lock-add-keywords


From: Robert Thorpe
Subject: Re: changing precedence in font-lock-add-keywords
Date: 23 Nov 2006 09:36:15 -0800
User-agent: G2/1.0

sandro.dentella wrote:
> Hi,
>
>   i'm trying to customize a mode for cheetah templating system, it is
> derived from html-mode and seems pretty simple:
>
> (define-derived-mode cheetah-mode html-mode "Cheetah"
>   (make-face 'cheetah-variable-face)
>   (font-lock-add-keywords
>    nil
>    '(
>      ("\\(#\\(end \\)?\\(include.*\\|block.*\\|import\\|load\\)\\)" 1
> font-lock-builtin-face)
>      ("\\(##.*\\)" 1 font-lock-comment-face)
>      ("\\(#\\*.*\\*#\\)" 1 font-lock-comment-face)
>      ("\\(#\\(from\\|else\\|set\\|import\\|for\\|if\\|end\\)+\\)\\>" 1
> font-lock-keyword-face)
>      ("\\(<%.*%>\\)" 1 font-lock-keyword-face)
> ;;
> ("\\(#\\(from\\|for\\|end\\)\\).*\\<\\(for\\|import\\|if\\|in\\)\\>" 3
> font-lock-keyword-face)
>      ("\\(\\$\\(?:\\sw\\|}\\|{\\|\\s_\\)+\\)" 1
> font-lock-variable-name-face)
>    ))
>   (font-lock-mode 1)
>   )
>
> what I'd like to optain is that the regexp defined here take precedence
> over those defined in html-mode. As an example the line with <% %> gets
> colored as it would in html but i'd like it to show as a keyword.
>
> Any hints?

See the awk-mode.el file in the Emacs distribution for an example of
how to do this.
It's in /lisp/progmodes.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]