From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!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: Fri, 21 Aug 2020 13:32:14 +0200 Message-ID: References: <5C4A633D-8222-4439-BE37-9B8674F1DA6D@acm.org> <83r1us8kw6.fsf@gnu.org> <020DE875-14A8-457A-9AE4-AA0925DB8997@acm.org> <83img48ffx.fsf@gnu.org> <83bllw82xt.fsf@gnu.org> <1B0F31C8-1E11-4527-A053-DD2DE8235F58@acm.org> <83wo4g5hz6.fsf@gnu.org> <49B7D7B5-D9E3-4E97-A749-CF5E8D8EE2C6@acm.org> <83mu5b5573.fsf@gnu.org> <83lfku69q2.fsf@gnu.org> <87eeo4m5kd.fsf@gnus.org> <83d03of3pf.fsf@gnu.org> <87blj8kpsr.fsf@gnus.org> <838secf1mq.fsf@gnu.org> <87zh6r7xlf.fsf@gnus.org> <837dtuelhr.fsf@gnu.org> <87sgciznhy.fsf@gnus.org> <83sgcid0ap.fsf@gnu.org> <87tuwxwjkr.fsf@gnus.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_277FAD2E-6E8F-4BDC-B57C-7B32ADD3A2E0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32592"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41544@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 21 13:49:19 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 1k95Xp-0008KR-81 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Aug 2020 13:49:18 +0200 Original-Received: from localhost ([::1]:60106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k95Xo-0005tx-9O for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Aug 2020 07:49:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k95I6-0001tN-Qs for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2020 07:33:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k95I6-0001WC-FF for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2020 07:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k95I6-0005aT-C0 for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2020 07:33: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: Fri, 21 Aug 2020 11:33: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.159800954219939 (code B ref 41544); Fri, 21 Aug 2020 11:33:02 +0000 Original-Received: (at 41544) by debbugs.gnu.org; 21 Aug 2020 11:32:22 +0000 Original-Received: from localhost ([127.0.0.1]:45161 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k95HR-0005BA-I5 for submit@debbugs.gnu.org; Fri, 21 Aug 2020 07:32:21 -0400 Original-Received: from mail205c50.megamailservers.eu ([91.136.10.215]:42244 helo=mail193c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k95HP-00058a-PM for 41544@debbugs.gnu.org; Fri, 21 Aug 2020 07:32:20 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1598009537; bh=Swbe7d+7ctMmBqjLyE26S1n5bF84A2mSLYTRPHcqtMw=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=jdZM/KWIK5DuGOLjGpti5QzoU0BLCPf+Ow6RX1aHC1Mg+8oiUx40FyUXVw+gUyScn Ie1pgkrkNSxLYkT6iPT5kzgM4/YKojB7Ptecl1b/hJmpduQr0+3Na+/8CGUWS3FMVK 0BYljgRrHR4Xkqz/muKiL0fqNk/3abXFn2+l1Zck= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail193c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 07LBWFuE011994; Fri, 21 Aug 2020 11:32:16 +0000 In-Reply-To: <87tuwxwjkr.fsf@gnus.org> X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F25.5F3FB0C1.00A0, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=cM2eTWWN c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=OocQHUDgAAAA:8 a=_ChZKkyvCguCiKtrDYIA:9 a=CjuIK1q_8ugA:10 a=UmfJOHRxoQaBqsDoL6wA:9 a=De_Ol2h6w80A:10 a=xUZTl98r3Qw_uB5NK3jt:22 X-Origin-Country: SE 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:185841 Archived-At: --Apple-Mail=_277FAD2E-6E8F-4BDC-B57C-7B32ADD3A2E0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 20 aug. 2020 kl. 15.08 skrev Lars Ingebrigtsen : > Mattias? I don't want to revive this discussion and consider the matter settled, = but since you asked: Suppose we add standard-colour-darkness-predicate, say, with = color-dark-p being the default and (r+b+g)/3<0.6 the 'traditional' = option (or the default, if you prefer). How would the effects of that = choice be explained to the user? A difference is only visible when: 1. a face sensitive to the background mode is used (many standard faces = are), and 2. a background colour used that is judged differently by the available = predicates Most reasonable backgrounds are either too light or too dark to pass the = latter criterion, but people's idea of what is reasonable varies. For = instance, black-on-green text is somewhat readable, but emacs -bg green -fg black will give mostly bad default faces (for instance, the minibuffer prompt = is almost invisible). With color-dark-p it becomes workable (attached = diff). Whether this is reason enough to add a defcustom is something I won't = comment on. I doubt anyone will change it, whatever the default would = be. --Apple-Mail=_277FAD2E-6E8F-4BDC-B57C-7B32ADD3A2E0 Content-Disposition: attachment; filename=dark.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="dark.diff" Content-Transfer-Encoding: 7bit diff --git a/lisp/frame.el b/lisp/frame.el index 081d3010e9..75e7f74209 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1198,13 +1198,10 @@ frame-set-background-mode non-default-bg-mode) ((not (color-values bg-color frame)) default-bg-mode) - ((>= (apply '+ (color-values bg-color frame)) - ;; Just looking at the screen, colors whose - ;; values add up to .6 of the white total - ;; still look dark to me. - (* (apply '+ (color-values "white" frame)) .6)) - 'light) - (t 'dark))) + ((color-dark-p (mapcar (lambda (c) (/ c 65535.0)) + (color-values bg-color frame))) + 'dark) + (t 'light))) (display-type (cond ((null (window-system frame)) (if (tty-display-color-p frame) 'color 'mono)) diff --git a/lisp/term/rxvt.el b/lisp/term/rxvt.el index 31e3d6ede4..793512105a 100644 --- a/lisp/term/rxvt.el +++ b/lisp/term/rxvt.el @@ -208,10 +208,7 @@ rxvt-set-background-mode (setq rgb (car (cddr (nth bg rxvt-standard-colors)))) ;; See the commentary in frame-set-background-mode about the ;; computation below. - (if (< (apply '+ rgb) - ;; The following line assumes that white is the 15th - ;; color in rxvt-standard-colors. - (* (apply '+ (car (cddr (nth 15 rxvt-standard-colors)))) 0.6)) + (if (color-dark-p (mapcar (lambda (c) (/ c 255.0)) rgb)) (set-terminal-parameter nil 'background-mode 'dark))))) (provide 'term/rxvt) diff --git a/lisp/term/w32console.el b/lisp/term/w32console.el index 36e9d896c7..66680af44b 100644 --- a/lisp/term/w32console.el +++ b/lisp/term/w32console.el @@ -86,7 +86,7 @@ terminal-init-w32console (setq r (nth 2 descr) g (nth 3 descr) b (nth 4 descr)) - (if (< (+ r g b) (* .6 (+ 65535 65535 65535))) + (if (color-dark-p (mapcar (lambda (c) (/ c 65535.0)) (list r g b))) (setq bg-mode 'dark) (setq bg-mode 'light)) (set-terminal-parameter nil 'background-mode bg-mode)) diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index 1a727e3933..d71297d811 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el @@ -1122,7 +1122,8 @@ xterm-register-default-colors (defun xterm-maybe-set-dark-background-mode (redc greenc bluec) ;; Use the heuristic in `frame-set-background-mode' to decide if a ;; frame is dark. - (when (< (+ redc greenc bluec) (* .6 (+ 65535 65535 65535))) + (when (color-dark-p (mapcar (lambda (c) (/ c 65535.0)) + (list redc greenc bluec))) (set-terminal-parameter nil 'background-mode 'dark) t)) --Apple-Mail=_277FAD2E-6E8F-4BDC-B57C-7B32ADD3A2E0--