From: Gregory Heytings <gregory@heytings.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 57499-done@debbugs.gnu.org
Subject: bug#57499: Documentation bug in the docstring of set-face-attribute?
Date: Thu, 01 Sep 2022 19:35:35 +0000 [thread overview]
Message-ID: <f61b9c26193de0f82592@heytings.org> (raw)
In-Reply-To: <83k06nq7es.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 532 bytes --]
>
> It isn't deprecated, it's invalid. There's no need to have anything
> like this in NEWS, because all our documentation says the color
> attributes can have only string values (in addition to 'unspecified').
>
Okay (I thought you wanted to retain the "undocumented but not really
invalid" use of nil).
>
> Warning: nil value for `%s' is invalid, use 'unspecified instead.
>
I added the name of the face in the message, which is I think useful to
locate the cause of the warning.
Should this go to master or to emacs-28?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Display-a-warning-for-some-uses-of-nil-in-face-attri.patch --]
[-- Type: text/x-diff; name=Display-a-warning-for-some-uses-of-nil-in-face-attri.patch, Size: 2531 bytes --]
From cbe76f8959bc1c7713ae84ab657adb3bbf0c4fde Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Thu, 1 Sep 2022 19:31:34 +0000
Subject: [PATCH] Display a warning for some uses of nil in face attributes.
* src/xfaces.c (HANDLE_INVALID_NIL_VALUE): New macro, which displays
a warning for invalid uses of nil as a face attribute value.
(Finternal_set_lisp_face_attribute): Use the macro for the attributes
:foreground, :distant-foreground and :background.
---
src/xfaces.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/xfaces.c b/src/xfaces.c
index 70d5cbeb4c..539f50bce9 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -3052,6 +3052,15 @@ DEFUN ("internal-copy-lisp-face", Finternal_copy_lisp_face,
}
+#define HANDLE_INVALID_NIL_VALUE(A,F) \
+ if (NILP (value)) \
+ { \
+ add_to_log ("Warning: setting attribute `%s' of face `%s': nil " \
+ "value is invalid, use 'unspecified instead.", A, F); \
+ /* Compatibility with 20.x. */ \
+ value = Qunspecified; \
+ }
+
DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute,
Sinternal_set_lisp_face_attribute, 3, 4, 0,
doc: /* Set attribute ATTR of FACE to VALUE.
@@ -3390,9 +3399,7 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute,
}
else if (EQ (attr, QCforeground))
{
- /* Compatibility with 20.x. */
- if (NILP (value))
- value = Qunspecified;
+ HANDLE_INVALID_NIL_VALUE (QCforeground, face);
if (!UNSPECIFIEDP (value)
&& !IGNORE_DEFFACE_P (value)
&& !RESET_P (value))
@@ -3409,9 +3416,7 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute,
}
else if (EQ (attr, QCdistant_foreground))
{
- /* Compatibility with 20.x. */
- if (NILP (value))
- value = Qunspecified;
+ HANDLE_INVALID_NIL_VALUE (QCdistant_foreground, face);
if (!UNSPECIFIEDP (value)
&& !IGNORE_DEFFACE_P (value)
&& !RESET_P (value))
@@ -3428,9 +3433,7 @@ DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute,
}
else if (EQ (attr, QCbackground))
{
- /* Compatibility with 20.x. */
- if (NILP (value))
- value = Qunspecified;
+ HANDLE_INVALID_NIL_VALUE (QCbackground, face);
if (!UNSPECIFIEDP (value)
&& !IGNORE_DEFFACE_P (value)
&& !RESET_P (value))
--
2.35.1
next prev parent reply other threads:[~2022-09-01 19:35 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-31 8:14 bug#57499: Documentation bug in the docstring of set-face-attribute? Gregory Heytings
2022-08-31 8:17 ` Gregory Heytings
2022-08-31 11:11 ` Eli Zaretskii
2022-08-31 12:04 ` Gregory Heytings
2022-08-31 12:39 ` Eli Zaretskii
2022-08-31 12:53 ` Gregory Heytings
2022-08-31 13:06 ` Eli Zaretskii
2022-08-31 13:43 ` Gregory Heytings
2022-08-31 16:11 ` Eli Zaretskii
2022-08-31 18:33 ` Gregory Heytings
2022-08-31 19:13 ` Eli Zaretskii
2022-08-31 19:33 ` Gregory Heytings
2022-08-31 19:49 ` Eli Zaretskii
2022-08-31 21:13 ` Gregory Heytings
2022-09-01 7:04 ` Eli Zaretskii
2022-09-01 8:25 ` Gregory Heytings
2022-09-01 8:44 ` Eli Zaretskii
2022-09-01 9:02 ` Gregory Heytings
2022-09-01 11:33 ` Eli Zaretskii
2022-09-01 11:56 ` Gregory Heytings
2022-09-01 12:08 ` Eli Zaretskii
2022-09-01 13:15 ` Gregory Heytings
2022-09-01 14:56 ` Eli Zaretskii
2022-09-01 17:07 ` Gregory Heytings
2022-09-01 18:24 ` Eli Zaretskii
2022-09-01 19:35 ` Gregory Heytings [this message]
2022-09-02 16:00 ` Eli Zaretskii
2022-09-02 20:48 ` Gregory Heytings
2022-09-03 6:00 ` Eli Zaretskii
2022-09-03 6:43 ` Gregory Heytings
2022-09-03 1:26 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f61b9c26193de0f82592@heytings.org \
--to=gregory@heytings.org \
--cc=57499-done@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).