[Top][All Lists]

[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: Johan Bockgård
Subject: Re: How to add syntax highlighting inside comments for an existing major mode
Date: Thu, 11 Oct 2007 13:49:13 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux)

Julien Barnier <address@hidden> writes:

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

(info "(elisp)Search-based Fontification")

       In this kind of element, SUBEXP-HIGHLIGHTER is a list which
       specifies how to highlight matches found by MATCHER.  It has the


       The CAR, SUBEXP, is an integer specifying which subexpression of
       the match to fontify (0 means the entire matching text).  The
       second subelement, FACESPEC, is an expression whose value
       specifies the face, as described above.

       The last two values in SUBEXP-HIGHLIGHTER, OVERRIDE and LAXMATCH,
       are optional flags.  If OVERRIDE is `t', this element can override
       existing fontification made by previous elements of
       `font-lock-keywords'.  If it is `keep', then each character is
       fontified if it has not been fontified already by some other
       element.  If it is `prepend', the face specified by FACESPEC is
       added to the beginning of the `font-lock-face' property.  If it is
       `append', the face is added to the end of the `font-lock-face'


       Here are some examples of elements of this kind, and what they do:

            ;; Highlight occurrences of either `foo' or `bar', using
            ;; `foo-bar-face', even if they have already been highlighted.
            ;; `foo-bar-face' should be a variable whose value is a face.
            ("foo\\|bar" 0 foo-bar-face t)

Johan Bockgård

reply via email to

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