From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Eric M. Ludlam" Newsgroups: gmane.emacs.devel Subject: Re: defstruct vs. Customize Date: Mon, 15 Nov 2010 17:35:42 -0500 Message-ID: <4CE1B5BE.2000709@siege-engine.com> References: <87r5em9t6s.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1289860557 29546 80.91.229.12 (15 Nov 2010 22:35:57 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 15 Nov 2010 22:35:57 +0000 (UTC) Cc: emacs-devel@gnu.org To: Ted Zlatanov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 15 23:35:53 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PI7eS-0005HI-PJ for ged-emacs-devel@m.gmane.org; Mon, 15 Nov 2010 23:35:52 +0100 Original-Received: from localhost ([127.0.0.1]:37840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PI7eS-0000j7-6J for ged-emacs-devel@m.gmane.org; Mon, 15 Nov 2010 17:35:52 -0500 Original-Received: from [140.186.70.92] (port=43612 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PI7eN-0000j2-Gp for emacs-devel@gnu.org; Mon, 15 Nov 2010 17:35:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PI7eM-0007J4-BT for emacs-devel@gnu.org; Mon, 15 Nov 2010 17:35:47 -0500 Original-Received: from bird.interbax.net ([75.126.100.114]:34671) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PI7eM-0007Im-6w for emacs-devel@gnu.org; Mon, 15 Nov 2010 17:35:46 -0500 Original-Received: (qmail 32155 invoked from network); 15 Nov 2010 15:35:44 -0700 Original-Received: from static-71-184-83-10.bstnma.fios.verizon.net (HELO ?192.168.1.201?) (71.184.83.10) by interbax.net with SMTP; 15 Nov 2010 15:35:43 -0700 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.3a1pre) Gecko/20091222 Shredder/3.1a1pre In-Reply-To: <87r5em9t6s.fsf@lifelogs.com> X-detected-operating-system: by eggs.gnu.org: Windows 98 (1) 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: news.gmane.org gmane.emacs.devel:132678 Archived-At: Hi, If you use defclass (via EIEIO, which became a part of Emacs when CEDET was integrated into Emacs.) Via CLOS compatible interface you can make classes, etc, but an Emacs extension allows specifying :label, :group and :custom fields on a per-slot basis. It also allows customization "in place" on an object, or via replacement as with customization of a variable. CEDET's EDE tool makes extensive use of these features. Eric On 11/15/2010 04:24 PM, Ted Zlatanov wrote: > (I'm working on a rewrite of auth-source.el with a better API) > > Is there a nice way to show and customize defstructs in Customize? > > I really like defstruct and would like to use it. But the user will > have trouble customizing things; e.g. > > (defstruct auth-source-backend > backend-type ; 'secrets or 'netrc > host port user ; all these are optional > create-function search-function) ; access functions > > (defcustom auth-source-secrets-backend > (make-auth-source-backend :backend-type 'secrets > :search-function 'auth-source-secrets-search > :create-function 'auth-source-secrets-create) > "The backend for working with the Secrets API") > > (defcustom auth-source-netrc-backend > (make-auth-source-backend :backend-type 'netrc > :search-function 'auth-source-netrc-search > :create-function 'auth-source-netrc-create) > "The backend for working with netrc files") > > (defcustom auth-source-backends '(auth-source-netrc-backend) > "The backends for auth-source." > :group 'auth-source > :version "23.2" ;; No Gnus > :type `(repeat > (choice :tag "Backend to use" > (const :tag "Secrets API" auth-source-secrets-backend) > (const :tag "Netrc files" auth-source-netrc-backend) > (symbol :tag "Any backend")))) > > This works until the user wants to add or remove a custom backend or > modify the default backend's host, port, and user properties. Is there > any way to do this through Customize? The slots of the defstruct are > known, of course. I could use ":type list" and omit ":named" which > would theoretically make the structures look like plain lists, but that > seems like a hack compared to true knowledge of all the slots. > > Thanks > Ted > > >