unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* custom colorizing keywords
@ 2006-03-12 13:29 ken
  0 siblings, 0 replies; 5+ messages in thread
From: ken @ 2006-03-12 13:29 UTC (permalink / raw)



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.

-- 
"This world ain't big enough for the both of us,"
said the big noema to the little noema.

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

* Re: custom colorizing keywords
       [not found] <mailman.4.1142170197.32310.help-gnu-emacs@gnu.org>
@ 2006-03-12 13:51 ` Stefan Monnier
  2006-03-13 18:59 ` Steve Wainstead
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2006-03-12 13:51 UTC (permalink / raw)


> 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

"nil" means "current buffer", not "all buffers".


        Stefan

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

* Re: custom colorizing keywords
       [not found] <mailman.4.1142170197.32310.help-gnu-emacs@gnu.org>
  2006-03-12 13:51 ` custom colorizing keywords Stefan Monnier
@ 2006-03-13 18:59 ` Steve Wainstead
  2006-03-15 18:41   ` ken
  1 sibling, 1 reply; 5+ messages in thread
From: Steve Wainstead @ 2006-03-13 18:59 UTC (permalink / raw)



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.

~swain

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

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

* Re: custom colorizing keywords
       [not found] <44166427.6040005@gmx.at>
@ 2006-03-15 14:18 ` ken
  0 siblings, 0 replies; 5+ messages in thread
From: ken @ 2006-03-15 14:18 UTC (permalink / raw)


martin rudalics wrote:
>>    ("\\<\\(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
> 
> Question marks in regular expressions are special.  Try, as an example,
> 
>     ("\\<\\(XXX\\|xxx\\|YYY\\)\\>" . font-lock-keyword-face)))
> 
> here.

I got the same error message either way.


-- 
"This world ain't big enough for the both of us,"
said the big noema to the little noema.

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

* Re: custom colorizing keywords
  2006-03-13 18:59 ` Steve Wainstead
@ 2006-03-15 18:41   ` ken
  0 siblings, 0 replies; 5+ messages in thread
From: ken @ 2006-03-15 18:41 UTC (permalink / raw)
  Cc: help-gnu-emacs

Steve Wainstead wrote:
> 
> 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.
> 
> ~swain

I can see how hi-lock-face-buffer could be very useful in given
situations.  But from what the help on this function tells me, I gather
that it's an interactive function.

I was looking for something which would colorize the specified strings
in any and all buffers visited.  I didn't want to have to invoke it for
every string for every buffer I visited.

Thanks anyhow.

> 
> 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.
>>
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs


-- 
"This world ain't big enough for the both of us,"
said the big noema to the little noema.

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

end of thread, other threads:[~2006-03-15 18:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4.1142170197.32310.help-gnu-emacs@gnu.org>
2006-03-12 13:51 ` custom colorizing keywords Stefan Monnier
2006-03-13 18:59 ` Steve Wainstead
2006-03-15 18:41   ` ken
     [not found] <44166427.6040005@gmx.at>
2006-03-15 14:18 ` ken
2006-03-12 13:29 ken

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