From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: custom + theme recursion Date: Tue, 22 Nov 2011 13:59:18 +0800 Message-ID: <87r5104s09.fsf@gnu.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1321941575 18787 80.91.229.12 (22 Nov 2011 05:59:35 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 22 Nov 2011 05:59:35 +0000 (UTC) Cc: emacs-devel@gnu.org To: joakim@verona.se Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 22 06:59:31 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RSjOE-0006YQ-VM for ged-emacs-devel@m.gmane.org; Tue, 22 Nov 2011 06:59:31 +0100 Original-Received: from localhost ([::1]:50478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSjOE-0008AY-9i for ged-emacs-devel@m.gmane.org; Tue, 22 Nov 2011 00:59:30 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:60969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSjOC-0008AT-Dn for emacs-devel@gnu.org; Tue, 22 Nov 2011 00:59:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RSjOB-0008Gs-0z for emacs-devel@gnu.org; Tue, 22 Nov 2011 00:59:28 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]:50214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSjOA-0008Go-Vr for emacs-devel@gnu.org; Tue, 22 Nov 2011 00:59:26 -0500 Original-Received: from [155.69.16.255] (port=32807 helo=furball) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1RSjOA-0007WP-1I; Tue, 22 Nov 2011 00:59:26 -0500 In-Reply-To: (joakim@verona.se's message of "Fri, 04 Nov 2011 12:24:20 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.10 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:146131 Archived-At: joakim@verona.se writes: > So, lets say I have a variable zen-state. when zen-state is set, I > want to change custom-enabled-themes. I also want zen-state to be a > customizable variable. > > For some reason this causes recursion. I don't think that is intuitive, > because zen-state is supposed to be in the user-theme, which has the > highest precedence of the themes, and the other themes should have no > opinion of the value of zen-state. > > Anyway, how should I reason about themes and custom? Sorry for the delay. Here, I think, is the problem: you have a custom :set function that calls `enable-theme', and the code in `enable-theme' calls `custom-theme-recalc-variable' to apply all variables in every theme (to ensure that theme values are applied in the correct order). Obviously, `custom-theme-recalc-variable' ends up calling the :set function again, etc. I'm not sure what's a good way to address this within Emacs itself, but you can get around it in your own code by doing (unless (custom-theme-enabled-p 'zen) (enable-theme 'zen))