unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* changing precedence in font-lock-add-keywords
@ 2006-11-22 14:36 sandro.dentella
  2006-11-23 17:36 ` Robert Thorpe
  2006-11-24 21:22 ` Dieter Wilhelm
  0 siblings, 2 replies; 3+ messages in thread
From: sandro.dentella @ 2006-11-22 14:36 UTC (permalink / raw)


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?

TIA
sandro
*:-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: changing precedence in font-lock-add-keywords
  2006-11-22 14:36 changing precedence in font-lock-add-keywords sandro.dentella
@ 2006-11-23 17:36 ` Robert Thorpe
  2006-11-24 21:22 ` Dieter Wilhelm
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Thorpe @ 2006-11-23 17:36 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: changing precedence in font-lock-add-keywords
  2006-11-22 14:36 changing precedence in font-lock-add-keywords sandro.dentella
  2006-11-23 17:36 ` Robert Thorpe
@ 2006-11-24 21:22 ` Dieter Wilhelm
  1 sibling, 0 replies; 3+ messages in thread
From: Dieter Wilhelm @ 2006-11-24 21:22 UTC (permalink / raw)
  Cc: help-gnu-emacs

"sandro.dentella" <sandro@e-den.it> writes:

> 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.

I think

    ("\\(<%.*%>\\)" 1 font-lock-keyword-face append)

should do the trick already.    

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-24 21:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-22 14:36 changing precedence in font-lock-add-keywords sandro.dentella
2006-11-23 17:36 ` Robert Thorpe
2006-11-24 21:22 ` Dieter Wilhelm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).