From c37b2cfdf9c5cbcba7cc174fcf8d6d17152c88a2 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Thu, 1 Sep 2022 13:02:27 +0000 Subject: [PATCH] Display a warning when using nil as a face attribute value. * src/xfaces.c (Finternal_set_lisp_face_attribute): Using the attribute value nil for the face attributes foreground, distant-foreground and background is a backward compatibility feature, that works only with existing frames. Using it with frame = t (and therefore also with frame = nil) will not produce the expected effect. Display a warning in these cases. --- src/xfaces.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/xfaces.c b/src/xfaces.c index 70d5cbeb4c..db7bc028c5 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -3051,6 +3051,22 @@ DEFUN ("internal-copy-lisp-face", Finternal_copy_lisp_face, return to; } +char warning_attribute_nil[] = + "Warning: using :%s nil with frame t has no effect."; + +#define WARNING_ATTRIBUTE_NIL(S) \ + if (NILP (value) && EQ (frame, Qt)) \ + { \ + if (redisplaying_p) \ + CALLN (Fmessage, \ + build_string (warning_attribute_nil), \ + build_string (S)); \ + else \ + Fsignal (Quser_error, \ + list1 (CALLN (Fformat, \ + build_string (warning_attribute_nil), \ + build_string (S)))); \ + } DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute, Sinternal_set_lisp_face_attribute, 3, 4, 0, @@ -3390,6 +3406,7 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute, } else if (EQ (attr, QCforeground)) { + WARNING_ATTRIBUTE_NIL ("foreground"); /* Compatibility with 20.x. */ if (NILP (value)) value = Qunspecified; @@ -3409,6 +3426,7 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute, } else if (EQ (attr, QCdistant_foreground)) { + WARNING_ATTRIBUTE_NIL ("distant-foreground"); /* Compatibility with 20.x. */ if (NILP (value)) value = Qunspecified; @@ -3428,6 +3446,7 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute, } else if (EQ (attr, QCbackground)) { + WARNING_ATTRIBUTE_NIL ("background"); /* Compatibility with 20.x. */ if (NILP (value)) value = Qunspecified; -- 2.35.1