From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Stephen Leake <stephen_leake@stephe-leake.org>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: autoload cl-defstruct constructor?
Date: Fri, 06 Sep 2019 08:47:49 -0400 [thread overview]
Message-ID: <jwvwoelmwc1.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <86ef0u8geu.fsf@stephe-leake.org> (Stephen Leake's message of "Thu, 05 Sep 2019 16:36:09 -0700")
> If I add an autoload cookie to a cl-defstruct, running
> update-directory-autoloads on the above gives:
>
> ---
>
> ;;; Generated autoloads from gnat-core.el
>
> (cl-defstruct gnat-compiler "\
> Used with wisi-compiler-* generic functions." gpr-file run-buffer-name
> project-path target runtime gnat-stub-opts gnat-stub-cargs)
Oh, right, because when the autoloads are generated `cl-defstruct` is
not defined at all. If you run update-directory-autoloads from within
a running Emacs where cl-lib is loaded, it will give you a result that's
much closer to what you want.
Making cl-defstruct into an autoloaded macro would solve this part of
the problem.
> The files are included in autoloads.el in file name alphabetical order
> (although there do seem to be exceptions?).
I believe the ordering is deterministic (modulo bugs), but it's
arbitrary, so better not rely on it, indeed.
> (cl-defstruct (ada-prj (:include wisi-prj) (:copier nil) (:constructor nil)
> (:constructor make-ada-prj (&key name compile-env (compiler-label
> ada-compiler) (xref-label ada-xref-tool) source-path plist file-pred &aux
> (compiler (ada-prj-make-compiler compiler-label)) (xref (ada-prj-make-xref
> xref-label))))) plist)
>
> ...
>
> ;;; Generated autoloads from wisi-prj.el
>
> (cl-defstruct wisi-prj name compile-env file-env compiler xref
> (case-exception-files nil) (case-full-exceptions 'nil)
> (case-partial-exceptions 'nil) source-path file-pred)
Once autoload applies to the macro-expanded code, the problem still
exists: there's no remaining dependencies between the various (autoload
'wisi-...) but there's still a dependency between the calls to
`cl-define-struct`.
I think the patch below would solve that second problem.
Stefan
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 1ae7266624..05a4192dd9 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -3006,6 +3006,7 @@ cl-defstruct
`(progn
(defvar ,tag-symbol)
,@(nreverse forms)
+ :autoload-end
;; Call cl-struct-define during compilation as well, so that
;; a subsequent cl-defstruct in the same file can correctly include this
;; struct as a parent.
next prev parent reply other threads:[~2019-09-06 12:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=jwvwoelmwc1.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=stephen_leake@stephe-leake.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.