From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: eieio defclass evaluate :initform value Date: Thu, 05 Jan 2017 10:56:39 -0800 Message-ID: <87k2a9pc7s.fsf@ericabrahamsen.net> References: <20170104120403.6e7c67e8@gauss> <87o9zm7dwd.fsf@ericabrahamsen.net> <20170105080654.7fdeac91@gauss> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1483652906 8162 195.159.176.226 (5 Jan 2017 21:48:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 5 Jan 2017 21:48:26 +0000 (UTC) User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/26.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 05 22:48:22 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPFtQ-0001AD-Bz for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Jan 2017 22:48:16 +0100 Original-Received: from localhost ([::1]:48805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPFtU-00087x-Ky for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Jan 2017 16:48:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPDDd-00080B-84 for help-gnu-emacs@gnu.org; Thu, 05 Jan 2017 13:56:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPDDa-0005iL-72 for help-gnu-emacs@gnu.org; Thu, 05 Jan 2017 13:56:57 -0500 Original-Received: from [195.159.176.226] (port=49756 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cPDDa-0005hl-0E for help-gnu-emacs@gnu.org; Thu, 05 Jan 2017 13:56:54 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cPDDP-0003VD-BH for help-gnu-emacs@gnu.org; Thu, 05 Jan 2017 19:56:43 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 41 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:SidGTXoHNKahw2tiCKturRthKbk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-Mailman-Approved-At: Thu, 05 Jan 2017 16:47:37 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112055 Archived-At: Joe Riel writes: > On Wed, 04 Jan 2017 12:45:22 -0800 > Eric Abrahamsen wrote: > >> Joe Riel writes: >> >> > According to the info page for eieio for Emacs 23, one >> > could do >> > >> > (defclass foo-class >> > ((bar :initform (lambda () my-var) >> > :type string))) >> > >> > When make-instance was called, the lambda expression >> > for :initform would be evaluated and the expression >> > assigned to my-var would be used for the slot bar. >> > >> > The info page for eieio Emacs 24 does not mention this >> > functionality and testing shows it no longer exists. >> > >> > Is there nice way, in 24, to create a class with an :initform >> > that, upon instantiation, evaluates to the value of a variable? >> >> Depending on what exactly you want, you might be able to solve it with >> `oset-default', which lives outside the class definition, and can >> evaluate variables. See if that does what you want? > > Thanks, Eric; I wasn't aware of oset-default and could use it, however, > am currently taking a different approach. The bigger picture is that > I'm using a buffer-local object to store configuration data for a > major mode. The object is normally updated when the mode is invoked, > but the global defaults should be configurable. The current approach > is to clone a default object whose values can be assigned via a > customization. The documentation for using defcustom with an eieio object > is slim, but I got it working. Yup, that would be awkward to do with `oset-default'. Glad you got something working. Eric