all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* defstruct vs. Customize
@ 2010-11-15 21:24 Ted Zlatanov
  2010-11-15 22:35 ` Eric M. Ludlam
  0 siblings, 1 reply; 2+ messages in thread
From: Ted Zlatanov @ 2010-11-15 21:24 UTC (permalink / raw)
  To: emacs-devel

(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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: defstruct vs. Customize
  2010-11-15 21:24 defstruct vs. Customize Ted Zlatanov
@ 2010-11-15 22:35 ` Eric M. Ludlam
  0 siblings, 0 replies; 2+ messages in thread
From: Eric M. Ludlam @ 2010-11-15 22:35 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-15 22:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-15 21:24 defstruct vs. Customize Ted Zlatanov
2010-11-15 22:35 ` Eric M. Ludlam

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.