help-gnu-emacs
[Top][All Lists]
Advanced

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

eieio persistent, plus autoloads


From: Eric Abrahamsen
Subject: eieio persistent, plus autoloads
Date: Thu, 15 Aug 2013 18:45:45 +0800
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux)

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




reply via email to

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