[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: autoload cl-defstruct constructor?
From: |
Stefan Monnier |
Subject: |
Re: autoload cl-defstruct constructor? |
Date: |
Fri, 06 Sep 2019 08:47:49 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> 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.
- autoload cl-defstruct constructor?, Stephen Leake, 2019/09/04
- Re: autoload cl-defstruct constructor?, Stefan Monnier, 2019/09/04
- Re: autoload cl-defstruct constructor?, Stephen Leake, 2019/09/05
- Re: autoload cl-defstruct constructor?,
Stefan Monnier <=
- Re: autoload cl-defstruct constructor?, Stephen Leake, 2019/09/06
- Re: autoload cl-defstruct constructor?, Stefan Monnier, 2019/09/07
- Re: autoload cl-defstruct constructor?, Stephen Leake, 2019/09/09
- Re: autoload cl-defstruct constructor?, Stephen Leake, 2019/09/09
- Re: autoload cl-defstruct constructor?, Stefan Monnier, 2019/09/09