[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: defstruct vs. Customize

From: Eric M. Ludlam
Subject: Re: defstruct vs. Customize
Date: Mon, 15 Nov 2010 17:35:42 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.3a1pre) Gecko/20091222 Shredder/3.1a1pre


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.


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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]