From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mauro Aranda Newsgroups: gmane.emacs.bugs Subject: bug#24727: 25.1; Editing custom theme removes undefined variables and faces Date: Fri, 4 Sep 2020 10:02:43 -0300 Message-ID: References: <87oa2if52f.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000b6ccf205ae7c7c9e" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25581"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Allen Li To: 24727@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 04 15:04:17 2020 Return-path: Envelope-to: geb-bug-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 1kEBO5-0006XX-85 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 04 Sep 2020 15:04:17 +0200 Original-Received: from localhost ([::1]:40590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEBO4-0003Gl-AD for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 04 Sep 2020 09:04:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEBNq-0003Gb-5y for bug-gnu-emacs@gnu.org; Fri, 04 Sep 2020 09:04:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kEBNp-00019Q-So for bug-gnu-emacs@gnu.org; Fri, 04 Sep 2020 09:04:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kEBNp-0002j9-PB for bug-gnu-emacs@gnu.org; Fri, 04 Sep 2020 09:04:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87oa2if52f.fsf@gmail.com> Resent-From: Mauro Aranda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Sep 2020 13:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24727 X-GNU-PR-Package: emacs Original-Received: via spool by 24727-submit@debbugs.gnu.org id=B24727.159922458310421 (code B ref 24727); Fri, 04 Sep 2020 13:04:01 +0000 Original-Received: (at 24727) by debbugs.gnu.org; 4 Sep 2020 13:03:03 +0000 Original-Received: from localhost ([127.0.0.1]:37943 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kEBMt-0002i1-By for submit@debbugs.gnu.org; Fri, 04 Sep 2020 09:03:03 -0400 Original-Received: from mail-wm1-f44.google.com ([209.85.128.44]:33239) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kEBMr-0002hW-GQ for 24727@debbugs.gnu.org; Fri, 04 Sep 2020 09:03:01 -0400 Original-Received: by mail-wm1-f44.google.com with SMTP id e11so7493460wme.0 for <24727@debbugs.gnu.org>; Fri, 04 Sep 2020 06:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=O9gINvyxcXBheY67dTKAJ53E4tJGDa5rit0YRiuUzo4=; b=A0q2PUo69/Q6T/sHjkqyFMoZiw2qsyxo/1CKP1dsE5bnXwijmZyMP7n4naJnB3pUbr rtVn+ar9Ca+5SS4Ld78neooluwBNyMUkjkXdtvhrmJtVoMYHv2sfgwKeZbVYxV1TuQPw jfU7VVEIyhLBlKm3XZVofgHcyZevtFtzEyyu3GyYdfiOWXUkXIOF0t3QSxdRVqoRnUCi CFtWcPj7UXO0grhU4C0Wwxjv9WJhmbAltliuAIZdSOhmRHqKJbjH8XvaDk344oLGvChr RIyTWlF8KJK3NG/Segk/zwuv5ei8ai9P2RujUOzZMVOI64T3o8yttFs/b68NLG0E2KT0 5iSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=O9gINvyxcXBheY67dTKAJ53E4tJGDa5rit0YRiuUzo4=; b=GpVUjl0sVMSK1GHGHL9cfLVC3PTSqhZ7WO8gUvz4z4/5AselNOhlHftxZ1TEQjfMOU QA8TMCtXjyqguDP2os+KxES4wUs1wvZ+v9QIKaEmz5rDYkwd2Flz8RR0dy0/k6JtC3LF e9ttuPDwyUDOUje/adiDWTXHce0wG7OAc7Clr0vs27ZyXZVvj8+A6fWUr1VK3N/CF6LP BdrqZ5CnlCJ0UFrSJkUZFZwOLz1+eveMpfIpo8NADHyW+KWElKLuhfq0PPv2y2NZcrcA iD0mGUiV8ZBs9MJtLIjm+VG5xUOtmwYdZeRpnp8nFLD3jaSFoyceycqW9Y3kQp5rvm1y ce+Q== X-Gm-Message-State: AOAM531XE92IBNft1zpyXYUyIRji7zizU0FRYGXnTJrtOF6G4rpm6uRb zPtYAS91237SzZwEv3M0ScEWkhS9y4eDd0J8bqijT+bMn8vOoA== X-Google-Smtp-Source: ABdhPJzJdbK4nxM5wVI8zULdOiM/9REaVoMVQmIdNZc6pGZQfxto5h2GaF2BVbi3zcnvS/rLN30kMFiMIN2fjzu42Dc= X-Received: by 2002:a1c:1b43:: with SMTP id b64mr7834950wmb.6.1599224575070; Fri, 04 Sep 2020 06:02:55 -0700 (PDT) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:187125 Archived-At: --000000000000b6ccf205ae7c7c9e Content-Type: multipart/alternative; boundary="000000000000b6ccef05ae7c7c9c" --000000000000b6ccef05ae7c7c9c Content-Type: text/plain; charset="UTF-8" Allen Li writes: > When using `customize-create-theme' to visit and edit an existing theme, > undefined variables and faces get removed on save (for example, for a > package whose autoload hasn't been triggered yet). > To test this, I used the following theme: (deftheme tbb-test "A test theme.") (custom-theme-set-variables 'tbb-test '(column-number-mode t) '(foo-undefined 'foo)) (provide-theme 'tbb-test) And put it under custom-theme-directory, with name tbb-test-theme.el. Then: M-x custom-theme-visit-theme RET tbb-test And clicked Save Theme. Then I visited tbb-test-theme.el and confirmed that the entry for foo-undefined wasn't there anymore. There is a check in custom-theme-write-variables for a bound symbol, and a check in custom-theme-write-faces for a known face, and I wonder why, because that should not be a concern for these functions. Note that still editing a theme with custom-theme-visit-theme is somewhat buggy, because if you click to show the variable foo-undefined you end up with a lot of errors, and you can't hide it back. But at least removing the checks makes it less rude, and undefined variables or faces stay in the file. Here's my proposed patch. --000000000000b6ccef05ae7c7c9c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Allen Li <v= ianchielfaura@gmail.com> writes:

