GNU bug report logs -
#5129
23.1.50; adding font-lock-keywords for face highlight
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5129 in the body.
You can then email your comments to 5129 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#5129
; Package
emacs
.
(Sat, 05 Dec 2009 19:20:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Roland Winkler" <Roland.Winkler <at> physik.uni-erlangen.de>
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Sat, 05 Dec 2009 19:20:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
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
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#5129
; Package
emacs
.
(Sat, 05 Dec 2009 20:35:08 GMT)
Full text and
rfc822 format available.
Message #8 received at 5129 <at> emacsbugs.donarmstrong.com (full text, mbox):
"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)))
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Sat, 05 Dec 2009 21:10:09 GMT)
Full text and
rfc822 format available.
Notification sent
to
"Roland Winkler" <Roland.Winkler <at> physik.uni-erlangen.de>
:
bug acknowledged by developer.
(Sat, 05 Dec 2009 21:10:10 GMT)
Full text and
rfc822 format available.
Message #13 received at 5129-done <at> emacsbugs.donarmstrong.com (full text, mbox):
> (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
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#5129
; Package
emacs
.
(Sat, 05 Dec 2009 23:40:07 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Roland Winkler" <Roland.Winkler <at> physik.uni-erlangen.de>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Sat, 05 Dec 2009 23:40:07 GMT)
Full text and
rfc822 format available.
Message #18 received at 5129 <at> emacsbugs.donarmstrong.com (full text, mbox):
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
bug archived.
Request was from
Debbugs Internal Request <bug-gnu-emacs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 03 Jan 2010 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 15 years and 228 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.