unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* font-lock-add-keywords confusion
@ 2007-02-10 14:25 Þorne
  2007-02-10 14:41 ` Þorne
  0 siblings, 1 reply; 3+ messages in thread
From: Þorne @ 2007-02-10 14:25 UTC (permalink / raw)
  To: help-gnu-emacs

I'm having major trouble understanding the documentation on faces--
specifically font-lock-add-keywords.  This works for me (emacs 21.3.1
Windows):

(font-lock-add-keywords nil
  '(("foo" 0 font-lock-builtin-face)))

but this does not:

(font-lock-add-keywords nil
  '(("foo" 0 underline)))

Nor with any other face--except the font-lock faces.  If i do M-x list-
faces-display, `underline' is there and looks right.

So i try:

(defface font-lock-underlined-face
  '((t (:underline t)))
  "Font Lock mode face used to underline."
  :group 'font-lock-highlighting-faces)

(font-lock-add-keywords nil
  '(("foo" 0 font-lock-underlined-face)))

but still no luck, even though again it looks like the new face is
defined ok and works--at least in customize and in list-faces-
display.

So what am i missing?

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

* Re: font-lock-add-keywords confusion
  2007-02-10 14:25 font-lock-add-keywords confusion Þorne
@ 2007-02-10 14:41 ` Þorne
  2007-02-10 20:10   ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Þorne @ 2007-02-10 14:41 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 10, 6:25 am, "Þorne" <ego...@gmail.com> wrote:
> I'm having major trouble understanding the documentation on faces--
> specificallyfont-lock-add-keywords.

That's for sure.

Sorry, nevermind.  I obviously didn't understant the types of the
arguments.

So, in case anyone searches and finds this, the answer is, the face
name needs to be quoted, as in:

(font-lock-add-keywords nil
  '(("foo" 0 'underline)))

The stock font-lock face names (like font-lock-builtin-face, etc) all
are symbols that point to themselves (or something like that) and so
are more-or-less self-quoting.  Kinda strange, at least for a lisp
newbie.

Þ

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

* Re: font-lock-add-keywords confusion
  2007-02-10 14:41 ` Þorne
@ 2007-02-10 20:10   ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2007-02-10 20:10 UTC (permalink / raw)
  To: help-gnu-emacs

> Sorry, nevermind.  I obviously didn't understant the types of the
> arguments.

Yes, the arg is not a face, but an expression whose evaluation returns
a face.  The added expressive power is very important.

> So, in case anyone searches and finds this, the answer is, the face
> name needs to be quoted, as in:

> (font-lock-add-keywords nil
>   '(("foo" 0 'underline)))

> The stock font-lock face names (like font-lock-builtin-face, etc) all
> are symbols that point to themselves (or something like that) and so
> are more-or-less self-quoting.

Yes, pretty much, or more precisely, the font-lock-<foo>-face are all both
faces and variables whose value is the corresponding face.

> Kinda strange, at least for a lisp newbie.

Yes, it's too bad the same name was chosen.  It should have been "variable
font-lock-foo-face has value `font-lock-foo' which is a face".

The purpose of those vars is not just to make it "self-quoting", but rather
to be able to change the face in some buffers, by making the variable local
to that buffer.


        Stefan

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

end of thread, other threads:[~2007-02-10 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-10 14:25 font-lock-add-keywords confusion Þorne
2007-02-10 14:41 ` Þorne
2007-02-10 20:10   ` Stefan Monnier

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