From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: autoload cl-defstruct constructor? Date: Fri, 06 Sep 2019 08:47:49 -0400 Message-ID: References: <86k1anriz5.fsf@stephe-leake.org> <86ef0u8geu.fsf@stephe-leake.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="135110"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel To: Stephen Leake Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 06 14:52:54 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i6DjQ-000Yxz-FA for ged-emacs-devel@m.gmane.org; Fri, 06 Sep 2019 14:52:52 +0200 Original-Received: from localhost ([::1]:55924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6DjP-00046i-3b for ged-emacs-devel@m.gmane.org; Fri, 06 Sep 2019 08:52:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55228) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Ded-0007sW-K4 for emacs-devel@gnu.org; Fri, 06 Sep 2019 08:47:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6Deb-0006kP-3x for emacs-devel@gnu.org; Fri, 06 Sep 2019 08:47:54 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:54997) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6Dea-0006jY-Tr for emacs-devel@gnu.org; Fri, 06 Sep 2019 08:47:53 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id BEF8081198; Fri, 6 Sep 2019 08:47:51 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5CFB480A8F; Fri, 6 Sep 2019 08:47:50 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1567774070; bh=VWBSo2sK1kLxZXUvCXJALKsgdbbJXUD/S9IXj0bJ04g=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=IxezQjYzq+rYfIFwAGVgmpUdf0V7h+5lFpFbdPmz06AUSLjFZJ6AOHcd4TnNBaVex GnL3cGjcEjm3+g8gzhg2ut8slXYdxiMRW3FXzBjC5mhE9i1iHoL2GY08Nl2f5S6nzh Ux7AUIuZSIZ9/myaT5ky8AZHKuRSMmLWF3miQKKu6CFz32m2vmkc8o7tJch9mLgzph P63Gbt7KmGBwTXFy7dAA5VtYiDB7KrbJnyxBbgecxd6b7pWsE0XhZagCF0unf73Xxp l3RSf0yiQFBkcB+6J0JBROoAbc+nRyZFg8hSfNnURuAu9ItOywoD5ab+VeT/HXF+VC 9MRM13q6FNQqA== Original-Received: from pastel (unknown [108.175.227.36]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 16A2E120402; Fri, 6 Sep 2019 08:47:50 -0400 (EDT) In-Reply-To: <86ef0u8geu.fsf@stephe-leake.org> (Stephen Leake's message of "Thu, 05 Sep 2019 16:36:09 -0700") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:239898 Archived-At: > 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.