unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
@ 2019-03-26 16:37 Markus Triska
  2019-03-28 16:14 ` Eli Zaretskii
  0 siblings, 1 reply; 16+ messages in thread
From: Markus Triska @ 2019-03-26 16:37 UTC (permalink / raw)
  To: 35005


The Elisp info material states in "39.12 Faces": 

      Many parts of Emacs require named faces, and do not accept
   anonymous faces. These include the functions documented in Attribute
   Functions, and the variable ‘font-lock-keywords’ (see Search-based
   Fontification). Unless otherwise stated, we will use the term “face”
   to refer only to named faces.

However, when I start Emacs with "emacs -Q", and then evaluate in
the *scratch* buffer the form:

    (progn
      (font-lock-add-keywords nil '(("hello" 0 '(:background "green")) t))
      (insert "hello"))

then I see that "hello" is inserted and highlighted in green, apparently
due to search-based fontification where an anonymous face is specified!

I am currently working on an application where this functionality (i.e.,
anonymous faces that can be specified for fontification) would be
extremely useful. Could you please consider supporting this feature,
and - if this already works as intended - officially document it?

Thank you and all the best!
Markus

In GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin18.0.0, X toolkit, Xaw scroll bars)
 of 2018-11-15 built on mt-computer
Repository revision: b4eb908f858284a7962851fd99c94598f76afa6f
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000







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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
  2019-03-26 16:37 bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces Markus Triska
@ 2019-03-28 16:14 ` Eli Zaretskii
  2019-10-31 17:24   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2019-03-28 16:14 UTC (permalink / raw)
  To: Markus Triska; +Cc: 35005

> From: Markus Triska <triska@metalevel.at>
> Date: Tue, 26 Mar 2019 17:37:04 +0100
> 
> 
> The Elisp info material states in "39.12 Faces": 
> 
>       Many parts of Emacs require named faces, and do not accept
>    anonymous faces. These include the functions documented in Attribute
>    Functions, and the variable ‘font-lock-keywords’ (see Search-based
>    Fontification). Unless otherwise stated, we will use the term “face”
>    to refer only to named faces.
> 
> However, when I start Emacs with "emacs -Q", and then evaluate in
> the *scratch* buffer the form:
> 
>     (progn
>       (font-lock-add-keywords nil '(("hello" 0 '(:background "green")) t))
>       (insert "hello"))
> 
> then I see that "hello" is inserted and highlighted in green, apparently
> due to search-based fontification where an anonymous face is specified!
> 
> I am currently working on an application where this functionality (i.e.,
> anonymous faces that can be specified for fontification) would be
> extremely useful. Could you please consider supporting this feature,
> and - if this already works as intended - officially document it?

I suggest to ask on emacs-devel whether the documentation is correct
or not.  It's possible that there are some subtle use cases where
anonymous faces won't work in this situation.  The real experts on
this matter don't read the bug list.





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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
  2019-03-28 16:14 ` Eli Zaretskii
@ 2019-10-31 17:24   ` Lars Ingebrigtsen
  2019-10-31 20:38     ` Stefan Monnier
  2019-10-31 21:09     ` Markus Triska
  0 siblings, 2 replies; 16+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-31 17:24 UTC (permalink / raw)
  To: Markus Triska, 35005, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> The Elisp info material states in "39.12 Faces": 
>> 
>>       Many parts of Emacs require named faces, and do not accept
>>    anonymous faces. These include the functions documented in Attribute
>>    Functions, and the variable ‘font-lock-keywords’ (see Search-based
>>    Fontification). Unless otherwise stated, we will use the term “face”
>>    to refer only to named faces.
>> 
>> However, when I start Emacs with "emacs -Q", and then evaluate in
>> the *scratch* buffer the form:
>> 
>>     (progn
>>       (font-lock-add-keywords nil '(("hello" 0 '(:background "green")) t))
>>       (insert "hello"))
>> 
>> then I see that "hello" is inserted and highlighted in green, apparently
>> due to search-based fontification where an anonymous face is specified!
>> 
>> I am currently working on an application where this functionality (i.e.,
>> anonymous faces that can be specified for fontification) would be
>> extremely useful. Could you please consider supporting this feature,
>> and - if this already works as intended - officially document it?
>
> I suggest to ask on emacs-devel whether the documentation is correct
> or not.  It's possible that there are some subtle use cases where
> anonymous faces won't work in this situation.  The real experts on
> this matter don't read the bug list.

I'm not sure whether this was ever brought up on emacs-devel?  I
wondered about that restriction myself -- I could see why it might be an
issue (some parts of the font locking machinery checking for whether an
element is a list and interpreting is as something other than a face),
but it would be nice if this worked with anonymous faces.

