From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#38812: 28.0.50; Custom: Problem with reverting some session's customizations Date: Tue, 31 Dec 2019 19:25:23 +0200 Message-ID: <83eewkl858.fsf@gnu.org> References: <83o8volbvf.fsf@gnu.org> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="228691"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38812@debbugs.gnu.org To: Mauro Aranda Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 31 18:26:24 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1imLHj-000xHp-7F for geb-bug-gnu-emacs@m.gmane.org; Tue, 31 Dec 2019 18:26:23 +0100 Original-Received: from localhost ([::1]:44936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imLHb-0004Ll-Pc for geb-bug-gnu-emacs@m.gmane.org; Tue, 31 Dec 2019 12:26:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40188) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1imLHR-0004LW-V6 for bug-gnu-emacs@gnu.org; Tue, 31 Dec 2019 12:26:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1imLHQ-0007zM-4d for bug-gnu-emacs@gnu.org; Tue, 31 Dec 2019 12:26:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57315) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1imLHO-0007yQ-Bc for bug-gnu-emacs@gnu.org; Tue, 31 Dec 2019 12:26:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1imLHO-0004nm-5P for bug-gnu-emacs@gnu.org; Tue, 31 Dec 2019 12:26:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 31 Dec 2019 17:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38812 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 38812-submit@debbugs.gnu.org id=B38812.157781312718416 (code B ref 38812); Tue, 31 Dec 2019 17:26:02 +0000 Original-Received: (at 38812) by debbugs.gnu.org; 31 Dec 2019 17:25:27 +0000 Original-Received: from localhost ([127.0.0.1]:35055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imLGp-0004my-5W for submit@debbugs.gnu.org; Tue, 31 Dec 2019 12:25:27 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57709) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imLGo-0004mm-8I for 38812@debbugs.gnu.org; Tue, 31 Dec 2019 12:25:26 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:52580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1imLGi-0006GJ-OI; Tue, 31 Dec 2019 12:25:20 -0500 Original-Received: from [176.228.60.248] (port=4317 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1imLGa-0003T2-8I; Tue, 31 Dec 2019 12:25:16 -0500 In-reply-to: (message from Mauro Aranda on Tue, 31 Dec 2019 14:21:09 -0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:173990 Archived-At: > From: Mauro Aranda > Date: Tue, 31 Dec 2019 14:21:09 -0300 > Cc: 38812@debbugs.gnu.org > > > And I have a question: isn't it better not to use setcar in > > custom-push-theme instead? > > I thought of doing that, and use setf with alist-get to make the change > instead. But I think we'll be better off if we avoid sharing the cons > cell inadvertedly, since that is prone to have bugs like this one. And I actually think that a problem should be fixed where it is caused. There's nothing wrong per se with sharing portions of Lisp data structures. > Alternatively, we could create the list in custom-theme-recalc-variable, > to accomplish the same thing without changing the return value of > custom-variable-theme-value. In that case, I think it would be > convenient to change the doc string of custom-variable-theme-value, to > say it returns some cdr. > > To me, either the patch I posted (with an additional explanatory > comment, of course) or the latter option sound better, but I won't argue > too much if you think otherwise. My alternative patch is below. WDYT? diff --git a/lisp/custom.el b/lisp/custom.el index 26bdaae2c2..7ed85b22e8 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -886,7 +886,10 @@ custom-push-theme (put theme 'theme-settings (cons (list prop symbol theme value) (delq res theme-settings))) - (setcar (cdr setting) value))) + ;; It's tempting to use setcar here, but that could + ;; inadvertently modify other properties in SYMBOL's proplist, + ;; if those just happen to share elements with the value of PROP. + (put symbol prop (cons (list theme value) (delq setting old))))) ;; Add a new setting: (t (when (custom--should-apply-setting theme)