From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Felix Dietrich Newsgroups: gmane.emacs.help Subject: Re: how to track down "invalid face attribute" errors? Date: Mon, 03 Oct 2022 21:19:41 +0200 Message-ID: <87wn9g4svm.fsf@sperrhaken.name> References: <87k05rr79k.fsf@ucl.ac.uk> <87czbjpq1c.fsf@dataswamp.org> <87r0zudtve.fsf@dataswamp.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16203"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 03 21:28:02 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofR6e-0003uF-Kr for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 03 Oct 2022 21:28:00 +0200 Original-Received: from localhost ([::1]:60674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ofR6d-0006oJ-HI for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 03 Oct 2022 15:27:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofQyn-0002we-VV for help-gnu-emacs@gnu.org; Mon, 03 Oct 2022 15:19:54 -0400 Original-Received: from mout.kundenserver.de ([212.227.17.13]:43721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofQym-0001vI-8g for help-gnu-emacs@gnu.org; Mon, 03 Oct 2022 15:19:53 -0400 Original-Received: from localhost ([89.12.94.204]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mlvmv-1p56xj3O5b-00ixzN for ; Mon, 03 Oct 2022 21:19:48 +0200 In-Reply-To: <87r0zudtve.fsf@dataswamp.org> (Emanuel Berg's message of "Thu, 29 Sep 2022 18:32:05 +0200") X-Provags-ID: V03:K1:8UjPuanz34WWVvIHpvRD/TkdnK4YRByVrT5uI2srn78D9npsWlX moiiQ+s3PquuWn850eJPPFNwmdTHaHvxTYBH9jm3ZspQvghFO6d2uK04Cm2VJ2fdVKQc1pP G7LwSpCp4tLqkQXlBOkszb+hHRPyISk77ALKf+vtfyuQjFZMdp6PjYcsqfLGFWoyqhVQXub +wC232dOL/YmUaonVXJkA== X-UI-Out-Filterresults: notjunk:1;V03:K0:ClDwb5i1bEo=:TkitKuqVIuj+2/qkF1KFKy T1GqKQipLAlp0CKEHswSFqqsyfllzGqsTujm1sMS+rGz5xcMEHA6Bf3qrNC7gE/r8W4f6x6Zz oE1JoPJERb+jtVC+cL229NLmLtr/D+6lQjsqz9S+RtwRmijqV3hlDfB1kiRi9XM4+CwQMoTGt gPwYvQd8ehwOPBE/JTqMir3Az+hC3VA4KE+mtf94W9oIGYm/eBRU1rwZgAT9R1w2roaNMkrto m9G9B/Bk0pSDBSYa1zGP1LlPuSB1BU4q6W2hWtKvmoP36+VaLBh3YUAtribKcPqj9cdGGRRIR 8RvAZw80etP1HNxO9UPkY25EZ/zfxOsakBm6+wzx2YERYERIQo0wtTJZ5bvopf+55ccFNHpnr cRW+dJNZTFUVdStEazCA8sreh09+SaXz/JTq/7EClSaJ9MC2SmDyt27Enuefv5PDuINyHd0u+ v4ttjAOHBA2wqubN3rz5PBpkDa74tN7D4nlh2nAhrdFmg4lACGHC8jYE6Zi8A2OKYfkHvSgXK BQjze2/qhQ6M6n51DX5KieFwX9cb4j65gGsOTp0a8ytOgcBHgyD+P8cklcY3l21rKzmlkgp0I GPQe/ia6FQTFTckR3o0WyxJ/oYFFO9TZ6mQCCpjqRhrtVoyArDxPUcfsza1vbRcUvSoe8J1R2 1HwS49N1WJ1p6WiCsDmQJ/2cE3DR1s8/eFrLXAv9w29z5oumCkaVewvWL0sVRj6rNGgtyBZye lG9fJ8CBAJ37vIerY/MWUlB9WmJjSBtyVQ4scsuPKLGhiReidr+HFlEZQhQDMj2qosWgrZAL Received-SPF: none client-ip=212.227.17.13; envelope-from=felix.dietrich@sperrhaken.name; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:139702 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Emanuel, Emanuel Berg writes: > Stefan Monnier via Users list for the GNU Emacs text editor wrote: > >>> Sounds like that error message should be changed to include >>> what face causes trouble, if possible? >> >> IIUC this message comes when the face is not a symbol but >> a plist of properties, so there's a good chance that >> printing the face will just say (:foreground nil) and thus >> won't help you. [...] > > Okay, but why are the face used before they even have a name? Those are *anonymous* faces. You can attach these to text or overlay properties. If I recall correctly, the Emacs Lisp manual recommends using named faces but recognises that anonymous faces might have some uses. > Isn't it better to initialize the faces first, and if it is > attempted to define them using invalid attributes, then that > would be an error? This already happens to a degree for named faces: if you use =E2=80=98deffa= ce=E2=80=99 to create a face with :foreground set to nil, subsequent calls to =E2=80=98face-attribute=E2=80=99 for :foreground on that face will return = =E2=80=98unspecified=E2=80=99: #+begin_src emacs-lisp (progn (defface my/test '((t . (:foreground nil))) "test face") (face-attribute 'my/test :foreground)) #+end_src #+RESULTS: : unspecified If I skimmed the code correctly, this is done in =E2=80=9Cxfaces.c:internal-set-lisp-face-attribute=E2=80=9D around line 334= 4 (note that there is also a check to ensure that the :foreground attribute is a string): #+NAME: xfaces.c:3344 #+begin_src c else if (EQ (attr, QCforeground)) { /* Compatibility with 20.x. */ if (NILP (value)) value =3D Qunspecified; if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)) { /* Don't check for valid color names here because it depends on the frame (display) whether the color will be valid when the face is realized. */ CHECK_STRING (value); if (SCHARS (value) =3D=3D 0) signal_error ("Empty foreground color value", value); } #+end_src In =E2=80=9Cxfaces.c:merge_face_ref=E2=80=9D, around line 2728, on the othe= r hand, everything but strings is considered an error for the :foreground attribute: #+NAME: xfaces.c:2728 #+begin_src c else if (EQ (keyword, QCforeground)) { if (STRINGP (value)) to[LFACE_FOREGROUND_INDEX] =3D value; else err =3D true; } #+end_src c Maybe just a missing check to allow NILP for the :foreground value in =E2=80=9Cxfaces.c:2728=E2=80=9D (completely untested): --=-=-= Content-Type: text/x-patch Content-Disposition: inline Content-Description: Patch to also allow NILP for :foreground in merge_face_ref diff --git a/src/xfaces.c b/src/xfaces.c index f7ee19195f..ab624a8d87 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -2727,7 +2727,9 @@ merge_face_ref (struct window *w, } else if (EQ (keyword, QCforeground)) { - if (STRINGP (value)) + if (NILP (value)) + to[LFACE_FOREGROUND_INDEX] = Qunspecified; + else if (STRINGP (value)) to[LFACE_FOREGROUND_INDEX] = value; else err = true; --=-=-= Content-Type: text/plain -- Felix Dietrich --=-=-=--