Does anybody know what the manual is referring to here, or whether it's
an outdated restriction that has gone away?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
  2019-10-31 17:24   ` Lars Ingebrigtsen
@ 2019-10-31 20:38     ` Stefan Monnier
  2019-11-01 13:13       ` Lars Ingebrigtsen
       [not found]       ` <871rur4u4j.fsf@gnus.org>
  2019-10-31 21:09     ` Markus Triska
  1 sibling, 2 replies; 16+ messages in thread
From: Stefan Monnier @ 2019-10-31 20:38 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Markus Triska, 35005, emacs-devel

> I'm not sure whether this was ever brought up on emacs-devel?  I
> wondered about that restriction myself -- I could see why it might be an
> issue (some parts of the font locking machinery checking for whether an
> element is a list and interpreting is as something other than a face),
> but it would be nice if this worked with anonymous faces.
>
> Does anybody know what the manual is referring to here, or whether it's
> an outdated restriction that has gone away?

AFAIK anonymous faces work fine in font-lock.  They can be a bit more
delicate to us because many places that accept faces also accept lists
(either of faces or of other things) but in general there's no real
restriction that I know of.

So I think the "do not accept" part is not true (any more?), but it's
still the case that you're generally better off using named faces
when possible.


        Stefan






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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
  2019-10-31 17:24   ` Lars Ingebrigtsen
  2019-10-31 20:38     ` Stefan Monnier
@ 2019-10-31 21:09     ` Markus Triska
  1 sibling, 0 replies; 16+ messages in thread
From: Markus Triska @ 2019-10-31 21:09 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 35005, emacs-devel

Dear Lars,

Lars Ingebrigtsen <larsi@gnus.org> writes:

> I'm not sure whether this was ever brought up on emacs-devel?

It was, but I have not received any answer so far:

  https://lists.gnu.org/archive/html/emacs-devel/2019-03/msg01092.html

Thank you for looking into this!

All the best,
Markus






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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
  2019-10-31 20:38     ` Stefan Monnier
@ 2019-11-01 13:13       ` Lars Ingebrigtsen
       [not found]       ` <871rur4u4j.fsf@gnus.org>
  1 sibling, 0 replies; 16+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-01 13:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Markus Triska, 35005, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> AFAIK anonymous faces work fine in font-lock.  They can be a bit more
> delicate to us because many places that accept faces also accept lists
> (either of faces or of other things) but in general there's no real
> restriction that I know of.
>
> So I think the "do not accept" part is not true (any more?), but it's
> still the case that you're generally better off using named faces
> when possible.

OK, I'll adjust the text in the manual.  Names faces are preferable, but
generating faces on the fly is sometimes necessary. 

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
       [not found]       ` <871rur4u4j.fsf@gnus.org>
@ 2019-11-02  9:10         ` Markus Triska
       [not found]         ` <87sgn6abjw.fsf@metalevel.at>
  1 sibling, 0 replies; 16+ messages in thread
From: Markus Triska @ 2019-11-02  9:10 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Stefan Monnier, 35005, emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> OK, I'll adjust the text in the manual.  Names faces are preferable, but
> generating faces on the fly is sometimes necessary.

In my opinion, this issue is not resolved, please consider reopening it.

With the change that is now installed, the documentation reads:

   Many parts of Emacs require named faces, but some do not accept
   anonymous faces (e.g., the functions documented in @ref{Attribute
   Functions})

Where "require named faces" and "do not accept anonymous faces" amounts
to the same thing, so the wording seems not to be the intended one.

So in fact, the documentation now stresses further that named faces are
required, whereas the point of this issue is to document that anonymous
faces can be used for fontification. This still cannot be deduced from
the current manual. If that works, could you please document it?

Thank you and all the best,
Markus





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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
       [not found]         ` <87sgn6abjw.fsf@metalevel.at>
@ 2019-11-02 15:07           ` Lars Ingebrigtsen
       [not found]           ` <87mudee2pk.fsf@gnus.org>
  1 sibling, 0 replies; 16+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-02 15:07 UTC (permalink / raw)
  To: Markus Triska; +Cc: Stefan Monnier, 35005, emacs-devel

Markus Triska <triska@metalevel.at> writes:

> With the change that is now installed, the documentation reads:
>
>    Many parts of Emacs require named faces, but some do not accept
>    anonymous faces (e.g., the functions documented in @ref{Attribute
>    Functions})
>
> Where "require named faces" and "do not accept anonymous faces" amounts
> to the same thing, so the wording seems not to be the intended one.

Yeah, that's a very awkward of putting it, so I've now tweaked it some.

> So in fact, the documentation now stresses further that named faces are
> required, whereas the point of this issue is to document that anonymous
> faces can be used for fontification. This still cannot be deduced from
> the current manual. If that works, could you please document it?

It just mentions one example where named faces are required, and I think
the reader will take from that that Emacs will document when you can't
use anonymous faces.  Since font locking doesn't say anything about
that, then the natural interpretation is that font locking doesn't
require named faces.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
       [not found]           ` <87mudee2pk.fsf@gnus.org>
