unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* "Invalid face reference" msg logged to *Messages* (but no error)
@ 2009-05-05 18:54 Drew Adams
  2009-05-06  0:12 ` Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2009-05-05 18:54 UTC (permalink / raw)
  To: emacs-devel

In GNU Emacs 23.0.93.1 (i386-mingw-nt5.1.2600) of 2009-05-02 on SOFT-MJASON, I
am seeing this logged to *Messages* at various points, with N = various
integers:

"Invalid face reference: quote [N times]"

Haven't been able to figure out where it's coming from yet. No error is raised
(why not?), so debug-on-error doesn't help. I assume that some code has (quote
foo) where Emacs is expecting just foo, and so it tries to interpret `quote' as
a face. But I haven't been able to track this down, to see if it is a problem
with my code or something else. I haven't noticed this in earlier builds of
Emacs 23 (or in other releases).

The only src directory I have for Emacs 23 dates from 2007. There I see this in
merge_face_ref:

      /* FACE_REF ought to be a face name.  */
      ok = merge_named_face (f, face_ref, to, named_merge_points);
      if (!ok && err_msgs)
	add_to_log ("Invalid face reference: %s", face_ref, Qnil);

Anyone have a clue about this error? Have you seen it?


[FWIW (no doubt unrelated), I've also seen this logged in *Messages*:
"Error during redisplay: (quit)". And of course I too still get this:
"Emergency (alloc): Warning: past 75% of memory limit"]






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

* RE: "Invalid face reference" msg logged to *Messages* (but no error)
  2009-05-05 18:54 "Invalid face reference" msg logged to *Messages* (but no error) Drew Adams
@ 2009-05-06  0:12 ` Drew Adams
  2009-05-06  1:25   ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2009-05-06  0:12 UTC (permalink / raw)
  To: emacs-devel

The message "Invalid face reference: quote [N times]" seems to start when this
is evaluated:

(add-text-properties 99 111 (face (quote some-face)))

The actual face `some-face' makes no difference. The `face' text property is in
fact added (and displayed) correctly.

N is incremented thereafter, with seemingly each event. My guess is that it is
redisplay that is logging/updating the message - it doesn't seem to be related
to the code being evaluated. The add-text-property call seems only to be what
initiates it.

And a correction: I do see this also with Emacs 22 - just never noticed it
before.

HTH. Anyone know what this is about?

> From: Drew Adams Sent: Tuesday, May 05, 2009 11:54 AM
> In GNU Emacs 23.0.93.1 (i386-mingw-nt5.1.2600) of 2009-05-02 
> on SOFT-MJASON, I am seeing this logged to *Messages* at
> various points, with N = various integers:
> 
> "Invalid face reference: quote [N times]"
> 
> Haven't been able to figure out where it's coming from yet. 
> No error is raised (why not?), so debug-on-error doesn't help.
> I assume that some code has (quote foo) where Emacs is expecting
> just foo, and so it tries to interpret `quote' as
> a face. But I haven't been able to track this down, to see if 
> it is a problem with my code or something else. I haven't
> noticed this in earlier builds of Emacs 23 (or in other releases).
> 
> The only src directory I have for Emacs 23 dates from 2007. 
> There I see this in merge_face_ref:
> 
>       /* FACE_REF ought to be a face name.  */
>       ok = merge_named_face (f, face_ref, to, named_merge_points);
>       if (!ok && err_msgs)
> 	add_to_log ("Invalid face reference: %s", face_ref, Qnil);
> 
> Anyone have a clue about this error? Have you seen it?
> 
> 
> [FWIW (no doubt unrelated), I've also seen this logged in *Messages*:
> "Error during redisplay: (quit)". And of course I too still get this:
> "Emergency (alloc): Warning: past 75% of memory limit"]





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

* Re: "Invalid face reference" msg logged to *Messages* (but no error)
  2009-05-06  0:12 ` Drew Adams
@ 2009-05-06  1:25   ` Stefan Monnier
  2009-05-06  2:29     ` Drew Adams
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2009-05-06  1:25 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

> (add-text-properties 99 111 (face (quote some-face)))