> When using `customize-c= reate-theme' to visit and edit an existing theme,
> undefined var= iables and faces get removed on save (for example, for a
> package wh= ose autoload hasn't been triggered yet).
>

To test this, I= used the following theme:
(deftheme tbb-test
=C2=A0 "A test the= me.")

(custom-theme-set-variables
=C2=A0'tbb-test
=C2= =A0'(column-number-mode t)
=C2=A0'(foo-undefined 'foo))
<= br>(provide-theme 'tbb-test)

And put it under custom-theme-direc= tory, with name tbb-test-theme.el.
Then:
M-x custom-theme-visit-theme= RET tbb-test

And clicked Save Theme.

Then I visited tbb-test= -theme.el and confirmed that the entry for
foo-undefined wasn't ther= e anymore.

There is a check in custom-theme-write-variables for a bo= und symbol, and
a check in custom-theme-write-faces for a known face, an= d I wonder why,
because that should not be a concern for these functions= .

Note that still editing a theme with custom-theme-visit-theme issomewhat buggy, because if you click to show the variable foo-undefinedyou end up with a lot of errors, and you can't hide it back.

B= ut at least removing the checks makes it less rude, and undefined
variab= les or faces stay in the file.

Here's my proposed patch.
--000000000000b6ccef05ae7c7c9c-- --000000000000b6ccf205ae7c7c9e Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Do-not-remove-unbound-variables-or-faces-when-modify.patch" Content-Disposition: attachment; filename="0001-Do-not-remove-unbound-variables-or-faces-when-modify.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_keo8z6wh0 RnJvbSAyZjMzZmMwMTFiNmY1MTRkYmQ2YmNjODBhYWQzMGM1NTdhZjkyODc0IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXVybyBBcmFuZGEgPG1hdXJvb2FyYW5kYUBnbWFpbC5jb20+ CkRhdGU6IFdlZCwgMjYgQXVnIDIwMjAgMTA6MjI6MTEgLTAzMDAKU3ViamVjdDogW1BBVENIXSBE byBub3QgcmVtb3ZlIHVuYm91bmQgdmFyaWFibGVzIG9yIGZhY2VzIHdoZW4gbW9kaWZ5aW5nIGEK IGN1c3RvbS10aGVtZQoKKiBsaXNwL2N1cy10aGVtZS5lbCAoY3VzdG9tLXRoZW1lLXdyaXRlLXZh cmlhYmxlcwpjdXN0b20tdGhlbWUtd3JpdGUtZmFjZXMpOiBSZW1vdmUgY2hlY2sgZm9yIGEgYm91 bmQgc3ltYm9sIG9yIGZvciBhCmZhY2UgbmFtZSwgc28gc2F2aW5nIGEgdGhlbWUgZG9lcyBub3Qg cmVtb3ZlIG5vdCB5ZXQgZGVmaW5lZCB2YXJpYWJsZXMKb3IgZmFjZXMuICAoQnVnIzI0NzI3KS4K LS0tCiBsaXNwL2N1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N0b20tdGhlbWUt d3JpdGUtZmFjZXMKIAkJICAgOzsgQ2hpbGQgaXMgbnVsbCBpZiB0aGUgd2lkZ2V0IGlzIGNsb3Nl ZCAoaGlkZGVuKS4KIAkJICAgKCh3aWRnZXQtZ2V0IHdpZGdldCA6c2hvd24tdmFsdWUpKQogCQkg ICAodCAoY3VzdG9tLWZhY2UtZ2V0LWN1cnJlbnQtc3BlYyBzeW1ib2wpKSkpKQotCSAgICAod2hl biAoYW5kIChmYWNlcCBzeW1ib2wpIHZhbHVlKQorCSAgICAod2hlbiB2YWx1ZQogCSAgICAgIChw cmluYyAoaWYgKGJvbHApICIgJygiICJcbiAnKCIpKQogCSAgICAgIChwcmluMSBzeW1ib2wpCiAJ ICAgICAgKHByaW5jICIgIikKLS0gCjIuMjguMAoK --000000000000b6ccf205ae7c7c9e--