unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* autoload cl-defstruct constructor?
@ 2019-09-04 18:53 Stephen Leake
  2019-09-04 19:03 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Stephen Leake @ 2019-09-04 18:53 UTC (permalink / raw)
  To: emacs-devel

I have code like:

In ada-core.el:

(defun ada-prj-make-compiler (label)
  (funcall (intern (format "make-%s-compiler" (symbol-name label)))))

where 'label' is a user variable indicating choice of Ada compiler.

In gnat-core.el:

(cl-defstruct (gnat-compiler :include wisi-compiler)
   ...)

In foo-core.el, for another Ada compiler:

(cl-defstruct (foo-compiler :include wisi-compiler)
   ...)

The question is how to arrange autoloads so the correct constructor is
available, without loading the file(s) containing the unneeded one(s).

I tried adding an autoload cookie to the cl-defstruct. That almost
works, but update-directory-autoloads doesn't respect the order implied
by :include, so wisi-compiler is declared in autoloads.el after it is
needed.

Is there a way to influence the order of files included in autoloads
(short of renaming the files so alphabetical is correct)?

I could rename the constructor:

    (:constructor create-gnat-compiler)

and provide an ordinary autoloaded defun:

(defun make-gnat-compiler (...)
   (create-gnat-compiler ...))

But that seems inelegant, and maintaining the arg lists is tedious and
error-prone.

Is there a way to autoload just the created constructor?

-- 
-- Stephe



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

end of thread, other threads:[~2019-09-09 21:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04 18:53 autoload cl-defstruct constructor? Stephen Leake
2019-09-04 19:03 ` Stefan Monnier
2019-09-05 23:36   ` Stephen Leake
2019-09-06 12:47     ` Stefan Monnier
2019-09-06 22:25       ` Stephen Leake
2019-09-07 14:29         ` Stefan Monnier
2019-09-09 19:12           ` Stephen Leake
2019-09-09 19:35             ` Stephen Leake
2019-09-09 21:38             ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).