Subject: bug#5129 closed by Stefan Monnier <[email-masked]> (Re: bug#5129: 23.1.50; adding font-lock-keywords for face highlight)

From: [email-masked] (Emacs bug Tracking System)
Date: Sat, 05 Dec 2009 21:10:10 +0000

This is an automatic notification regarding your bug report
which was filed against the emacs package:

#5129: 23.1.50; adding font-lock-keywords for face highlight

It has been closed by Stefan Monnier <[email-masked]>.

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact Stefan Monnier <[email-masked]> by
replying to this email.

-- 
5129: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5129
Emacs Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#5129: 23.1.50; adding font-lock-keywords for face highlight
From: Stefan Monnier <[email-masked]>
To: Roland Winkler <[email-masked]>
Date: Sat, 05 Dec 2009 16:04:29 -0500

>   (font-lock-add-keywords nil '(("foo" . font-lock-constant-face)))
                                           ^^^^^^^^^^^^^^^^^^^^^^^
> Yet when I do instead

>   (font-lock-add-keywords nil '(("foo" . highlight)))
                                           ^^^^^^^^^

Thos two things are treated by font-lock as a Lisp expression
to evaluate.  Since font-lock-constant-face is a variable (whose
content is usually the symbol font-lock-constant-face), the first will
work, whereas the second will either signal en error (because the
variable `highlight' doesn't exist) or lead to odd behavior (because
`highlight' just happens to be let-bound by one of the caller).

I.e. you want

   (font-lock-add-keywords nil '(("foo" . 'highlight)))
                                         ^^^

-- Stefan

Subject: 23.1.50; adding font-lock-keywords for face highlight
From: "Roland Winkler" <[email-masked]>
To: [email-masked]
Date: Sat, 05 Dec 2009 13:15:31 -0600

The highlight face is somehow treated special in an odd way:

If I eval the following in a buffer it will highlight all occurences
of "foo" as expected:

  (font-lock-add-keywords nil '(("foo" . font-lock-constant-face)))

Yet when I do instead

  (font-lock-add-keywords nil '(("foo" . highlight)))

it gives me the message (in the *Messages* buffer)

  Invalid face reference: 0

When I put point at the position of the string "foo" and evaluate

  (get-text-property (point) 'face)

this gives me

  (0 highlight)

which probably explains the "invalid face reference" error.
Why is the face `0' added?

In GNU Emacs 23.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.14.4)
 of 2009-12-04 on regnitz
Windowing system distributor `The X.Org Foundation', version 11.0.10502000

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: en_GB.utf8
  value of $LANG: en_US.ISO-8859-15
  value of $XMODIFIERS: nil
  locale-coding-system: iso-latin-9-unix
  default enable-multibyte-characters: t