[Top][All Lists]

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

defstruct vs. Customize

From: Ted Zlatanov
Subject: defstruct vs. Customize
Date: Mon, 15 Nov 2010 15:24:11 -0600
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

(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]