Subject: Re: bug#4381: 23.1.50; Cocoa Emacs: face background for 'region set in ns-win.el after .emacs

From: Adrian Robert <[email-masked]>
Date: Thu, 24 Sep 2009 12:15:31 -0400

On Sep 24, 2009, at 11:14 AM, Stefan Monnier wrote:

>>>> Colors there are defined for dark and light backgrounds, which
>>>> is not supported by the NS implementation.
>>> Why isn't it supported?
>> The only system-defined selection color on NS platforms is for the
>> unconfigurable standard background color of white.
>
> I'm not sure we're talking about the same thing.  The lisp/faces.el
> notion of dark/light background doesn't have anything to do with the
> desktop's background, but with the Emacs buffers's default background
> (i.e. whether the background color of the `default' face is rather
> light or rather dark).

No, we are.  The background of content panes in apps under NS (text  
editors, email readers, PDF viewers, etc.) is unconfigurably fixed to  
be white.  So the system-defined selection color will work well with  
light backgrounds, but not dark.  The patch I attached handles this  
in a reasonable way though.

>> --- faces.el.~1.446.~	2009-09-05 15:33:48.000000000 -0400
>> +++ faces.el	2009-09-23 23:06:19.000000000 -0400
>> @@ -2281,6 +2281,8 @@ terminal type to a different value."
>>  (defface region
>>    '((((class color) (min-colors 88) (background dark))
>>       :background "blue3")
>> +    (((class color) (min-colors 88) (background light) (type ns))
>> +     :background "ns_selection_color")
>>      (((class color) (min-colors 88) (background light))
>>       :background "lightgoldenrod2")
>>      (((class color) (min-colors 16) (background dark))
>
> Could you add a comment explaining why you put (background light) in
> the specs?  I guess it's because the ns_selection_color is (almost)
> always defined with the assumption that it will be used on text
> displayed on a light background., right?

Something like:

;; Region face: under NS, use the system-defined selection color
;; (optimized for the system-fixed white background of other apps),
;; if background is light.