all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
To: emacs-devel <emacs-devel@gnu.org>
Subject: autoload cl-defstruct constructor?
Date: Wed, 04 Sep 2019 11:53:34 -0700	[thread overview]
Message-ID: <86k1anriz5.fsf@stephe-leake.org> (raw)

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



             reply	other threads:[~2019-09-04 18:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 18:53 Stephen Leake [this message]
2019-09-04 19:03 ` autoload cl-defstruct constructor? 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86k1anriz5.fsf@stephe-leake.org \
    --to=stephen_leake@stephe-leake.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.