@ 2019-11-09 17:43             ` Markus Triska
       [not found]             ` <87y2wpndxs.fsf@metalevel.at>
  1 sibling, 0 replies; 16+ messages in thread
From: Markus Triska @ 2019-11-09 17:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Stefan Monnier, 35005, emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> It just mentions one example where named faces are required, and I think
> the reader will take from that that Emacs will document when you can't
> use anonymous faces.  Since font locking doesn't say anything about
> that, then the natural interpretation is that font locking doesn't
> require named faces.

Please consider specifically the documentation of the function
font-lock-add-keywords that I used in the example. Its documentation
points to that of font-lock-keywords, which contains the description:

   FACENAME is an expression whose value is the face name to use.
   Instead of a face, FACENAME can evaluate to a property list of
   the form (face FACE PROP1 VAL1 PROP2 VAL2 ...)  in which case all
   the listed text-properties will be set rather than just FACE.

This currently states that a face name is expected.

Since the Elisp documentation also states: "Unless otherwise stated, we
will use the term “face” to refer only to named faces.", the notion of
"face" in the description above also does not include anonymous faces.

Would it work to mention that "face FACE" can also be omitted, i.e.,
that an anonymous face can also be specified here?

Thank you and all the best,
Markus





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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
       [not found]             ` <87y2wpndxs.fsf@metalevel.at>
@ 2019-11-09 18:01               ` Stefan Monnier
       [not found]               ` <jwva795ue1u.fsf-monnier+emacs@gnu.org>
  1 sibling, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2019-11-09 18:01 UTC (permalink / raw)
  To: Markus Triska; +Cc: Lars Ingebrigtsen, 35005, emacs-devel

>    FACENAME is an expression whose value is the face name to use.
>    Instead of a face, FACENAME can evaluate to a property list of
>    the form (face FACE PROP1 VAL1 PROP2 VAL2 ...)  in which case all
>    the listed text-properties will be set rather than just FACE.
>
> This currently states that a face name is expected.
>
> Since the Elisp documentation also states: "Unless otherwise stated, we
> will use the term “face” to refer only to named faces.", the notion of
> "face" in the description above also does not include anonymous faces.
>
> Would it work to mention that "face FACE" can also be omitted, i.e.,
> that an anonymous face can also be specified here?

No, the `face FACE` *cannot* be omitted: the `face' symbol in the car is
tested to distinguish this case.  Note also that the `PROP1 VAL1 ...`
are *not* face properties, they are *text* properties.

The above docstring should probably replace "face name" by "face" but
other than that it looks about right.


        Stefan






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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
       [not found]               ` <jwva795ue1u.fsf-monnier+emacs@gnu.org>
@ 2019-11-09 20:02                 ` Lars Ingebrigtsen
       [not found]                 ` <87tv7czulh.fsf@gnus.org>
  1 sibling, 0 replies; 16+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-09 20:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Markus Triska, 35005, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> The above docstring should probably replace "face name" by "face" but
> other than that it looks about right.

OK; updated.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
       [not found]                 ` <87tv7czulh.fsf@gnus.org>
@ 2019-11-09 21:02                   ` Markus Triska
       [not found]                   ` <87imnszrsx.fsf@metalevel.at>
  1 sibling, 0 replies; 16+ messages in thread
From: Markus Triska @ 2019-11-09 21:02 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Stefan Monnier, 35005, emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

>> The above docstring should probably replace "face name" by "face" but
>> other than that it looks about right.
>
> OK; updated.

Initially, I also thought this would solve it. However, as I mentioned,
the Emacs documentation states:

   "Unless otherwise stated, we will use the term “face” to refer only
   to named faces."

Therefore, the description now still does not make clear that anonymous
faces can be used here. I filed this issue to document this feature, and
I would appreciate if a phrasing to that effect could be added.

Thank you and all the best,
Markus






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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
       [not found]                   ` <87imnszrsx.fsf@metalevel.at>
@ 2019-11-09 21:10                     ` Stefan Monnier
       [not found]                     ` <jwvd0e0u5f7.fsf-monnier+emacs@gnu.org>
  2019-11-10  1:52                     ` Drew Adams
  2 siblings, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2019-11-09 21:10 UTC (permalink / raw)
  To: Markus Triska; +Cc: Lars Ingebrigtsen, 35005, emacs-devel

