From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Re: About the :distant-foreground face attribute Date: Mon, 13 Jan 2014 10:41:36 -0800 Message-ID: <52D43360.6050605@dancol.org> References: <87bnzo9cja.fsf@gnu.org> <59B7E7FC-48D0-4737-B1BB-FFAC5BA9E07A@swipnet.se> <874n5f3162.fsf@gnu.org> <83fvozf86g.fsf@gnu.org> <87r48javwe.fsf@gnu.org> <83bnzmfjxe.fsf@gnu.org> <52D3E689.6050902@dancol.org> <8E16225F-53EF-498A-AB35-66EB9B33B859@swipnet.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1389638508 3114 80.91.229.3 (13 Jan 2014 18:41:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 13 Jan 2014 18:41:48 +0000 (UTC) Cc: Eli Zaretskii , Chong Yidong , emacs-devel To: =?ISO-8859-1?Q?Jan_Dj=E4rv?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 13 19:41:56 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W2mSO-00051i-OV for ged-emacs-devel@m.gmane.org; Mon, 13 Jan 2014 19:41:52 +0100 Original-Received: from localhost ([::1]:44524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2mSO-0000v8-CL for ged-emacs-devel@m.gmane.org; Mon, 13 Jan 2014 13:41:52 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2mSK-0000uQ-VO for emacs-devel@gnu.org; Mon, 13 Jan 2014 13:41:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2mSJ-0000xz-JA for emacs-devel@gnu.org; Mon, 13 Jan 2014 13:41:48 -0500 Original-Received: from dancol.org ([2600:3c01::f03c:91ff:fedf:adf3]:53920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2mSG-0000wm-MJ; Mon, 13 Jan 2014 13:41:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References:Subject:CC:To:MIME-Version:From:Date:Message-ID; bh=f32BHrDi1uN8y/fs6PHJ928shXdgfeeX3X5xHI8llaQ=; b=Woc69MPH9zau41Jm42Q5TpAPhOmlqAHTf11S0XvUp8Ddzcn81wVuzSNTHM120tSgKTrJFTwaZX3YVul5f24qA5NauSgnoz4hWLJq5iXe2Qw//UBiWer5jrHzDbFnIC+cZS3ey2JunZ0+zu+V5qN1jhbJD37wM3ElzIMrJT9dANrRtVbos9EVdaDC7reCdaukuaTTfldvklmG8gxlI3att0qunIgXBQKSBO295aHnC5TaLVm8EJNR5CIvYBnSgge4D5E9nApMY/3m1qa4/4F0uf9uYEzmbAHny+JRSL8UIvOkDVOhACH3o0yaawivDmC6JhdCHjyp7NhuiAle37f89Q==; Original-Received: from [2620:0:1cfe:99::7] by dancol.org with esmtpsa (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1W2mSE-0000Rg-Tb; Mon, 13 Jan 2014 10:41:42 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <8E16225F-53EF-498A-AB35-66EB9B33B859@swipnet.se> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2600:3c01::f03c:91ff:fedf:adf3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:168308 Archived-At: On 01/13/2014 08:33 AM, Jan Djärv wrote: > 13 jan 2014 kl. 14:13 skrev Daniel Colascione : > >> The attached patch might be another solution to the problem. It replaces :distant-foreground with :contrast-function, which punts the actual contrast logic to lisp by calling the named function during face realization. (Performance isn't a problem in practice because we cache face realizations.) In lisp, we implement four low-contrast-mitigation policies: do not adjust for contrast, adjust automatically (by adjusting CIE L*A*B color space L values), adjust automatically (by adjusting the V values in HSV color space), or just set the foreground to a specific color if the contrast dips below a certain point (the current :distant-foreground behavior). Both the policy and the parameters (well, the override color) are customizable on a per-face basis; when merging faces, the one with the hig hest priority sets the whole behavior. > > The main complaint (as I see it) was that a new attribute was added. So does this. No. The main complaint is that we're adding a brittle face attribute with a very confusing name, not that just that we're adding an attribute. This patch allows for flexible policy and treats face foreground and background colors identically. >> The patch uses the CIE L*A*B colorspace algorithm by default. > > Do not change the defaults please. Reinstate the > *_selection_fg_color. They are system defined and should be honored. There are two sane defaults: the 24.3 behavior, where we always use the system selection foreground and background, and my proposed behavior, where we use the fontified foreground and automatically adjust it so that it's legible. The current behavior is worse because it uses the system selection foreground only sometimes and doesn't preserve theme hues when possible. > >> It produces surprisingly good results, at least in my tests, adapting automatically to light and dark backgrounds while preserving the hues of theme foreground colors. >> >> (Changing themes nukes the face property right now, so you'll have to reset it each time.) >> > > > @@ -1070,7 +1070,8 @@ > (:foreground . "foreground color") > (:background . "background color") > (:stipple . "background stipple") > - (:inherit . "inheritance")) > + (:inherit . "inheritance") > + (:contrast-function "contrast function")) > "An alist of descriptive names for face attributes. > Each element has the form (ATTRIBUTE-NAME . DESCRIPTION) where > ATTRIBUTE-NAME is a face attribute name (a keyword symbol), and > @@ -1351,7 +1352,6 @@ > > > There is a . missing after :contrast-function. Thanks. > Have you checked that no event handling code accesses a face > fore/background? You can not call a lisp function in that context. We only run this code when we're realizing faces, not when we're just accessing their attributes. We call lisp from merge_face_heights in the same context, so this use should be safe as well.