Subject: Re: bug#60841: 30.0.50; kill-ring-save pauses despite region being highlighted

From: Kévin Le Gouguec <[email-masked]>
Date: Tue, 17 Jan 2023 08:53:03 +0100

Gregory Heytings <[email-masked]> writes:

>> But it would be better to have there a test which would tell us whether the
>> region face is "visually different" from the default face.  Can we do
>> something like that?
>>
>
> face-differs-from-default-p?

Nice catch; IIUC display-supports-face-attributes-p is what is doing the
heavy work.

Might need to be made smarter wrt :extend though?

(set-face-background 'region (face-background 'default nil t))
(face-differs-from-default-p 'region nil)
; ⇒ :extend

AFAICT (from messing around without any kind of scripted recipe, so
caveat lector),

* :extend nil on 'default does not prevent its background/underline from
  spanning the whole window width,

* but :extend t on 'default does not mean that other faces will be
  extended, even if they have :extend 'unspecified.

(This last point might have gone without saying for the audience; I
admit to not knowing enough about face internals to understand which
attributes are implicitly "inherited" from 'default)

So,

* :extend nil for both: they display differently (region will not be
  extended, default will be),
* :extend t for both: they display the same,
* default has nil, region has t: they display the same,
* default has t, region has nil: they display differently.

Ergo, assuming (a) I didn't mess something up (b) this is the expected
behaviour, it seems that when considering :extend,
(face-differs-from-default-p FACE FRAME) should check

(1) whether FACE's :extend is nil (regardless of default's :extend),
    and
(2) whether FACE's :underline or :background are "supported", as
    reported by display-supports-face-attributes-p.

Hope the coffee kicked in and the above made sense.