all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* eieio persistent, plus autoloads
@ 2013-08-15 10:45 Eric Abrahamsen
  2013-08-15 16:05 ` David Engster
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Abrahamsen @ 2013-08-15 10:45 UTC (permalink / raw)
  To: help-gnu-emacs

tl;dr: I'm looking for a safe way of creating autoloads (via
eieio-defclass-autoload) for every defined subclass of a particular
class (even when defined in third-party packages), and then writing
those autoload statements to a custom loaddefs.el file.

longer version:

One of my one-hour-a-month side projects is seeing if I can port BBDB
over to use EIEIO under the hood. There are a lot of potential benefits,
but two of the big ones are automatic file persistence with
eieieo-persistent, and the ability to subclass BBDB records and field
classes, making it much easier to extend and alter the behavior of a
BBDB database.

Those two features together create an immediate problem. Say a
third-party package defines a new field type. I instantiate that type in
my current session, make it part of my database, and then write it to
file. The next time I restart emacs, there's a danger that the database
file will be read before the class type has been defined, leading to a
type error.

eieio-persistent provides some tools for this in the form of autoloads:
eieio-defclass-autoload creates class definition autoload objects, and
the file-reading function looks out for them while reading a persistence
file. I'm just stuck on making it work right.

Working backwards, I envision it happening like this: at the top of the
BBDB code, in a spot that gets loaded before any databases are read,
there's a line like this:

(load "bbdb-loaddefs.el" t t t)

That file would be full of autoload statements, created by
eieio-defclass-autoload, for any custom subclass that's been created.
The question is, how do I get those statements in there?

eieio-hook is only run the first time eieio-defclass is called, so
that's no good.

My other idea was to provide a custom macro that wraps defclass, but I
can't even get that to work: it seems that update-file-autoloads only
works for autoload cookies in comments, not for regular autoload or
eieio-defclass-autoload calls. You can't put that comment cookie in a
macro, so I still can't find a way to programmatically write these
autoload statements to a single file...

I hope that made sense. Any pointers very appreciated!

Eric




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

end of thread, other threads:[~2013-08-19  2:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-15 10:45 eieio persistent, plus autoloads Eric Abrahamsen
2013-08-15 16:05 ` David Engster
2013-08-16  2:03   ` Eric Abrahamsen
2013-08-16 15:18     ` David Engster
2013-08-17  4:11       ` Eric Abrahamsen
2013-08-17  7:21         ` David Engster
2013-08-19  2:18           ` Eric Abrahamsen

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.