From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#41544: 26.3; Possible incorrect results from color-distance Date: Sun, 31 May 2020 22:46:07 +0200 Message-ID: <9902865C-01B4-4E50-A433-DBC8B8311234@acm.org> References: <5C4A633D-8222-4439-BE37-9B8674F1DA6D@acm.org> <87r1v2aat3.fsf@tromey.com> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_7FF6E8CE-41E3-44BB-A837-E0A212C5FA1B" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="34877"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Simon Pugnet , 41544@debbugs.gnu.org To: Tom Tromey Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 31 22:47:11 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jfUrP-00091Z-8b for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 May 2020 22:47:11 +0200 Original-Received: from localhost ([::1]:52030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfUrN-0007t2-Sg for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 May 2020 16:47:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfUrG-0007sn-Eh for bug-gnu-emacs@gnu.org; Sun, 31 May 2020 16:47:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jfUrG-0001T9-4z for bug-gnu-emacs@gnu.org; Sun, 31 May 2020 16:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jfUrG-0007PG-3i for bug-gnu-emacs@gnu.org; Sun, 31 May 2020 16:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 May 2020 20:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41544 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 41544-submit@debbugs.gnu.org id=B41544.159095797628405 (code B ref 41544); Sun, 31 May 2020 20:47:02 +0000 Original-Received: (at 41544) by debbugs.gnu.org; 31 May 2020 20:46:16 +0000 Original-Received: from localhost ([127.0.0.1]:33954 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jfUqW-0007O4-4S for submit@debbugs.gnu.org; Sun, 31 May 2020 16:46:16 -0400 Original-Received: from mail208c50.megamailservers.eu ([91.136.10.218]:53996 helo=mail194c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jfUqT-0007Nu-7y for 41544@debbugs.gnu.org; Sun, 31 May 2020 16:46:14 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1590957970; bh=ooMLS9DDFzKSGSxXjp/3+EGdBk0U2wGJBMbfN6qNNf4=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=B6Jpy68SQ0/A2qu5YuKnv9cfKYOVqmXrHaeexbMwRBuycmNPfjobDFwdrWoo3S5et g+3WOZt165TbM3XdcOAmM/zCMy44t2mV91V0cRALVHj58l7OqraQTnK6ryzcacWZS4 fDa69uucErSHwjjrepvON9EOl2FQznlvLEwMhQbE= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-4e4ae655.032-75-73746f71.bbcust.telenor.se [85.230.74.78]) (authenticated bits=0) by mail194c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 04VKk7hn017708; Sun, 31 May 2020 20:46:09 +0000 In-Reply-To: <87r1v2aat3.fsf@tromey.com> X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F1C.5ED41749.000C:SCFSTAT68638221, ss=1, re=-4.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: -4.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=KsozJleN c=1 sm=1 tr=0 a=klNLuyVZdLUgl+K5Uafb2A==:117 a=klNLuyVZdLUgl+K5Uafb2A==:17 a=M51BFTxLslgA:10 a=zstS-IiYAAAA:8 a=yhKnspnhLiaNJBSypWMA:9 a=CjuIK1q_8ugA:10 a=LUiTdrM7ar1z_bhPKtoA:9 a=B2y7HmGcmWMA:10 a=tclcd6dtLQvEqt9_mmAA:9 a=4G6NA9xxw8l3yy4pmD5M:22 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:181321 Archived-At: --Apple-Mail=_7FF6E8CE-41E3-44BB-A837-E0A212C5FA1B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 29 maj 2020 kl. 19.52 skrev Tom Tromey : > However, my main concern is just whether it still picks reasonably > contrasting colors when editing CSS. If it does, then that's good > enough for me. Thank you for the kind words. I couldn't leave well enough alone, of = course. Emacs does this sort of is-this-colour-dark computation in at = least 7 different places, with different algorithms: * max(r,g,b) < 0.5 * r+g+b < 0.5*3 * color-distance(c, "black") < 292485 They aren't really satisfactory: for example, saturated blue (#0000ff) = is quite clearly 'dark', yet the first algorithm considers it 'light'. = Colour distance isn't quite right either -- the implemented formula is = intended to measure distances between colours, not brightness. For = example, it considers #ff0000 to be closer than #0000ff to black, but = the red is clearly brighter. I tentatively went with your suggested 0.299r + 0.587g + 0.114g, with a = cut-off value of 0.58 to make saturated blue and red 'dark' and green = 'light'. This is not a correct luma calculation since there is no gamma = correction, but it might do for this purpose. Proposed patch attached. I found css-mode no worse than before (a tad = better, if anything). Perhaps we need to decompress to linear components = after all, but at least now there is a single place to do it. (Should list-colors-display use color-dark-p for the text in its left = column, by the way? Or is there a point in not doing so?) --Apple-Mail=_7FF6E8CE-41E3-44BB-A837-E0A212C5FA1B Content-Disposition: attachment; filename=0001-Use-a-single-light-dark-colour-predicate.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Use-a-single-light-dark-colour-predicate.patch" Content-Transfer-Encoding: quoted-printable =46rom=205d5ef884c47695a39c22d931c4bc44e6a812d7b4=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Sun,=2031=20May=202020=2021:12:46=20+0200=0A= Subject:=20[PATCH]=20Use=20a=20single=20light/dark=20colour=20predicate=0A= =0AAdd=20a=20single=20predicate,=20color-dark-p,=20for=20deciding=20= whether=20a=20colour=0Ais=20more=20readable=20against=20black=20or=20= white.=20=20Previously=20this=20was=20done=20in=0Adifferent=20ways=20in=20= several=20places,=20and=20with=20worse=20results.=20=20(Bug#41544)=0A=0A= *=20lisp/color.el=20(color-name-to-rgb):=20Use=20color-component-max=20= instead=0Aof=20the=20error-prone=20method=20of=20(color-values=20= "#ffffffffffff"),=20which=0Awould=20give=20unexpected=20values=20or=20= outright=20fail=20if=20called=20without=0Aan=20initialised=20display=20= (as=20in=20batch=20mode).=0A*=20lisp/facemenu.el=20(list-colors-print):=20= Use=20readable-foreground-color.=0A(color-dark-p,=20= color-component-max):=20New=20functions.=0A*=20lisp/term/pc-win.el:=20= Update=20comment.=0A*=20lisp/term/rxvt.el=20(rxvt-set-background-mode):=0A= *=20lisp/term/w32console.el=20(terminal-init-w32console):=0A*=20= lisp/term/xterm.el=20(xterm-maybe-set-dark-background-mode):=0A*=20= lisp/faces.el=20(readable-foreground-color):=0A*=20lisp/frame.el=20= (frame-set-background-mode):=20Use=20color-dark-p.=0A*=20= lisp/textmodes/css-mode.el=20(css--contrasty-color):=20Remove.=0A= (css--fontify-region):=20Use=20color-dark-p.=0A---=0A=20lisp/color.el=20=20= =20=20=20=20=20=20=20=20=20=20=20=20|=20=204=20+---=0A=20= lisp/facemenu.el=20=20=20=20=20=20=20=20=20=20=20|=20=208=20+++-----=0A=20= lisp/faces.el=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=2034=20= +++++++++++++++++++++++++---------=0A=20lisp/frame.el=20=20=20=20=20=20=20= =20=20=20=20=20=20=20|=2010=20+++-------=0A=20lisp/term/pc-win.el=20=20=20= =20=20=20=20=20|=20=208=20+++-----=0A=20lisp/term/rxvt.el=20=20=20=20=20=20= =20=20=20=20|=2012=20+++++-------=0A=20lisp/term/w32console.el=20=20=20=20= |=20=205=20++---=0A=20lisp/term/xterm.el=20=20=20=20=20=20=20=20=20|=20=20= 5=20++---=0A=20lisp/textmodes/css-mode.el=20|=2014=20++------------=0A=20= 9=20files=20changed,=2046=20insertions(+),=2054=20deletions(-)=0A=0Adiff=20= --git=20a/lisp/color.el=20b/lisp/color.el=0Aindex=20= 560631ae66..2385874028=20100644=0A---=20a/lisp/color.el=0A+++=20= b/lisp/color.el=0A@@=20-50,9=20+50,7=20@@=20color-name-to-rgb=0A=20= Optional=20argument=20FRAME=20specifies=20the=20frame=20where=20the=20= color=20is=20to=20be=0A=20displayed.=20=20If=20FRAME=20is=20omitted=20or=20= nil,=20use=20the=20selected=20frame.=0A=20If=20FRAME=20cannot=20display=20= COLOR,=20return=20nil."=0A-=20=20;;=20`colors-values'=20maximum=20value=20= is=20either=2065535=20or=2065280=20depending=20on=20the=0A-=20=20;;=20= display=20system.=20=20So=20we=20use=20a=20white=20conversion=20to=20get=20= the=20max=20value.=0A-=20=20(let=20((valmax=20(float=20(car=20= (color-values=20"#ffffffffffff")))))=0A+=20=20(let=20((valmax=20(float=20= (color-component-max=20frame))))=0A=20=20=20=20=20(mapcar=20(lambda=20= (x)=20(/=20x=20valmax))=20(color-values=20color=20frame))))=0A=20=0A=20= (defun=20color-rgb-to-hex=20=20(red=20green=20blue=20&optional=20= digits-per-component)=0Adiff=20--git=20a/lisp/facemenu.el=20= b/lisp/facemenu.el=0Aindex=20b10d874b21..119a2ba790=20100644=0A---=20= a/lisp/facemenu.el=0A+++=20b/lisp/facemenu.el=0A@@=20-621,9=20+621,7=20= @@=20list-colors-print=0A=20=09=09=09=09=09=09=20(downcase=20b))))))=0A=20= =09(setq=20color=20(list=20color)))=0A=20=20=20=20=20=20=20(let*=20= ((opoint=20(point))=0A-=09=20=20=20=20=20(color-values=20(color-values=20= (car=20color)))=0A-=09=20=20=20=20=20(light-p=20(>=3D=20(apply=20'max=20= color-values)=0A-=09=09=09=20=20(*=20(car=20(color-values=20"white"))=20= .5))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20(fg=20= (readable-foreground-color=20(car=20color))))=0A=20=09(insert=20(car=20= color))=0A=20=09(indent-to=2022)=0A=20=09(put-text-property=20opoint=20= (point)=20'face=20`(:background=20,(car=20color)))=0A@@=20-639,7=20= +637,7=20@@=20list-colors-print=0A=20=09(insert=20(propertize=0A=20=09=09= =20(apply=20'format=20"#%02x%02x%02x"=0A=20=09=09=09(mapcar=20(lambda=20= (c)=20(ash=20c=20-8))=0A-=09=09=09=09color-values))=0A+=09=09=09=09= (color-values=20(car=20color))))=0A=20=09=09=20'mouse-face=20'highlight=0A= =20=09=09=20'help-echo=0A=20=09=09=20(let=20((hsv=20(apply=20= 'color-rgb-to-hsv=0A@@=20-651,7=20+649,7=20@@=20list-colors-print=0A=20=09= =20=20=20opoint=20(point)=0A=20=09=20=20=20'follow-link=20t=0A=20=09=20=20= =20'mouse-face=20(list=20:background=20(car=20color)=0A-=09=09=09=20=20=20= =20=20:foreground=20(if=20light-p=20"black"=20"white"))=0A+=09=09=09=20=20= =20=20=20:foreground=20fg)=0A=20=09=20=20=20'color-name=20(car=20color)=0A= =20=09=20=20=20'action=20callback-fn)))=0A=20=20=20=20=20=20=20(insert=20= "\n"))=0Adiff=20--git=20a/lisp/faces.el=20b/lisp/faces.el=0Aindex=20= e707f6f4b6..2b9bcb9bcf=20100644=0A---=20a/lisp/faces.el=0A+++=20= b/lisp/faces.el=0A@@=20-1786,15=20+1786,22=20@@=20= defined-colors-with-face-attributes=0A=20=0A=20(defun=20= readable-foreground-color=20(color)=0A=20=20=20"Return=20a=20readable=20= foreground=20color=20for=20background=20COLOR."=0A-=20=20(let*=20((rgb=20= =20=20(color-values=20color))=0A-=09=20(max=20=20=20(apply=20#'max=20= rgb))=0A-=09=20(black=20(car=20(color-values=20"black")))=0A-=09=20= (white=20(car=20(color-values=20"white"))))=0A-=20=20=20=20;;=20Select=20= black=20or=20white=20depending=20on=20which=20one=20is=20less=20similar=20= to=0A-=20=20=20=20;;=20the=20brightest=20component.=0A-=20=20=20=20(if=20= (>=20(abs=20(-=20max=20black))=20(abs=20(-=20max=20white)))=0A-=09= "black"=0A-=20=20=20=20=20=20"white")))=0A+=20=20(if=20(color-dark-p=20= (color-name-to-rgb=20color))=20"white"=20"black"))=0A+=0A+(defun=20= color-dark-p=20(rgb)=0A+=20=20"Whether=20RGB=20is=20more=20readable=20= against=20white=20than=20black.=0A+RGB=20is=20a=203-element=20list=20(R=20= G=20B),=20each=20component=20in=20the=20range=20[0,1]."=0A+=20=20(let=20= ((r=20(nth=200=20rgb))=0A+=20=20=20=20=20=20=20=20(g=20(nth=201=20rgb))=0A= +=20=20=20=20=20=20=20=20(b=20(nth=202=20rgb)))=0A+=20=20=20=20(unless=20= (<=3D=200=20(min=20r=20g=20b)=20(max=20r=20g=20b)=201)=0A+=20=20=20=20=20= =20(error=20"RGB=20component=20not=20in=20[0,1]"))=0A+=20=20=20=20;;=20= Simple=20heuristic=20--=20correct=20luma=20requires=20gamma=20= correction,=0A+=20=20=20=20;;=20which=20is=20overkill=20for=20this=20= purpose.=0A+=20=20=20=20;;=20The=20cut-off=20value=20was=20designed=20to=20= make=20saturated=20green=20'light',=0A+=20=20=20=20;;=20but=20saturated=20= red=20and=20blue=20'dark'.=0A+=20=20=20=20(<=20(+=20(*=20r=200.299)=20(*=20= g=200.587)=20(*=20b=200.114))=0A+=20=20=20=20=20=20=200.58)))=0A=20=0A=20= (declare-function=20xw-color-defined-p=20"xfns.c"=20(color=20&optional=20= frame))=0A=20=0A@@=20-1840,6=20+1847,15=20@@=20color-values=0A=20=20=20=20= (t=0A=20=20=20=20=20(tty-color-values=20color=20frame))))=0A=20=0A= +(defun=20color-component-max=20(&optional=20frame)=0A+=20=20"The=20= highest=20value=20of=20a=20color=20component=20on=20FRAME.=0A+If=20FRAME=20= is=20omitted=20or=20nil,=20use=20the=20selected=20frame."=0A+=20=20;;=20= Right=20now,=20NS=20frames=20are=20the=20only=20ones=20having=20a=20= different=20maximum=0A+=20=20;;=20colour=20component=20value.=0A+=20=20= (if=20(eq=20(framep-on-display=20frame)=20'ns)=0A+=20=20=20=20=20=20= #xff00=0A+=20=20=20=20#xffff))=0A+=0A=20(defalias=20'x-color-values=20= 'color-values)=0A=20=0A=20(declare-function=20xw-display-color-p=20= "xfns.c"=20(&optional=20terminal))=0Adiff=20--git=20a/lisp/frame.el=20= b/lisp/frame.el=0Aindex=206c2f774709..fed46f333d=20100644=0A---=20= a/lisp/frame.el=0A+++=20b/lisp/frame.el=0A@@=20-1181,13=20+1181,9=20@@=20= frame-set-background-mode=0A=20=09=09=20=20=20non-default-bg-mode)=0A=20=09= =09=20=20((not=20(color-values=20bg-color=20frame))=0A=20=09=09=20=20=20= default-bg-mode)=0A-=09=09=20=20((>=3D=20(apply=20'+=20(color-values=20= bg-color=20frame))=0A-=09=09=20=20=20=20=20=20=20;;=20Just=20looking=20= at=20the=20screen,=20colors=20whose=0A-=09=09=20=20=20=20=20=20=20;;=20= values=20add=20up=20to=20.6=20of=20the=20white=20total=0A-=09=09=20=20=20= =20=20=20=20;;=20still=20look=20dark=20to=20me.=0A-=09=09=20=20=20=20=20=20= =20(*=20(apply=20'+=20(color-values=20"white"=20frame))=20.6))=0A-=09=09=20= =20=20'light)=0A-=09=09=20=20(t=20'dark)))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20((color-dark-p=20(color-name-to-rgb=20= bg-color=20frame))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20'dark)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(t=20= 'light)))=0A=20=09=20=20=20(display-type=0A=20=09=20=20=20=20(cond=20= ((null=20(window-system=20frame))=0A=20=09=09=20=20=20(if=20= (tty-display-color-p=20frame)=20'color=20'mono))=0Adiff=20--git=20= a/lisp/term/pc-win.el=20b/lisp/term/pc-win.el=0Aindex=20= 76a48a86c7..16eb660f00=20100644=0A---=20a/lisp/term/pc-win.el=0A+++=20= b/lisp/term/pc-win.el=0A@@=20-54,11=20+54,9=20@@=0A=20;;=20= DJGPP-compiled=20Emacs=20on=20the=20same=20PC.=20=20The=20names=20of=20X=20= colors=20used=20to=0A=20;;=20define=20the=20pixel=20values=20are=20shown=20= as=20comments=20to=20each=20color=20below.=0A=20;;;=0A-;;=20If=20you=20= want=20to=20change=20the=20RGB=20values,=20keep=20in=20mind=20that=20= various=20pieces=0A-;;=20of=20Emacs=20think=20that=20a=20color=20whose=20= RGB=20values=20add=20up=20to=20less=20than=200.6=20of=0A-;;=20the=20= values=20for=20WHITE=20(i.e.=20less=20than=20117963)=20are=20``dark'',=20= otherwise=20the=0A-;;=20color=20is=20``light'';=20see=20= `frame-set-background-mode'=20in=20lisp/faces.el=20for=0A-;;=20an=20= example.=0A+;;=20If=20you=20want=20to=20change=20the=20RGB=20values,=20= consider=20the=20heuristics=20in=0A+;;=20`color-dark-p'=20which=20is=20= used=20to=20select=20a=20suitably=20contrasting=0A+;;=20foreground=20or=20= background=20colour.=0A=20(defvar=20msdos-color-values=0A=20=20=20= '(("black"=20=20=20=20=20=20=20=20=20=200=20=20=20=20=200=20=20=20=20=20= 0=20=20=20=20=200)=0A=20=20=20=20=20("blue"=20=20=20=20=20=20=20=20=20=20= =201=20=20=20=20=200=20=20=20=20=200=2052480)=20;=20MediumBlue=0Adiff=20= --git=20a/lisp/term/rxvt.el=20b/lisp/term/rxvt.el=0Aindex=20= 31e3d6ede4..ebcb13db77=20100644=0A---=20a/lisp/term/rxvt.el=0A+++=20= b/lisp/term/rxvt.el=0A@@=20-206,13=20+206,11=20@@=20= rxvt-set-background-mode=0A=20=20=20=20=20=20=20;;=20The=20next=20line=20= assumes=20that=20rxvt-standard-colors=20are=20ordered=0A=20=20=20=20=20=20= =20;;=20by=20the=20color=20index=20in=20the=20ascending=20order!=0A=20=20= =20=20=20=20=20(setq=20rgb=20(car=20(cddr=20(nth=20bg=20= rxvt-standard-colors))))=0A-=20=20=20=20=20=20;;=20See=20the=20= commentary=20in=20frame-set-background-mode=20about=20the=0A-=20=20=20=20= =20=20;;=20computation=20below.=0A-=20=20=20=20=20=20(if=20(<=20(apply=20= '+=20rgb)=0A-=09=20=20=20=20=20;;=20The=20following=20line=20assumes=20= that=20white=20is=20the=2015th=0A-=09=20=20=20=20=20;;=20color=20in=20= rxvt-standard-colors.=0A-=09=20=20=20=20=20(*=20(apply=20'+=20(car=20= (cddr=20(nth=2015=20rxvt-standard-colors))))=200.6))=0A-=09=20=20= (set-terminal-parameter=20nil=20'background-mode=20'dark)))))=0A+=20=20=20= =20=20=20;;=20The=20following=20line=20assumes=20that=20white=20is=20the=20= 15th=0A+=20=20=20=20=20=20;;=20color=20in=20rxvt-standard-colors.=0A+=20=20= =20=20=20=20(let=20((comp-max=20(caddr=20(nth=2015=20= rxvt-standard-colors))))=0A+=20=20=20=20=20=20=20=20(when=20= (color-dark-p=20(mapcar=20(lambda=20(c)=20(/=20c=20comp-max))=20rgb))=0A= +=09=20=20(set-terminal-parameter=20nil=20'background-mode=20'dark))))))=0A= =20=0A=20(provide=20'term/rxvt)=0A=20=0Adiff=20--git=20= a/lisp/term/w32console.el=20b/lisp/term/w32console.el=0Aindex=20= 36e9d896c7..b249a4e602=20100644=0A---=20a/lisp/term/w32console.el=0A+++=20= b/lisp/term/w32console.el=0A@@=20-86,9=20+86,8=20@@=20= terminal-init-w32console=0A=20=20=20=20=20(setq=20r=20(nth=202=20descr)=0A= =20=09=20=20g=20(nth=203=20descr)=0A=20=09=20=20b=20(nth=204=20descr))=0A= -=20=20=20=20(if=20(<=20(+=20r=20g=20b)=20(*=20.6=20(+=2065535=2065535=20= 65535)))=0A-=09(setq=20bg-mode=20'dark)=0A-=20=20=20=20=20=20(setq=20= bg-mode=20'light))=0A+=20=20=20=20(setq=20bg-mode=20(if=20(color-dark-p=20= (list=20(/=20r=2065535)=20(/=20g=2065535)=20(/=20b=2065535)))=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20'dark=20= 'light))=0A=20=20=20=20=20(set-terminal-parameter=20nil=20= 'background-mode=20bg-mode))=0A=20=20=20(tty-set-up-initial-frame-faces)=0A= =20=20=20(run-hooks=20'terminal-init-w32-hook))=0Adiff=20--git=20= a/lisp/term/xterm.el=20b/lisp/term/xterm.el=0Aindex=20= 1a727e3933..bf9bcae526=20100644=0A---=20a/lisp/term/xterm.el=0A+++=20= b/lisp/term/xterm.el=0A@@=20-1120,9=20+1120,8=20@@=20= xterm-register-default-colors=0A=20=20=20=20=20(clear-face-cache)))=0A=20= =0A=20(defun=20xterm-maybe-set-dark-background-mode=20(redc=20greenc=20= bluec)=0A-=20=20;;=20Use=20the=20heuristic=20in=20= `frame-set-background-mode'=20to=20decide=20if=20a=0A-=20=20;;=20frame=20= is=20dark.=0A-=20=20(when=20(<=20(+=20redc=20greenc=20bluec)=20(*=20.6=20= (+=2065535=2065535=2065535)))=0A+=20=20(when=20(color-dark-p=20(mapcar=20= (lambda=20(c)=20(/=20c=2065535.0))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(list=20redc=20= greenc=20bluec)))=0A=20=20=20=20=20(set-terminal-parameter=20nil=20= 'background-mode=20'dark)=0A=20=20=20=20=20t))=0A=20=0Adiff=20--git=20= a/lisp/textmodes/css-mode.el=20b/lisp/textmodes/css-mode.el=0Aindex=20= eda739a397..2cd99787e8=20100644=0A---=20a/lisp/textmodes/css-mode.el=0A= +++=20b/lisp/textmodes/css-mode.el=0A@@=20-1149,17=20+1149,6=20@@=20= css--compute-color=0A=20=20=20=20;;=20Evaluate=20to=20the=20color=20if=20= the=20name=20is=20found.=0A=20=20=20=20((css--named-color=20start-point=20= match))))=0A=20=0A-(defun=20css--contrasty-color=20(name)=0A-=20=20= "Return=20a=20color=20that=20contrasts=20with=20NAME.=0A-NAME=20is=20of=20= any=20form=20accepted=20by=20`color-distance'.=0A-The=20returned=20color=20= will=20be=20usable=20by=20Emacs=20and=20will=20contrast=0A-with=20NAME;=20= in=20particular=20so=20that=20if=20NAME=20is=20used=20as=20a=20= background=0A-color,=20the=20returned=20color=20can=20be=20used=20as=20= the=20foreground=20and=20still=0A-be=20readable."=0A-=20=20;;=20See=20= bug#25525=20and=20bug#41544=20for=20a=20discussion=20of=20this.=0A-=20=20= (if=20(>=20(color-distance=20name=20"black")=20138500)=0A-=20=20=20=20=20= =20"black"=20"white"))=0A-=0A=20(defcustom=20css-fontify-colors=20t=0A=20= =20=20"Whether=20CSS=20colors=20should=20be=20fontified=20using=20the=20= color=20as=20the=20background.=0A=20When=20non-`nil',=20a=20text=20= representing=20CSS=20color=20will=20be=20fontified=0A@@=20-1199,7=20= +1188,8=20@@=20css--fontify-region=0A=20=09=09=20=20=20=20= (add-text-properties=0A=20=09=09=20=20=20=20=20start=20(point)=0A=20=09=09= =20=20=20=20=20(list=20'face=20(list=20:background=20color=0A-=09=09=09=09= =20=20=20=20=20=20=20:foreground=20(css--contrasty-color=20color)=0A+=09=09= =09=09=20=20=20=20=20=20=20:foreground=20(readable-foreground-color=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20color)=0A=20=09=09=09=09=20=20=20=20=20=20=20:box=20'(:line-width=20= -1))))))))))))=0A=20=20=20=20=20extended-region))=0A=20=0A--=20=0A2.21.1=20= (Apple=20Git-122.3)=0A=0A= --Apple-Mail=_7FF6E8CE-41E3-44BB-A837-E0A212C5FA1B Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_7FF6E8CE-41E3-44BB-A837-E0A212C5FA1B--