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

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

Re: Help with font-lock-add-keywords


From: Marcin Borkowski
Subject: Re: Help with font-lock-add-keywords
Date: Fri, 13 Mar 2015 04:46:21 +0100

On 2015-03-13, at 04:33, Emanuel Berg <address@hidden> wrote:

> Marcin Borkowski <address@hidden> writes:
>
>> I'm trying to grok the font-lock-add-keywords
>> function. Why doesn't this work (i.e., turn all
>> foo's into italic ones)?
>>
>> (font-lock-add-keywords nil '(("foo" . italic)))
>
> Try this - it should look like this after you put
> Emacs into emacs-lisp-mode:
>
>     http://user.it.uu.se/~embe8573/cols/www/dumps/emacs_faces.png
>
> (font-lock-add-keywords 'emacs-lisp-mode
>   '(
>     ("font-lock-builtin-face"              .  font-lock-builtin-face)
>     ("font-lock-comment-delimiter-face"    .  
> font-lock-comment-delimiter-face)
>     ("font-lock-comment-face"              .  font-lock-comment-face)
>     ("font-lock-constant-face"             .  font-lock-constant-face)
>     ("font-lock-doc-face"                  .  font-lock-doc-face)
>     ("font-lock-function-name-face"        .  font-lock-function-name-face)
>     ("font-lock-keyword-face"              .  font-lock-keyword-face)
>     ("font-lock-negation-char-face"        .  font-lock-negation-char-face)
>     ("font-lock-preprocessor-face"         .  font-lock-preprocessor-face)
>     ("font-lock-reference-face"            .  font-lock-reference-face)
>     ("font-lock-string-face"               .  font-lock-string-face)
>     ("font-lock-syntactic-face-function"   .  
> font-lock-syntactic-face-function)
>     ("font-lock-type-face"                 .  font-lock-type-face)
>     ("font-lock-variable-name-face"        .  font-lock-variable-name-face)
>     ("font-lock-warning-face"              .  font-lock-warning-face)
>     ("font-lock-regexp-grouping-construct" . 
> 'font-lock-regexp-grouping-construct)
>     ("font-lock-regexp-grouping-backslash" . 
> 'font-lock-regexp-grouping-backslash)
>     )
>   t)

Thanks!

This works - sort of.  First of all, not all faces are set correctly
until I edit something in the respective line.  And M-x
font-lock-fontify-buffer doesn't help - I don't understand this,
actually.  (Tested on emacs -Q.)

Even worse, if I add ("foo" . italic) to the list above, occurrences of
"foo" don't get italicized.  (M-x describe-face italic shows that my
computer /can/ display this face properly.)

What am I doing wrong?

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

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