diff options
author | Federico Tedin <federicotedin@gmail.com> | 2019-01-15 22:08:15 -0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2019-03-01 10:36:59 +0200 |
commit | 63d0dc7937bddd803145f2df23a600597c4fd8e7 (patch) | |
tree | 688dec6e5162e5d6ee4fbd6b346e96014a41e9b4 | |
parent | 44b7436d4408ddfb72c1758d60395872791ae00d (diff) | |
download | emacs-63d0dc7937bddd803145f2df23a600597c4fd8e7.tar.gz |
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.
-rw-r--r-- | etc/NEWS | 7 | ||||
-rw-r--r-- | src/xfaces.c | 15 |
2 files changed, 19 insertions, 3 deletions
@@ -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 3ba824b6517..69e73e8c0dd 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); |