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

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

Re: font-lock-keywords and lines containing comments / quotes


From: despen
Subject: Re: font-lock-keywords and lines containing comments / quotes
Date: Fri, 26 Feb 2010 13:41:41 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

 On Thu, Feb 25, 2010 at 8:57 PM, Erik Iverson <eriki@ccbr.umn.edu> wrote:
> I am trying to learn things about font-lock-mode, and am needing help
> understanding the following behavior.  To see what I am confused about,
> create a buffer in emacs-lisp mode (or just use *scratch*) and define the
> following:
>
> ;; syntax highlight lines that start with a "*" in the current buffer
> (font-lock-add-keywords nil
>                        '(("^\\*\\{1\\}.*" . font-lock-keyword-face)))
>
>
> Now, with the above defined, paste (or type out to see the effect in action)
> the following lines starting with * in the same buffer, which will
> demonstrate what I would like to achieve, and what is going wrong...
>
>
> * this is highlighted, great!
> * so is this, until I type a ; comment
> * similiar here, until I type a "quote"
>
>
> As soon as I type the ; or " characters, the previous part of the line
> becomes "normal" and the comment or quote appears as it should.  I would
> like for the initial part of the line to remain highlighted though.
>
> Obviously I am missing something simple(?) here, but I am having a hard time
> figuring out how the typical major-modes (e.g., emacs-lisp) handle this
> case. Any hints?

Look at the description of font-lock-defaults.
When you set it, you want to set KEYWORDS-ONLY to t so that
syntax tables (strings and comments) are ignored.


reply via email to

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