emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 63d0dc7: Allow control on the threshold for using '


From: Eli Zaretskii
Subject: [Emacs-diffs] master 63d0dc7: Allow control on the threshold for using 'distant-foreground'
Date: Fri, 1 Mar 2019 03:38:27 -0500 (EST)

branch: master
commit 63d0dc7937bddd803145f2df23a600597c4fd8e7
Author: Federico Tedin <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Allow control on the threshold for using 'distant-foreground'
    
    * src/xfaces.c (NEAR_SAME_COLOR_THRESHOLD): Macro deleted.
    (load_face_colors): Compare against
    face_near_same_color_threshold instead of
    NEAR_SAME_COLOR_THRESHOLD.
    (syms_of_xfaces) <face-near-same-color-threshold>: New
    variable.  (Bug#34001)
    
    * etc/NEWS: Announce the change.
---
 etc/NEWS     |  7 +++++++
 src/xfaces.c | 15 ++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 683a427..29ed7ab 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -145,6 +145,13 @@ EMACS_SOCKET_NAME environment variable to an appropriate 
value.
 *** When run by root, emacsclient no longer connects to non-root sockets.
 (Instead you can use Tramp methods to run root commands in a non-root Emacs.)
 
+---
+** Control of the threshold for using the 'distant-foreground' color.
+The threshold for color distance below which the 'distant-foreground'
+color of the face will be used instead of the foreground color can now
+be controlled via the new variable 'face-near-same-color-threshold'.
+The default value is 30000, as the previously hard-coded threshold.
+
 +++
 ** The function 'read-passwd' uses '*' as default character to hide passwords.
 
diff --git a/src/xfaces.c b/src/xfaces.c
index 3ba824b..69e73e8 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1157,8 +1157,6 @@ load_color (struct frame *f, struct face *face, 
Lisp_Object name,
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-#define NEAR_SAME_COLOR_THRESHOLD 30000
-
 /* Load colors for face FACE which is used on frame F.  Colors are
    specified by slots LFACE_BACKGROUND_INDEX and LFACE_FOREGROUND_INDEX
    of ATTRS.  If the background color specified is not supported on F,
@@ -1199,7 +1197,7 @@ load_face_colors (struct frame *f, struct face *face,
 
   dfg = attrs[LFACE_DISTANT_FOREGROUND_INDEX];
   if (!NILP (dfg) && !UNSPECIFIEDP (dfg)
-      && color_distance (&xbg, &xfg) < NEAR_SAME_COLOR_THRESHOLD)
+      && color_distance (&xbg, &xfg) < face_near_same_color_threshold)
     {
       if (EQ (attrs[LFACE_INVERSE_INDEX], Qt))
         face->background = load_color (f, face, dfg, LFACE_BACKGROUND_INDEX);
@@ -6799,6 +6797,17 @@ RESCALE-RATIO is a floating point number to specify how 
much larger
 a font of 10 point, we actually use a font of 10 * RESCALE-RATIO point.  */);
   Vface_font_rescale_alist = Qnil;
 
+  DEFVAR_INT ("face-near-same-color-threshold", face_near_same_color_threshold,
+             doc: /* Threshold for using distant-foreground color instead of 
foreground.
+
+The value should be an integer number providing the minimum distance
+between two colors that will still qualify them to be used as foreground
+and background.  If the value of `color-distance', invoked with a nil
+METRIC argument, for the foreground and background colors of a face is
+less than this threshold, the distant-foreground color, if defined,
+will be used for the face instead of the foreground color.  */);
+  face_near_same_color_threshold = 30000;
+
 #ifdef HAVE_WINDOW_SYSTEM
   defsubr (&Sbitmap_spec_p);
   defsubr (&Sx_list_fonts);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]