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: Wed, 23 Sep 2009 23:19:37 -0400

On Sep 23, 2009, at 6:44 PM, Stefan Monnier wrote:

>>>> (custom-set-faces '(region ((t (:background  
>>>> "ns_selection_color")))))
>>> Why not change faces.el directly?
>
>> I guess I'd prefer to remove this feature completely over hacking  
>> into
>> faces.el.
>
> Your call, but if you want to change the default value of the `region'
> face, it should be done directly in faces.el.

Hmm, now that I see the 'type' parameter for defface, a patch is  
attached.

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

>> It would be nice to allow the default system-wide selection color to
>> be  used under NS, but I guess if this is not being implemented on  
>> GTK
>> /  etc. it is not considered important by Emacs users.
>
> IIUC it is supported under w32 (also be defining special color names),
> so you may want to check what they do there.  I do not know if they  
> set
> the faces to use those by default.
> BTW, it might be a good idea to try and use the same special color  
> names
> whenever possible.
> There's no such support under Gtk currently, AFAIK, but I don't think
> it's because we don't want it, but because nobody wrote the code  
> for it yet.

It looks like w32 adds system colors to a color "map" in  
w32fns.c:add_system_logical_colors_to_map ().  So they are available  
to the user when customizing.  Making some sort of alias like "system- 
selected-text-background" that window system code could map  
appropriately sounds like a good way to go.

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

--- ns-win.el.~1.53.~	2009-09-22 22:32:24.000000000 -0400
+++ ns-win.el	2009-09-23 23:03:31.000000000 -0400
@@ -1075,8 +1067,6 @@ On Nextstep, put TEXT in the pasteboard;
    (interactive)
    (insert (ns-get-cut-buffer-internal 'SECONDARY)))

-(set-face-background 'region "ns_selection_color")
-

  ;;;; Scrollbar handling.