This code isn't correct, because it calls `face' as a function.
So I guess you mean

   (add-text-properties 99 111 '(face (quote some-face)))

in which case the fix is to use

   (add-text-properties 99 111 '(face some-face))

aka

   (put-text-property 99 111 'face 'some-face)

> N is incremented thereafter, with seemingly each event.  My guess is
> that it is redisplay that is logging/updating the message - it doesn't
> seem to be related to the code being evaluated.  The add-text-property
> call seems only to be what initiates it.

Yes, the message comes from redisplay.


        Stefan




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

* RE: "Invalid face reference" msg logged to *Messages* (but no error)
  2009-05-06  1:25   ` Stefan Monnier
@ 2009-05-06  2:29     ` Drew Adams
  2009-05-06  3:01       ` Miles Bader
                         ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Drew Adams @ 2009-05-06  2:29 UTC (permalink / raw)
  To: 'Stefan Monnier'; +Cc: emacs-devel

> > (add-text-properties 99 111 (face (quote some-face)))
> 
> This code isn't correct, because it calls `face' as a function.
> So I guess you mean
>    (add-text-properties 99 111 '(face (quote some-face)))

Yes, that was actually from the debugger, so it was after arg evaluation.

> in which case the fix is to use
>    (add-text-properties 99 111 '(face some-face))

Duh. Hard to believe I didn't notice that. Thanks for the extra eyeballs.

> > N is incremented thereafter, with seemingly each event.  My guess is
> > that it is redisplay that is logging/updating the message - 
> > it doesn't seem to be related to the code being evaluated.  The 
> > add-text-property call seems only to be what initiates it.
> 
> Yes, the message comes from redisplay.

I had the same code in several places (different commands) actually, from
copy+pasting no doubt. What's odd it that it still worked. The only difference I
can see is the message logged to *Messages*. The face was added properly,
combined with other text properties properly when that was the case, etc. I
don't understand it, but that's the case.

I wonder too why such a thing is not handled as an error, or even as a message
to the echo area, but just logged in *Messages*. Is it the case perhaps that we
never raise an error from the redisplay code?

Anyway, thanks for clearing this up. 





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

* Re: "Invalid face reference" msg logged to *Messages* (but no error)
  2009-05-06  2:29     ` Drew Adams
@ 2009-05-06  3:01       ` Miles Bader
  2009-05-06  3:26       ` Stefan Monnier
  2009-05-06 18:38       ` Eli Zaretskii
  2 siblings, 0 replies; 8+ messages in thread
From: Miles Bader @ 2009-05-06  3:01 UTC (permalink / raw)
  To: emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:
> I wonder too why such a thing is not handled as an error, or even as a
> message to the echo area, but just logged in *Messages*. Is it the
> case perhaps that we never raise an error from the redisplay code?

yes

Errors from redisplay can be very nasty...

-Miles

-- 
Logic, n. The art of thinking and reasoning in strict accordance with the
limitations and incapacities of the human misunderstanding.





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

* Re: "Invalid face reference" msg logged to *Messages* (but no error)
  2009-05-06  2:29     ` Drew Adams
  2009-05-06  3:01       ` Miles Bader
@ 2009-05-06  3:26       ` Stefan Monnier
  2009-05-06  5:54         ` Drew Adams
  2009-05-06 18:38       ` Eli Zaretskii
  2 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2009-05-06  3:26 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

> I had the same code in several places (different commands) actually,
> from copy+pasting no doubt. What's odd it that it still worked. The
> only difference I can see is the message logged to *Messages*. The
> face was added properly, combined with other text properties properly
> when that was the case, etc. I don't understand it, but that's
> the case.

The `face' property can hold a list of faces as well, so your (quote
some-face) was really saying "combine the face `some-face' and the face
`quote'".  So the redisplay skipped the non-existent `quote' face (with
an appropriate error message) and used just `some-face'.

> I wonder too why such a thing is not handled as an error, or even as
> a message to the echo area, but just logged in *Messages*.  Is it the
> case perhaps that we never raise an error from the redisplay code?

The redisplay code is executed "asynchronously" and signalling an error
from it is rather problematic.  Of course, the error could be caught
earlier during the `add-text-properties' call, but currently
add-text-properties knows nothing about the special meaning of `face'
(or any other special text property for that matter), so it would
require a significant change (and risks introducing bugs since e.g. in
your example you may actually define the `quote' face just after doing
the add-text-properties).


        Stefan




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

* RE: "Invalid face reference" msg logged to *Messages* (but no error)
  2009-05-06  3:26       ` Stefan Monnier
@ 2009-05-06  5:54         ` Drew Adams
  0 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2009-05-06  5:54 UTC (permalink / raw)
  To: 'Stefan Monnier'; +Cc: emacs-devel

> > I had the same code in several places (different commands) actually,
> > from copy+pasting no doubt. What's odd it that it still worked. The
> > only difference I can see is the message logged to *Messages*. The
> > face was added properly, combined with other text 
> > properties properly
> > when that was the case, etc. I don't understand it, but that's
> > the case.
> 
> The `face' property can hold a list of faces as well,

Right; I use that in this particular code, in fact, merging various faces.

> so your (quote some-face) was really saying "combine the face `some-face' 
> and the face `quote'". So the redisplay skipped the non-existent `quote' 
> face (with an appropriate error message) and used just `some-face'.

That's what I guessed (after this mail exchange); I figured it must just be
tolerant. From Miles's message I see that the reason is that redisplay can't
really do much else, reasonably.

> > I wonder too why such a thing is not handled as an error, or even as
> > a message to the echo area, but just logged in *Messages*.  
> > Is it the case perhaps that we never raise an error from the
> > redisplay code?
> 
> The redisplay code is executed "asynchronously" and 
> signalling an error from it is rather problematic. Of course, the
> error could be caught earlier during the `add-text-properties' call,
> but currently add-text-properties knows nothing about the special
> meaning of `face' (or any other special text property for that
> matter),

Right; of course.

> so it would require a significant change (and risks introducing
> bugs since e.g. in your example you may actually define the
> `quote' face just after doing the add-text-properties).

Yes.

IIUC, `add-text-property' actually does add the `face' property value `quote' -
there is no error at that level/time. It is only during redisplay that redisplay
mentions in passing that at that moment it doesn't recognize any face named
`quote'. That all sounds good, to me.

Thanks for the explanations.





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

* Re: "Invalid face reference" msg logged to *Messages* (but no error)
  2009-05-06  2:29     ` Drew Adams
  2009-05-06  3:01       ` Miles Bader
  2009-05-06  3:26       ` Stefan Monnier
@ 2009-05-06 18:38       ` Eli Zaretskii
  2 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2009-05-06 18:38 UTC (permalink / raw)
  To: Drew Adams; +Cc: monnier, emacs-devel

> From: "Drew Adams" <drew.adams@oracle.com>
> Date: Tue, 5 May 2009 19:29:58 -0700
> Cc: emacs-devel@gnu.org
> 
> I wonder too why such a thing is not handled as an error, or even as a message
> to the echo area, but just logged in *Messages*. Is it the case perhaps that we
> never raise an error from the redisplay code?

In addition to everything others wrote about the reason(s), there's
one more: signaling an error itself triggers redisplay -- to display
the error message.  Now, if you do that because redisplay code itself
encountered a fatal error, you will almost certainly immediately
trigger the same problem again, because redisplay triggered by
signaling an error will want to redisplay the entire selected frame.
So you will have an endless loop of fatal errors and a stuck Emacs
that is only good to be killed.

That is why in the few situations where we need to report something
fatal from redisplay code, we display it somewhere, like in the mode
line, instead of signaling an error in the usual way.  See, for
example, what we do with invalid EOL type display in
decode_mode_spec_coding (on xdisp.c).  Less fatal errors simply go to
*Messages*.




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

end of thread, other threads:[~2009-05-06 18:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-05 18:54 "Invalid face reference" msg logged to *Messages* (but no error) Drew Adams
2009-05-06  0:12 ` Drew Adams
2009-05-06  1:25   ` Stefan Monnier
2009-05-06  2:29     ` Drew Adams
2009-05-06  3:01       ` Miles Bader
2009-05-06  3:26       ` Stefan Monnier
2009-05-06  5:54         ` Drew Adams
2009-05-06 18:38       ` Eli Zaretskii

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