> Therefore, the description now still does not make clear that anonymous
> faces can be used here.

Maybe we should simply better document the general rules about where
anonymous faces can usually be used and where they usually can't be used
(AFAICT they can be used where they affect the redisplay (e.g. in the
`face` and `font-lock-face` properties) but they can't be passed to face
manipulation functions like `set-face-attributes` and `describe-face`).
Their usage in font-lock is a natural consequence of those general
rules and doesn't merit extra discussion in the font-lock-keywords
doc which is already complex enough IMO.


        Stefan






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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
       [not found]                     ` <jwvd0e0u5f7.fsf-monnier+emacs@gnu.org>
@ 2019-11-09 21:29                       ` Markus Triska
  2019-11-14  9:00                       ` Eli Zaretskii
  1 sibling, 0 replies; 16+ messages in thread
From: Markus Triska @ 2019-11-09 21:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Lars Ingebrigtsen, 35005, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Maybe we should simply better document the general rules about where
> anonymous faces can usually be used and where they usually can't be
> used

Yes, I would greatly appreciate this, and it would also solve this
concrete issue.

Thank you and all the best,
Markus





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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
       [not found]                   ` <87imnszrsx.fsf@metalevel.at>
  2019-11-09 21:10                     ` Stefan Monnier
       [not found]                     ` <jwvd0e0u5f7.fsf-monnier+emacs@gnu.org>
@ 2019-11-10  1:52                     ` Drew Adams
  2 siblings, 0 replies; 16+ messages in thread
From: Drew Adams @ 2019-11-10  1:52 UTC (permalink / raw)
  To: Markus Triska, Lars Ingebrigtsen; +Cc: Stefan Monnier, 35005, emacs-devel

Sorry to interrupt, but is there a good
reason y'all are sending this to both
the bug list and emacs-devel?  If not,
please consider sending it to only the
bug list.  Thx.





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

* bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces
       [not found]                     ` <jwvd0e0u5f7.fsf-monnier+emacs@gnu.org>
  2019-11-09 21:29                       ` Markus Triska
@ 2019-11-14  9:00                       ` Eli Zaretskii
  1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2019-11-14  9:00 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: larsi, triska, 35005

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Sat, 09 Nov 2019 16:10:58 -0500
> Cc: Lars Ingebrigtsen <larsi@gnus.org>, 35005@debbugs.gnu.org,
>  emacs-devel@gnu.org
> 
> > Therefore, the description now still does not make clear that anonymous
> > faces can be used here.
> 
> Maybe we should simply better document the general rules about where
> anonymous faces can usually be used and where they usually can't be used
> (AFAICT they can be used where they affect the redisplay (e.g. in the
> `face` and `font-lock-face` properties) but they can't be passed to face
> manipulation functions like `set-face-attributes` and `describe-face`).
> Their usage in font-lock is a natural consequence of those general
> rules and doesn't merit extra discussion in the font-lock-keywords
> doc which is already complex enough IMO.

If someone knows enough to write a documentation patch about this,
please feel free, and TIA.





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

end of thread, other threads:[~2019-11-14  9:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-26 16:37 bug#35005: 27.0.50; Fontification unexpectedly works with anonymous faces Markus Triska
2019-03-28 16:14 ` Eli Zaretskii
2019-10-31 17:24   ` Lars Ingebrigtsen
2019-10-31 20:38     ` Stefan Monnier
2019-11-01 13:13       ` Lars Ingebrigtsen
     [not found]       ` <871rur4u4j.fsf@gnus.org>
2019-11-02  9:10         ` Markus Triska
     [not found]         ` <87sgn6abjw.fsf@metalevel.at>
2019-11-02 15:07           ` Lars Ingebrigtsen
     [not found]           ` <87mudee2pk.fsf@gnus.org>
2019-11-09 17:43             ` Markus Triska
     [not found]             ` <87y2wpndxs.fsf@metalevel.at>
2019-11-09 18:01               ` Stefan Monnier
     [not found]               ` <jwva795ue1u.fsf-monnier+emacs@gnu.org>
2019-11-09 20:02                 ` Lars Ingebrigtsen
     [not found]                 ` <87tv7czulh.fsf@gnus.org>
2019-11-09 21:02                   ` Markus Triska
     [not found]                   ` <87imnszrsx.fsf@metalevel.at>
2019-11-09 21:10                     ` Stefan Monnier
     [not found]                     ` <jwvd0e0u5f7.fsf-monnier+emacs@gnu.org>
2019-11-09 21:29                       ` Markus Triska
2019-11-14  9:00                       ` Eli Zaretskii
2019-11-10  1:52                     ` Drew Adams
2019-10-31 21:09     ` Markus Triska

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