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: Wed, 3 Jun 2020 22:08:46 +0200 Message-ID: <624D7FB8-A836-4A7E-8895-47E867214504@acm.org> References: <5C4A633D-8222-4439-BE37-9B8674F1DA6D@acm.org> <87r1v2aat3.fsf@tromey.com> <9902865C-01B4-4E50-A433-DBC8B8311234@acm.org> <83tuzueogo.fsf@gnu.org> <6272275C-560C-4437-90F1-2A8294D27019@acm.org> <83o8q2elja.fsf@gnu.org> <83mu5mel4o.fsf@gnu.org> <77F1DDD3-A69F-40ED-902D-74986D5E6596@acm.org> <83y2p5cumz.fsf@gnu.org> <83blm0cjlz.fsf@gnu.org> <83367ccf8w.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_7AF097D7-D9EE-4CBA-891D-80A035FB968B" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="27060"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Tom Tromey , Simon Pugnet , 41544@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 03 22:09:27 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 1jgZhX-0006yr-BU for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Jun 2020 22:09:27 +0200 Original-Received: from localhost ([::1]:32776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgZhV-00065Y-Rc for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Jun 2020 16:09:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgZh9-00065J-Iq for bug-gnu-emacs@gnu.org; Wed, 03 Jun 2020 16:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgZh8-00060W-CO for bug-gnu-emacs@gnu.org; Wed, 03 Jun 2020 16:09:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jgZh7-00011E-Os for bug-gnu-emacs@gnu.org; Wed, 03 Jun 2020 16:09:01 -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: Wed, 03 Jun 2020 20:09:01 +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.15912149413910 (code B ref 41544); Wed, 03 Jun 2020 20:09:01 +0000 Original-Received: (at 41544) by debbugs.gnu.org; 3 Jun 2020 20:09:01 +0000 Original-Received: from localhost ([127.0.0.1]:44604 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgZh6-00010z-8v for submit@debbugs.gnu.org; Wed, 03 Jun 2020 16:09:01 -0400 Original-Received: from mail1450c50.megamailservers.eu ([91.136.14.50]:58488 helo=mail265c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgZh3-00010i-4j for 41544@debbugs.gnu.org; Wed, 03 Jun 2020 16:08:58 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1591214930; bh=VXRY4nZ1v/WVsQgi2nckWUmQ57pZbckp5Au97+Hfj3w=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=e4zxEn/xUpFzPXawNEFUOv0LmtV7YR6e9R00vMrZHccEI1gHPCa4sIKC8CSrrupEb BrJZRFWGo3p565i/gbSKUdihlO2vnTUEZAmE6GnutfQul4MbL3YoobOEVPFxmiQpe3 n2NABf/22LDIACCsrNr+67pQ9yjNuC6+gdqMb9vc= 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 mail265c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 053K8kT7016642; Wed, 3 Jun 2020 20:08:48 +0000 In-Reply-To: <83367ccf8w.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F28.5ED802FF.003B: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=D5w51cZj c=1 sm=1 tr=0 a=klNLuyVZdLUgl+K5Uafb2A==:117 a=klNLuyVZdLUgl+K5Uafb2A==:17 a=M51BFTxLslgA:10 a=mDV3o1hIAAAA:8 a=vWmk6DFq9m4vw4mpYXoA:9 a=CjuIK1q_8ugA:10 a=BcT7ibRjUQrrFaFC1yUA:9 a=B2y7HmGcmWMA:10 a=_FVE-zBwftR9WsbkzFJk: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:181475 Archived-At: --Apple-Mail=_7AF097D7-D9EE-4CBA-891D-80A035FB968B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 3 juni 2020 kl. 17.59 skrev Eli Zaretskii : > Then I think we should install it. Thank you; pushed to master. Now about the consolidation of the contrast colour predicate = (color-dark-p): as described previously in detail, the current code for = doing so in various places is unsatisfactory. For example, some of the = methods employed classify #00ff00 as a "dark" colour, leading to = suboptimal results. (Try typing #00ff00 in css-mode.) There are other bugs that are annoying in themselves, but need to be = fixed in order to make progress. Start Emacs in TTY mode with = TERM=3Dxterm-color and evaluate (color-name-to-rgb "blue"). Notice how = one of the components is greater than 1 -- this is the unfortunate = result of several bad decisions. The attached patch supersedes the previous one; after staring at colour = combinations I came to the conclusion that gamma-expansion is a = necessity, but the exact sRGB composite gamma curve isn't quite = necessary, and a power of 2.2 is close enough. It also uses a contrasting text colour for the first column in = list-colors-display, which serves as a good demonstration of how the = predicate works for the standard named colours. --Apple-Mail=_7AF097D7-D9EE-4CBA-891D-80A035FB968B 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=20f328bda216f06dd2daff6098c6d60e128da2ef67=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|=2011=20+++++------=0A=20= lisp/faces.el=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=2036=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= =205=20++---=0A=20lisp/textmodes/css-mode.el=20|=2014=20++------------=0A= =209=20files=20changed,=2050=20insertions(+),=2055=20deletions(-)=0A=0A= diff=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..419b76101b=20100644=0A---=20= a/lisp/facemenu.el=0A+++=20b/lisp/facemenu.el=0A@@=20-621,12=20+621,11=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-=09(put-text-property=20opoint=20= (point)=20'face=20`(:background=20,(car=20color)))=0A+=09= (put-text-property=20opoint=20(point)=20'face=20`(:background=20,(car=20= 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:foreground=20,fg))=0A=20=09(put-text-property=0A=20=09=20= (prog1=20(point)=0A=20=09=20=20=20(insert=20"=20")=0A@@=20-639,7=20= +638,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+650,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..5958427946=20100644=0A---=20a/lisp/faces.el=0A+++=20= b/lisp/faces.el=0A@@=20-1786,15=20+1786,24=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= ((sr=20(nth=200=20rgb))=0A+=20=20=20=20=20=20=20=20=20(sg=20(nth=201=20= rgb))=0A+=20=20=20=20=20=20=20=20=20(sb=20(nth=202=20rgb))=0A+=20=20=20=20= =20=20=20=20=20;;=20Use=20the=20power=202.2=20as=20an=20approximation=20= to=20sRGB=20gamma;=0A+=20=20=20=20=20=20=20=20=20;;=20it=20should=20be=20= good=20enough=20for=20the=20purpose=20of=20this=20function.=0A+=20=20=20=20= =20=20=20=20=20(r=20(expt=20sr=202.2))=0A+=20=20=20=20=20=20=20=20=20(g=20= (expt=20sg=202.2))=0A+=20=20=20=20=20=20=20=20=20(b=20(expt=20sb=20= 2.2)))=0A+=20=20=20=20(unless=20(<=3D=200=20(min=20r=20g=20b)=20(max=20r=20= g=20b)=201)=0A+=20=20=20=20=20=20(error=20"RGB=20components=20%S=20not=20= in=20[0,1]"=20rgb))=0A+=20=20=20=20;;=20The=20cut-off=20value=20was=20= determined=20experimentally;=20see=20bug#41544.=0A+=20=20=20=20(<=20(+=20= (*=20r=200.299)=20(*=20g=200.587)=20(*=20b=200.114))=0A+=20=20=20=20=20=20= =20(eval-when-compile=20(expt=200.6=202.2)))))=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+1849,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= 0035c5e7b0..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=20for=20a=20discussion=20of=20this.=0A-=20=20(if=20(>=20= (color-distance=20name=20"black")=20292485)=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=20color=20= as=20the=20background.=0A=20When=20non-`nil',=20a=20text=20representing=20= CSS=20color=20will=20be=20fontified=0A@@=20-1199,7=20+1188,8=20@@=20= css--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=_7AF097D7-D9EE-4CBA-891D-80A035FB968B--