unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5129: 23.1.50; adding font-lock-keywords for face highlight
@ 2009-12-05 19:15 ` Roland Winkler
  2009-12-05 20:32   ` Glenn Morris
  2009-12-05 21:10   ` bug#5129: marked as done (23.1.50; adding font-lock-keywords for face highlight) Emacs bug Tracking System
  0 siblings, 2 replies; 4+ messages in thread
From: Roland Winkler @ 2009-12-05 19:15 UTC (permalink / raw)
  To: emacs-pretest-bug

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





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

* bug#5129: 23.1.50; adding font-lock-keywords for face highlight
  2009-12-05 19:15 ` bug#5129: 23.1.50; adding font-lock-keywords for face highlight Roland Winkler
@ 2009-12-05 20:32   ` Glenn Morris
  2009-12-05 23:32     ` Roland Winkler
  2009-12-05 21:10   ` bug#5129: marked as done (23.1.50; adding font-lock-keywords for face highlight) Emacs bug Tracking System
  1 sibling, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2009-12-05 20:32 UTC (permalink / raw)
  To: Roland Winkler; +Cc: 5129

"Roland Winkler" wrote:

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

works

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

doesn't work.

I think you are running into the old issue that faces should be quoted
in font-lock keywords, else they will be treated as variables. For
historical reasons, font-lock-constant-face (etc) as well as being a
face, is a variable whose value is that face.

Instead, try

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





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

* bug#5129: marked as done (23.1.50; adding font-lock-keywords for face highlight)
  2009-12-05 19:15 ` bug#5129: 23.1.50; adding font-lock-keywords for face highlight Roland Winkler
  2009-12-05 20:32   ` Glenn Morris
@ 2009-12-05 21:10   ` Emacs bug Tracking System
  1 sibling, 0 replies; 4+ messages in thread
From: Emacs bug Tracking System @ 2009-12-05 21:10 UTC (permalink / raw)
  To: Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 921 bytes --]

Your message dated Sat, 05 Dec 2009 16:04:29 -0500
with message-id <jwv1vj9nni9.fsf-monnier+emacsbugreports@gnu.org>
and subject line Re: bug#5129: 23.1.50; adding font-lock-keywords for face highlight
has caused the Emacs bug report #5129,
regarding 23.1.50; adding font-lock-keywords for face highlight
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@emacsbugs.donarmstrong.com
immediately.)


-- 
5129: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=5129
Emacs Bug Tracking System
Contact owner@emacsbugs.donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 2984 bytes --]

From: "Roland Winkler" <Roland.Winkler@physik.uni-erlangen.de>
To: emacs-pretest-bug@gnu.org
Subject: 23.1.50; adding font-lock-keywords for face highlight
Date: Sat, 05 Dec 2009 13:15:31 -0600
Message-ID: <878wdhp6zw.fsf@regnitz.physics.niu.edu>

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


[-- Attachment #3: Type: message/rfc822, Size: 2483 bytes --]

From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Subject: Re: bug#5129: 23.1.50; adding font-lock-keywords for face highlight
Date: Sat, 05 Dec 2009 16:04:29 -0500
Message-ID: <jwv1vj9nni9.fsf-monnier+emacsbugreports@gnu.org>

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

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

* bug#5129: 23.1.50; adding font-lock-keywords for face highlight
  2009-12-05 20:32   ` Glenn Morris
@ 2009-12-05 23:32     ` Roland Winkler
  0 siblings, 0 replies; 4+ messages in thread
From: Roland Winkler @ 2009-12-05 23:32 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 5129

On Sat Dec 5 2009 Glenn Morris wrote:
> Instead, try
> 
> (font-lock-add-keywords nil '(("foo" . 'highlight)))

Oh well, I thought I ran into this often enough. But still it's too
easy to forget it again.

Thanks for helping me out and sorry for the noise!

Roland





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

end of thread, other threads:[~2009-12-05 23:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <jwv1vj9nni9.fsf-monnier+emacsbugreports@gnu.org>
2009-12-05 19:15 ` bug#5129: 23.1.50; adding font-lock-keywords for face highlight Roland Winkler
2009-12-05 20:32   ` Glenn Morris
2009-12-05 23:32     ` Roland Winkler
2009-12-05 21:10   ` bug#5129: marked as done (23.1.50; adding font-lock-keywords for face highlight) Emacs bug Tracking System

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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