From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: drkm Newsgroups: gmane.emacs.devel Subject: Re: Getting more info on a variable in Customize buffers Date: Mon, 03 Jan 2005 18:28:42 +0100 Organization: None Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1104773368 12681 80.91.229.6 (3 Jan 2005 17:29:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 3 Jan 2005 17:29:28 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 03 18:29:18 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ClW18-0007ZR-00 for ; Mon, 03 Jan 2005 18:29:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1ClWCH-0003yo-Kj for ged-emacs-devel@m.gmane.org; Mon, 03 Jan 2005 12:40:49 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1ClWC1-0003ye-FH for emacs-devel@gnu.org; Mon, 03 Jan 2005 12:40:33 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1ClWC0-0003yC-Pn for emacs-devel@gnu.org; Mon, 03 Jan 2005 12:40:33 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1ClWC0-0003xu-Lw for emacs-devel@gnu.org; Mon, 03 Jan 2005 12:40:32 -0500 Original-Received: from [80.91.229.2] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ClW0P-00049E-DY for emacs-devel@gnu.org; Mon, 03 Jan 2005 12:28:33 -0500 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1ClW0O-0000bm-00 for ; Mon, 03 Jan 2005 18:28:32 +0100 Original-Received: from 202-250.242.81.adsl.skynet.be ([81.242.250.202]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 03 Jan 2005 18:28:32 +0100 Original-Received: from darkman_spam by 202-250.242.81.adsl.skynet.be with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 03 Jan 2005 18:28:32 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 56 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 202-250.242.81.adsl.skynet.be User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (windows-nt) Cancel-Lock: sha1:HwP25X9Q4CngQ4jZSLhbmvMGH18= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:31743 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:31743 Stefan writes: > The problem is that custom's "variables" aren't the same as > Elisp variables. They look very much alike, and they usually are exactly > the same, but that's not always the case. > The :get, :set, and :init thingies allow you to define a custom setting > "foo-bar" which controls "toto" rather than the variable "foo-bar". So a big difference between variables and customs is: - with a variable, you can `setq' it before evaluate its definition, to overload its default value. It's very convenient in .emacs. For example, you don't have to load any library to change the variable value; - with a custom, you have to wait its definition to be evaluated before setting it in any way, to have its :get and al. to be known. So you have to deal with `require' or `eval-after-load' in .emacs, or correctly load autoloads file if provided (and if it contains the desired defcustom form). Right ? If it is, I don't know any standard way to do that directly in ELisp, if I don't want to use Customize. I think about something like : (defmacro set-custom (custom value lib) (if (boundp custom) `(set-variable ',custom ,value) `(eval-after-load ,lib '(set-variable ',custom ,value)))) But for using it, I have to know CUSTOM to be defined as a custom, where it is defined, etc. And this doesn't deal with non-evaluating the "default value form" (in defcustom) if `set-custom' is evaluated before loading the LIB. This point can be important if the custom' value is used when loading the file, for example to compute the default value of another variable: (defcustom a-custom 'default "..." :set ...) (defvar a-internal-var (compute a-custom)) How can I do in this case to change the value of `a-custom' (and have `a-internal-var' correctly set)? Hum, I suppose it's the responsability of the :set'er of `a-custom'... So what's the clean way to set custom' value in ELisp, in a user point of view? --drkm