[Top][All Lists]

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

Re: custom colorizing keywords

From: Steve Wainstead
Subject: Re: custom colorizing keywords
Date: Mon, 13 Mar 2006 13:59:17 -0500
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv: Gecko/20060127 SeaMonkey/1.0

That will give you a permanent solution; but if you just want to highlight arbitrary words take a look at hi-lock-face-buffer. Immensely useful when tailing logs in shell-mode.


ken wrote:
Wishing to colorize some of my own keywords, I stumbled across
font-lock-add-keywords and did C-h f on it.  I'm not an elisp
programmer, so of course the explanations there made hardly any sense.
So I tried just altering the example:

 (font-lock-add-keywords 'c-mode
  '(("\\<\\(FIXME\\):" 1 font-lock-warning-face prepend)
    ("\\<\\(and\\|or\\|not\\)\\>" . font-lock-keyword-face)))

The help page says "MODE should be a symbol, the major mode command
name, such as `c-mode' or nil."  Because I want to highlight the added
keywords in all modes, I did this:

(font-lock-add-keywords nil
  '(("\\<\\(FIXME\\):" 1 font-lock-warning-face prepend)
    ("\\<\\(XXX\\|xxx\\|???\\)\\>" . font-lock-keyword-face)))

Evaluating this failed, told me "Fontifying region...(invalid-regexp
Invalid regular expression)".  I've read enough elisp code that I pretty
much knew that there shouldn't be an apostrophe (') in front of nil, but
I tried it anyway.  Got the same error message.

I tried a lot of other things, but this is the easiest yet most
perplexing of several questions.  Searching the archives and EmacsWiki
yeilded nothing helpful.  Is what I'm asking even possible to do?

Thanks for any assistance.

reply via email to

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