From unknown Fri Sep 19 18:23:36 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#78995 <78995@debbugs.gnu.org> To: bug#78995 <78995@debbugs.gnu.org> Subject: Status: [PATCH] ;;;autoload-expand for special macros Reply-To: bug#78995 <78995@debbugs.gnu.org> Date: Sat, 20 Sep 2025 01:23:36 +0000 retitle 78995 [PATCH] ;;;autoload-expand for special macros reassign 78995 emacs submitter 78995 JD Smith severity 78995 normal tag 78995 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 11 15:29:01 2025 Received: (at submit) by debbugs.gnu.org; 11 Jul 2025 19:29:01 +0000 Received: from localhost ([127.0.0.1]:40053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uaJQb-0006n0-1c for submit@debbugs.gnu.org; Fri, 11 Jul 2025 15:29:01 -0400 Received: from lists.gnu.org ([2001:470:142::17]:36564) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uaJQV-0006mS-Bk for submit@debbugs.gnu.org; Fri, 11 Jul 2025 15:28:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uaJPz-00020a-Pz for bug-gnu-emacs@gnu.org; Fri, 11 Jul 2025 15:28:31 -0400 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uaJPu-0003Ur-So for bug-gnu-emacs@gnu.org; Fri, 11 Jul 2025 15:28:20 -0400 Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-86d00ae076dso113418539f.0 for ; Fri, 11 Jul 2025 12:28:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752262095; x=1752866895; darn=gnu.org; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=vybBfTIR7jEoBGLUeAS5aqvz5eK9MExBoVYOLsDQ8Dc=; b=cHjBV+XtZTzAm+ZBHbfIfccU5Kc4esQEDm3dbOYYX9hFxU+n7Os4TWky397eOWCS3a j/1eHXrGQXE2nutRLRrT2kxeBtp/KMJCo25dEGRdqEpCu6IWAuHDXqdEmg8uDu2qxAW2 ZprPsoOBLVMR9eDtJyemYDSRatEqxdhwMAPUCun51Z5lPp8KOab4B+1U2StY7PTJTy9F tcMvXzX1dgLCeH83zaNEdohzeH+/y6HoFKg4OCusisOJGY2qWhFl1XCiiAzKsOMvdIeY 9/iH4/hBwQJ0/I27dmXJNR277Gb18CHtQRjgR4D+IgQC1v1hGM+0zhd91RWMEcwy4j9C jfpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752262095; x=1752866895; h=to:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vybBfTIR7jEoBGLUeAS5aqvz5eK9MExBoVYOLsDQ8Dc=; b=kZ7alx4oFgU/4kXCE4YHu+rb5DhWHf5CE4l7EDa2TD2uf+hGR7pS+YNkhEcTpa/o4G xd837/Tegf02lorcykzw3krkF30qL5VUtdCKfAwlknL2IQT+mUzkAxSJoyqSU6l3Fhwu OkrCd4AB7SvcWu3a/1jJ/xBzW6EveDgBIVNYgzxqE0R4j1jWBRbYZLbvY3wUPa0NrcnZ NMVp7N9/hMrGFhfCliAFM5coWG53uIhqyiYmmAHu3A+80w7rg0jkhckoq6jg9rZALl+r jWoqZkLGht6Yq8dICViM7jeBg4Ku45BZXCDRZV02YCxDPcj3QdVNBNdUxLT5yvbv/rlb wRDA== X-Gm-Message-State: AOJu0YzxjCrP+DIJ+sXOvy6a3HeDCYKcBWEMzepugWqqhV1347leKq9k SNxINvwFP4MOTh5soKkJX+T48lBdqn8LdFdcVz9KBh4eY6IPOHKffk3t5V7FXw== X-Gm-Gg: ASbGncvOquoLDZZQ++lWOmKgvNj5zzc+nh8nqSG99I//qXSkjMM601isI4K8H5NWAwe InDOo8tFkefpIUZ2E5wdPVRk9vR2fUkcCJqaJQl+7Uv4/Bc0JakPyHjaY7gzHw8elquJDyjvYV9 vD/Y+YfO1aTWhN9YIjUEkfBByxIaUDTQQU/63/biQCcAK5tS/RN3hW97QujbBKRL0vzt9nUzGiy MgcmTLQ2xdsJZpD0SXteohFayn3qCCGT/NfYa1E1UPhduGjcGrQose06fQKwI1WEWwpo/XP4333 OZOnnaIY3fX5pjjlR+Wk8HeXaG9Tns4oPqHTLlbPvJ04fCW+7xlRx7ygOzxBT0HDa3Gl11+K+1D P60tE/mIW0epOgOe4l7ifeghrTD3XMKBrUm0nkbkAfeJAyS1zD/lli4p4DzAoclI9LYT4vQ== X-Google-Smtp-Source: AGHT+IFqtnGGg0/8Ojdmk4rmDOjNjAgbhD8il7uq3SnpAPn4D1Sx2PmmbLPmEWdqCMQ89sia8Acqmw== X-Received: by 2002:a05:6602:a009:b0:873:1e91:210e with SMTP id ca18e2360f4ac-87966faaae9mr1152471039f.4.1752262094877; Fri, 11 Jul 2025 12:28:14 -0700 (PDT) Received: from smtpclient.apple (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-5055697326asm975144173.76.2025.07.11.12.28.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jul 2025 12:28:14 -0700 (PDT) From: JD Smith Content-Type: multipart/mixed; boundary="Apple-Mail=_FB6434A8-ED87-408A-A82B-E5678986141D" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.600.51.1.1\)) Subject: [PATCH] ;;;autoload-expand for special macros Message-Id: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Fri, 11 Jul 2025 15:28:03 -0400 To: bug-gnu-emacs@gnu.org X-Mailer: Apple Mail (2.3826.600.51.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::d2f; envelope-from=jdtsmith@gmail.com; helo=mail-io1-xd2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --Apple-Mail=_FB6434A8-ED87-408A-A82B-E5678986141D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii As mentioned over on emacs-devel, it's sometimes a problem that = `loaddefs-gen' hard-codes the list of special macros it is willing to = expand: (memq car '(easy-mmode-define-global-mode define-global-minor-mode define-globalized-minor-mode defun defmacro easy-mmode-define-minor-mode = define-minor-mode define-inline cl-defun cl-defmacro = cl-defgeneric cl-defstruct pcase-defmacro iter-defun = cl-iter-defun)) This makes it challenging to wrap things like `define-minor-mode' into a = new macro, and autoload the resulting forms. This small patch adds a = new variant of the autoload cookie: ;;;autoload-expand (my-autoloadable-macro-to-expand ...) which allows package authors to "opt-in" to macro expansion of the = following form during autoload generation. It would be useful primarily = for special macros that are not in the hard-coded list above, but which = expand to other special macros that are. Docs can be added if this looks good. --Apple-Mail=_FB6434A8-ED87-408A-A82B-E5678986141D Content-Disposition: attachment; filename=autoload-expand.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="autoload-expand.patch" Content-Transfer-Encoding: 7bit diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..552da564929 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -144,10 +144,11 @@ loaddefs-generate--shorten-autoload (defun loaddefs-generate--make-autoload (form file &optional expansion) "Turn FORM into an autoload or defvar for source file FILE. -Returns nil if FORM is not a special autoload form (i.e. a function definition -or macro definition or a defcustom). -If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +Returns nil if FORM is not a special autoload form (i.e. a function +definition or macro definition or a defcustom). If EXPANSION is +non-nil, we're processing the macro expansion of an expression, in which +case we want to handle forms differently. If it the symbol `force', +assume the form requires expansion." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -196,12 +197,13 @@ loaddefs-generate--make-autoload (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) + ;; For complex cases and forced expansions, try again on the macro-expansion. + ((and (or (eq expansion 'force) + (memq car '(easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode defun defmacro + easy-mmode-define-minor-mode define-minor-mode + define-inline cl-defun cl-defmacro cl-defgeneric + cl-defstruct pcase-defmacro iter-defun cl-iter-defun))) (macrop car) (setq expand (let ((load-true-file-name file) (load-file-name file)) @@ -465,7 +467,10 @@ loaddefs-generate--parse-file (expand-file-name (concat aname "-loaddefs.el") (file-name-directory file)) - (or local-outfile main-outfile)))) + (or local-outfile main-outfile))) + (expansion (and (looking-at "-expand[ \t]*") 'force))) + (when expansion + (goto-char (match-end 0))) (if (eolp) ;; We have a form following. (let* ((form (prog1 @@ -473,7 +478,7 @@ loaddefs-generate--parse-file (unless (bolp) (forward-line 1)))) (autoload (or (loaddefs-generate--make-autoload - form load-name) + form load-name expansion) form))) ;; We get back either an autoload form, or a tree ;; structure of `(progn ...)' things, so unravel that. --Apple-Mail=_FB6434A8-ED87-408A-A82B-E5678986141D Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_FB6434A8-ED87-408A-A82B-E5678986141D-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 12 02:10:19 2025 Received: (at 78995) by debbugs.gnu.org; 12 Jul 2025 06:10:19 +0000 Received: from localhost ([127.0.0.1]:42987 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uaTRD-0002h6-9S for submit@debbugs.gnu.org; Sat, 12 Jul 2025 02:10:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52772) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uaTRB-0002gg-7Z for 78995@debbugs.gnu.org; Sat, 12 Jul 2025 02:10:17 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uaTR3-000882-PK; Sat, 12 Jul 2025 02:10:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Vm2rKj1n60kbOtRXE0iq0UlYQhweigBivDS0aRRDiGg=; b=cYqzhy7UBjFP lKbRYqwyYUA/hRVFFio52GP/PRT5NDtTMd4XjK56MmvE3Is9oF0aRVAmLu80LbKgLFH1DD1Wusd3+ WtuVufG+cbASdjfNx1AFJNV0SKFcGn6MIKFq+ZhDPe4AbT3bQ2KysNJ6FgStlhH8pUMS1/w7rGSAM XhmEfHrXOS06LQCYO+W2eoVHMAqOE6bWI2yfPpKdUdMsibmIGM6hrKf9dcA5FrNjJVbziCmj+ElHx Fa/TGzGI6ubVS9Q5Ny53hZ98UB/XYWE0zTJoFshwC+Ocm4uAxhzlqf6pKQS75EgLSoM6uTi1DD9A5 CuL+L/VYKjVwELn7JezIoQ==; Date: Sat, 12 Jul 2025 09:10:05 +0300 Message-Id: <86y0suey82.fsf@gnu.org> From: Eli Zaretskii To: JD Smith , Stefan Monnier , Philip Kaludercic In-Reply-To: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> (message from JD Smith on Fri, 11 Jul 2025 15:28:03 -0400) Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: JD Smith > Date: Fri, 11 Jul 2025 15:28:03 -0400 > > (defun loaddefs-generate--make-autoload (form file &optional expansion) > "Turn FORM into an autoload or defvar for source file FILE. > -Returns nil if FORM is not a special autoload form (i.e. a function definition > -or macro definition or a defcustom). > -If EXPANSION is non-nil, we're processing the macro expansion of an > -expression, in which case we want to handle forms differently." > +Returns nil if FORM is not a special autoload form (i.e. a function > +definition or macro definition or a defcustom). If EXPANSION is > +non-nil, we're processing the macro expansion of an expression, in which > +case we want to handle forms differently. If it the symbol `force', ^^^^^^^^^^^^^ "it is the symbol". Also, I wonder why you decided to refill the existing text. A doc string is easier readable if each argument's description starts on a new line, because then it's easier to scan the doc string if you are looking for the description of a specific argument. And finally, the last sentence, which you added, doesn't really explain the effect of the special value 'force' -- can we do a better job describing that? > - (or local-outfile main-outfile)))) > + (or local-outfile main-outfile))) > + (expansion (and (looking-at "-expand[ \t]*") 'force))) And this part seems to be completely undocumented? From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 12 11:00:08 2025 Received: (at 78995) by debbugs.gnu.org; 12 Jul 2025 15:00:08 +0000 Received: from localhost ([127.0.0.1]:46731 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uabhv-0001Zh-U4 for submit@debbugs.gnu.org; Sat, 12 Jul 2025 11:00:08 -0400 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]:50438) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uabhr-0001Vo-9y for 78995@debbugs.gnu.org; Sat, 12 Jul 2025 11:00:05 -0400 Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-875ce3c8e24so113166439f.1 for <78995@debbugs.gnu.org>; Sat, 12 Jul 2025 08:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752332397; x=1752937197; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=Ud23kGEmbOpVxI4eDn7yxQIqfS/5kC3rqFGGoCvg6RE=; b=LajnthsMD5ztAvZYMDRmfp7rEplZkRZbrfTwwI5ULOxAE61Bt57GlWTIfFQ9UZKz+h GErZKSvh7RrKXomOx9p0S0F4KcUA3mnIqDJ5PTCPnY3TofEmv3iQCdVpiY+pZ5SlUuRS ZfkWPQdzfiP96DCGJJr94Q5lWOFSYuqtCCxPnqsHD244Z5vsbgvKxCbpJfhmBGYzxdQP 8owzYiMN6xLvfyU2XDAafOessE4nTlPatUdR5f/pCyQrik47fN8Enkhj4YZyyUwfZj7Q WSMpv2wKxVeVREETz5QtpdPzEZTagqmxq6wJnITkyfSU0obQlp5A5ToTKL+BWIBW7hTf V0Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752332397; x=1752937197; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ud23kGEmbOpVxI4eDn7yxQIqfS/5kC3rqFGGoCvg6RE=; b=uV7ZsV8mxFxALVFQbqH1KgDiE0bEVjojDT0BCrVMPTiyDt8AHuQyH5f/Qf+YBcQlAw pdLzhKPh8QGrOkP0I1r+q1LM19nNJ6TDWpNrjmLCf9Tzek6yo/JL6hiAQ7kKilWU5S/p xcW9jxwgfrA4n8ybt7+a46eYnIj2LU99nkhWKV88o92feh6nXpnwYgr73VY1qq90T6OM KCgJx0i4b1zGBKq3jCPH0imXmnBg4ZY+4L4TGJ7KRPNXL2O32i5iz84bhP790jCQ2vc8 MJZc5LtvPg8MeR2uKwfC8W/quUUQypDhsy+7EgWFc89nhLCnVPQgJT+pV/u2WLKFTmfg dACA== X-Forwarded-Encrypted: i=1; AJvYcCUwvAfUvaDoLzu8w1LwrAC/5foTUs4O0SOpWbW9qEXSXsYo/Se1pIbWZU6CMG20U8zBeuLlew==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyUFFusuALncXqve/8hvRr8r8vMMGZYiL41Nf1fSDo9Z49UQfnp NLxuzwHSw49lo3yFuAtvOculhv9Dqu0V/SX6Pk3pv72EOcLRiWjT0tZ1 X-Gm-Gg: ASbGncsYwardUpt9GMFq/aj9PeV7bQNxW6NpH9POIjUbo2dQRMF1326KeYXtkTlSrtD FReZ/PCYxVAbPOck0vy6uGMGhXRcPWWEXWeotMaQskk2uqV3yrII0jvHRSj2Q5gVBXCadYBjHPx W6g0FYzHqEuqnZRXmCX0mGJQLA92glZhMeRi9TUkLWK+Ca6g2YKZ4kHmcv9V3K1+8vtV+F4OsUp Gk4AJm41o06srgphiFRZ8m0rEYPByxiBLZm8DYlHITTsj6goCiGOSDxCv4TTAzdmt3BE5cdWVFW RN+OYOFk5XxfYwuRaqnGi3E+YrtpF7dostqL7Av9bnITsw99M72F7DZJS0v0dykHxEBZdnpZUmg 4zRMXhheaRzFbUnM4ZI4XOP0ihelDVJzZMu8csBZCK/T37fXv22vmDQDAyzjmdW5m+HH7Kg== X-Google-Smtp-Source: AGHT+IETBKr5AFIpcbYVZiCIKNPwKT917i0gLQUyT3vm/sVPMtTf51Z3VcQrZ9ax1C2L4eX52l1G6g== X-Received: by 2002:a05:6602:4019:b0:876:7876:a587 with SMTP id ca18e2360f4ac-87977e98946mr842201939f.0.1752332397328; Sat, 12 Jul 2025 07:59:57 -0700 (PDT) Received: from smtpclient.apple (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-50556970df3sm1259214173.90.2025.07.12.07.59.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Jul 2025 07:59:56 -0700 (PDT) From: JD Smith Message-Id: <3DAE88EE-FBFD-4930-94F4-50A664DD01BE@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_D4F50C73-5A22-443B-8A3D-114D1C774589" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.600.51.1.1\)) Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros Date: Sat, 12 Jul 2025 10:59:45 -0400 In-Reply-To: <86y0suey82.fsf@gnu.org> To: Eli Zaretskii References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <86y0suey82.fsf@gnu.org> X-Mailer: Apple Mail (2.3826.600.51.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: Philip Kaludercic , 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_D4F50C73-5A22-443B-8A3D-114D1C774589 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Thanks, improved doc-strings in the attached. If this is looking good I = can also update the `Autoload' section of the elisp manual, near "If you = write a function definition with an unusual macro...". I also noticed = that `:autoload-end' is not mentioned there, and probably should be = (this keyword marker halts further processing of forms in the macro = expansion). One question on nesting of macros: I'm wondering whether an = ;;;###autoload-expand should result in using `EXPANSION=3Dforce' in all = recursive calls to `loaddefs-generate--make-autoload'. I.e. should all = macros be _recursively_ expanded with `force'? This would allow = nesting, e.g. a macro wrapping a macro which itself wraps = `define-minor-mode'. But it would also expand all other macros = encountered in the expansion, which could be problematic. My instinct = is that one level of such forced macro expansion is all that can be = safely supported. --Apple-Mail=_D4F50C73-5A22-443B-8A3D-114D1C774589 Content-Disposition: attachment; filename=autoload-expand.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="autoload-expand.patch" Content-Transfer-Encoding: 7bit diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..e171fa6bf16 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -147,7 +147,10 @@ loaddefs-generate--make-autoload Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. If +EXPANSION is the symbol `force' and the following form is a macro call, +it will be expanded prior to generating autoload forms, similar to what +is done automatically for special macros like `define-minor-mode'." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -196,12 +199,13 @@ loaddefs-generate--make-autoload (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) + ;; For complex cases and forced expansions, try again on the macro-expansion. + ((and (or (eq expansion 'force) + (memq car '(easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode defun defmacro + easy-mmode-define-minor-mode define-minor-mode + define-inline cl-defun cl-defmacro cl-defgeneric + cl-defstruct pcase-defmacro iter-defun cl-iter-defun))) (macrop car) (setq expand (let ((load-true-file-name file) (load-file-name file)) @@ -381,6 +385,10 @@ loaddefs-generate--parse-file setting of `generated-autoload-file' in FILE, and by ;;;###foo-autoload statements. +The special statement ;;;###[foo-]autoload-expand causes the following +form to be macro-expanded prior to generating autoloads; see +`loaddefs-generate--make-autoload'. + If PACKAGE-DATA is `only', return only the package data. If t, include the package data with the rest of the data. Otherwise, don't include." @@ -465,7 +473,10 @@ loaddefs-generate--parse-file (expand-file-name (concat aname "-loaddefs.el") (file-name-directory file)) - (or local-outfile main-outfile)))) + (or local-outfile main-outfile))) + (expansion (and (looking-at "-expand[ \t]*") 'force))) + (when expansion + (goto-char (match-end 0))) (if (eolp) ;; We have a form following. (let* ((form (prog1 @@ -473,7 +484,7 @@ loaddefs-generate--parse-file (unless (bolp) (forward-line 1)))) (autoload (or (loaddefs-generate--make-autoload - form load-name) + form load-name expansion) form))) ;; We get back either an autoload form, or a tree ;; structure of `(progn ...)' things, so unravel that. --Apple-Mail=_D4F50C73-5A22-443B-8A3D-114D1C774589-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 12 12:10:06 2025 Received: (at 78995) by debbugs.gnu.org; 12 Jul 2025 16:10:06 +0000 Received: from localhost ([127.0.0.1]:46930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uacne-00069N-0k for submit@debbugs.gnu.org; Sat, 12 Jul 2025 12:10:06 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:4885) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uacnb-00067Q-1g for 78995@debbugs.gnu.org; Sat, 12 Jul 2025 12:10:03 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 08CFC10025E; Sat, 12 Jul 2025 12:09:57 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1752336596; bh=E6In7OqO895e6alT6aK07YYJkgiIEE1hgSPsk4LftTU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=kkkWSrgxnZHnhuBeDQ4gV98LdYw3NbHxKmXJERYsyrwdG7OPbrL8VgYu03mq+D8uN uM8xc9zp0o8tAnj4f/DK3WsHt22VBidOjnecyDgrXmRFuELPRaTpe9xqj264uqqszD 3rNDdySWBehsDZkuUP/Fhe9YjIjgpw+1BRm5o5cGr3MfKbiRBN4SCB+cmybCfOVO/v gvi47KDB3iIvWGUEWqal/4e5DyneL09X3XoV2dozOP2KTr81b630xW/0E7rWpdhnEv 1w/L7FjZxbjC+0jDBYrqbmYxR8ng9TcyHEwGZnHsigN0pN/RPJ2CiyoyZmgZn4mIR8 72Yye2OMdQYnw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 2FE42100034; Sat, 12 Jul 2025 12:09:56 -0400 (EDT) Received: from pastel (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0764B1209BC; Sat, 12 Jul 2025 12:09:55 -0400 (EDT) From: Stefan Monnier To: JD Smith Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sat, 12 Jul 2025 12:09:55 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.281 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > This makes it challenging to wrap things like `define-minor-mode' into a new > macro, and autoload the resulting forms. This small patch adds a new > variant of the autoload cookie: > > ;;;autoload-expand > (my-autoloadable-macro-to-expand ...) I suspect this will often fail to work because autoloads are often generated by a fresh new session where `my-autoloadable-macro-to-expand` will not yet be defined. So at the very least, your patch should make sure to signal an error when the cookie is of the form `;;;autoload-expand` by the head is not currently defined as a macro. I've been wanting to add the feature you propose, but this "macro is not defined" has gotten in the way until now. I think we need to add something like a file-local `autoload-requires-for-macros`. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 12 12:12:52 2025 Received: (at 78995) by debbugs.gnu.org; 12 Jul 2025 16:12:52 +0000 Received: from localhost ([127.0.0.1]:46939 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uacqK-0006Kp-0z for submit@debbugs.gnu.org; Sat, 12 Jul 2025 12:12:52 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39723) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uacqI-0006KS-46 for 78995@debbugs.gnu.org; Sat, 12 Jul 2025 12:12:50 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A830F440B6C; Sat, 12 Jul 2025 12:12:44 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1752336763; bh=hBJ+y1nr5Y4jL6K/BtDERyh3e5o+4H75cdn0PZVG+fE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=MfkMXHHUoSB7HD7lKCx11yu9p1pK/XAljB5RUFOUrSypFs8GlzKeHMl+IE3eoY0Bg n/akig0OTC/4ycBXOw70q9a4nnKURN0w2PZFEsyZNPXlHkw203xM/uXO3PoYeUhYzQ hhgOnIoCaRFgttcNhgWllVJUgsTs7cx38kRwZVutvBGX2ZD67aK6p5/z1GiasjOPFq FE1ii3phDyJWkqjRenoMxb/CKdyYWF6Tn6+RBGoyS2f5GLjwTyADwO6lDiqHrAyPyD lZ1O4NQRMWXLPNykW/D8YxEruoloxukQIIpWJaxY73BE7EmpEF9v4Rxbw5hFG0YlYJ F/6Qpyb2GPXzQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 9D4FF440A63; Sat, 12 Jul 2025 12:12:43 -0400 (EDT) Received: from pastel (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6769C120312; Sat, 12 Jul 2025 12:12:43 -0400 (EDT) From: Stefan Monnier To: JD Smith Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <3DAE88EE-FBFD-4930-94F4-50A664DD01BE@gmail.com> Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <86y0suey82.fsf@gnu.org> <3DAE88EE-FBFD-4930-94F4-50A664DD01BE@gmail.com> Date: Sat, 12 Jul 2025 12:12:42 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.272 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: Eli Zaretskii , 78995@debbugs.gnu.org, Philip Kaludercic X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > One question on nesting of macros: I'm wondering whether > an ;;;###autoload-expand should result in using `EXPANSION=force' in all > recursive calls to `loaddefs-generate--make-autoload'. I.e. should all > macros be _recursively_ expanded with `force'? This would allow nesting, > e.g. a macro wrapping a macro which itself wraps `define-minor-mode'. > But it would also expand all other macros encountered in the expansion, > which could be problematic. My instinct is that one level of such forced > macro expansion is all that can be safely supported. Another way might be to replace the `;;;###autoload-expand` marker with an list of of macros which should be expanded (i.e. a way to extent the hardcoded list). Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 12 13:26:16 2025 Received: (at 78995) by debbugs.gnu.org; 12 Jul 2025 17:26:17 +0000 Received: from localhost ([127.0.0.1]:47090 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uadzM-0002Fq-CY for submit@debbugs.gnu.org; Sat, 12 Jul 2025 13:26:16 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]:58551) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uadzI-0002FY-Ka for 78995@debbugs.gnu.org; Sat, 12 Jul 2025 13:26:13 -0400 Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-876ae3f7768so258658039f.0 for <78995@debbugs.gnu.org>; Sat, 12 Jul 2025 10:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752341166; x=1752945966; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=cwR+f5R8LWV6IThAcbiQXIqQaQjDz3BPr7R/NecJytU=; b=hDDo6RZXsaD4YOXMfgokE69PABU3MFPKzdxNUgdsdqDi6jvIM9IulLHZWcLunJljYu JnL0BHnoMpLojrp4pBxyGIO28FLck4bOiMnO/CrNKos5JRB5uz23iEszZXG3MnNy+D0L GMbJ4rqjrV3640WqPvHAdtmBrI0NANNFOx+dz9z18o646ch5+S0tUVgogJ0us57o/HSv ynCsoXWXP9ClqIIwTcu3kHHc1lXb6iwa7+VZk0zeocYbqLVxZqzYIMQLtaG/OrMccp3f BN4pXOq9YiH4G1XG0N1keI3IeZxwAz2DcobWnqlAQ5FijXNkq9J/VB69mGb+uDOh8gr8 F97A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752341166; x=1752945966; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cwR+f5R8LWV6IThAcbiQXIqQaQjDz3BPr7R/NecJytU=; b=pqm99vtOgZv9bm7FqvV5/MB5rCdF3OMvRCwbxymAUc+B9n/UzBqLU6glFDTRsAHefP eRTYnVwqF9+EzeXSnjWFB8DGZ9oncwIvkIUbKE64UMVFi97bFhc0SZARWevdRTUkXCXs axcV09ZCTI0c6isiYHhGT+9U54YJEIGxapqYwTnAnPWLxt0zwSq9s1mfp7cuH32U0ElM KRmKwM3wyT2eeCXa/YCZ1sccpimmru+1G9bh9GBZEI6khZvnDCuffukTklUgzo13Q/4t aubQO4ITfdw/bJCWoRlGoyA7zv0wG2MxLsI1wnDhg94uKr+3jquMEVufnA3SM+bt+dYH XIYw== X-Gm-Message-State: AOJu0Ywv2AFd/0kon4o0BXhtOtuJGdL9rq+RRCgFNECKVC8drtilRD0A q/WgTaU61jbozCathV0ZP46CWA45zSc3Jprwth7f2CaBeIDLLKFDg5wJWTnshA== X-Gm-Gg: ASbGnctM3pk/0Ow0gZekiaRmCYKbsmt5pmXDjwAM1pSzZC2AibHsIbvhMIQ01JmDVZ3 al6OJn54fzVqQR1ze1PirxAdEvmMssmE9RtQ4gNnCyPIUOX1njntaA2lZ4j+wfNxas3hfoON45r zqN59+hp2byB1gj/DPEmT21L9YD6AcuGQBNU1Wd+rDWb16ZVZ3bLSM97itfiz+phWK+VKjI8L7S gwM2GAc2bBUNVyykpWMAQ9XvpjyNOJfCxb5zJmQaRJuHH8DSzOBJ9io//Er00RLwtxY9e4YBCy2 hg/HrR2nVkrXWlHGyKJJdc5GNYSXAV3tK0zYeZ4kMfokmOA/id15ouPkPHR6J+yOVRG9RuU/Xxr JTvtaeISexBFyx8NYfs3B7s6JnM2mUeBzjyZldgqIZaO+cAzXjJ3RPa9W X-Google-Smtp-Source: AGHT+IGd+Df8dOn2qR1otc+tQ7VMZD2BE+xyfnBYIbL3E1oOD6mylcR/u0wQgYb22ikvMyeaZ8Zw6w== X-Received: by 2002:a05:6602:15c9:b0:86c:f9f4:6aa6 with SMTP id ca18e2360f4ac-879787d8f28mr895115439f.7.1752341166255; Sat, 12 Jul 2025 10:26:06 -0700 (PDT) Received: from moss-3 (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-505569cc6c1sm1282842173.104.2025.07.12.10.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jul 2025 10:26:05 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Sat, 12 Jul 2025 12:09:55 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sat, 12 Jul 2025 13:26:04 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Stefan Monnier writes: >> This makes it challenging to wrap things like `define-minor-mode' into a new >> macro, and autoload the resulting forms. This small patch adds a new >> variant of the autoload cookie: >> >> ;;;autoload-expand >> (my-autoloadable-macro-to-expand ...) > > I suspect this will often fail to work because autoloads are often > generated by a fresh new session where `my-autoloadable-macro-to-expand` > will not yet be defined. Good point. That chicken-and-egg problem was definitely in the back of my mind, and is why I didn't attempt to create an expandable list to replace the list of hard-coded special macros. > I've been wanting to add the feature you propose, but this "macro is not > defined" has gotten in the way until now. I think we need to add > something like a file-local `autoload-requires-for-macros`. How about this solution? If the car of the following form is not a macro (and not a function), attempt to load the file itself (temporarily expanding `load-path' to include the file's containing directory). If that fails to define the macro, warn the user, and simply proceed without expansion. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=autoload-expand.patch Content-Description: autoload-expand patch diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..f7919a7a377 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -147,7 +147,10 @@ loaddefs-generate--make-autoload Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. If +EXPANSION is the symbol `force' and the following form is a macro call, +it will be expanded prior to generating autoload forms, similar to what +is done automatically for special macros like `define-minor-mode'." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -196,12 +199,13 @@ loaddefs-generate--make-autoload (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) + ;; For complex cases and forced expansions, try again on the macro-expansion. + ((and (or (eq expansion 'force) + (memq car '(easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode defun defmacro + easy-mmode-define-minor-mode define-minor-mode + define-inline cl-defun cl-defmacro cl-defgeneric + cl-defstruct pcase-defmacro iter-defun cl-iter-defun))) (macrop car) (setq expand (let ((load-true-file-name file) (load-file-name file)) @@ -381,6 +385,10 @@ loaddefs-generate--parse-file setting of `generated-autoload-file' in FILE, and by ;;;###foo-autoload statements. +The special statement ;;;###[foo-]autoload-expand causes the following +form to be macro-expanded prior to generating autoloads; see +`loaddefs-generate--make-autoload'. + If PACKAGE-DATA is `only', return only the package data. If t, include the package data with the rest of the data. Otherwise, don't include." @@ -465,16 +473,38 @@ loaddefs-generate--parse-file (expand-file-name (concat aname "-loaddefs.el") (file-name-directory file)) - (or local-outfile main-outfile)))) + (or local-outfile main-outfile))) + (expansion (and (looking-at "-expand[ \t]*") 'force))) + (when expansion + (goto-char (match-end 0))) (if (eolp) ;; We have a form following. (let* ((form (prog1 (read (current-buffer)) (unless (bolp) (forward-line 1)))) - (autoload (or (loaddefs-generate--make-autoload - form load-name) - form))) + (car (car form)) + autoload) + (when expansion + ;; We encountered ;;;###autoload-expand, so the + ;; following form should be a macro. Check that + ;; it is defined. If it is undefined (and not a + ;; function), load the file to attempt to define + ;; it. If it remains undefined, warn and simply + ;; ignore the expand request. + (unless (or (macrop car) (functionp car)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s" file) + (condition-case e (load file) + (error + (warn "loaddefs-gen: load error\n\t%s" e))))) + (unless (macrop car) + (warn "loaddefs-gen: macro undefined, skipping expansion\n\t%s" + car) + (setq expansion nil))) + (setq autoload (or (loaddefs-generate--make-autoload + form load-name expansion) + form)) ;; We get back either an autoload form, or a tree ;; structure of `(progn ...)' things, so unravel that. (let ((forms (if (eq (car autoload) 'progn) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 12 13:51:22 2025 Received: (at 78995) by debbugs.gnu.org; 12 Jul 2025 17:51:22 +0000 Received: from localhost ([127.0.0.1]:47157 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uaeNe-0003jv-3Q for submit@debbugs.gnu.org; Sat, 12 Jul 2025 13:51:22 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:29555) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uaeNa-0003jc-P0 for 78995@debbugs.gnu.org; Sat, 12 Jul 2025 13:51:19 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 159DB80387; Sat, 12 Jul 2025 13:51:12 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1752342670; bh=s/viiq4zmOqSuQmjhXfJxxfq4Kjvu2zrQNa4eEdBsLM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=RhjhTNEFQdJbiflH5dK9TWa74NljYHVaS/+vlgFhrzvfRbgVZCmXxdT4NkprZpw53 Sn8N/SqR0sshVqFtGvpSUA9MaYwaOOY4qAtZrfftHe1ILWDz+p9FAEg8d8lsfbkFzW u4a1TehIAbcfzASYS8RtezrVqNDhd5VIvPVaeqGNWHAH4uEzB0a7KlOdC4EV1ac+r8 F+OP6dQPRKDgRCvGmwHcUIO6cB6ay+ZAk6whY3znEAg6GLBt9/lErwL4B/vrFzDWjI nGOewcQqQUdUognhO33uCPsd5h87nuQVcaCRZzoI/48X4xJVqyPBGBqv/5eZKss376 rtzRjq2Z3QXQw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 557278089D; Sat, 12 Jul 2025 13:51:10 -0400 (EDT) Received: from pastel (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2BBCC12065D; Sat, 12 Jul 2025 13:51:10 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sat, 12 Jul 2025 13:51:09 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.288 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> I've been wanting to add the feature you propose, but this "macro is not >> defined" has gotten in the way until now. I think we need to add >> something like a file-local `autoload-requires-for-macros`. > How about this solution? If the car of the following form is not a > macro (and not a function), attempt to load the file itself (temporarily > expanding `load-path' to include the file's containing directory). If > that fails to define the macro, warn the user, and simply proceed > without expansion. I don't think it's good enough. Many of the use-cases I've bumped into use macros defined in another file (or even another package). I think we should aim to provide a mechanism that lets us reduce the size of the hardcoded list (ideally to nothing). Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 12 15:59:57 2025 Received: (at 78995) by debbugs.gnu.org; 12 Jul 2025 19:59:57 +0000 Received: from localhost ([127.0.0.1]:47475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uagO5-0003AK-4C for submit@debbugs.gnu.org; Sat, 12 Jul 2025 15:59:57 -0400 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]:53493) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uagO0-00039f-Ra for 78995@debbugs.gnu.org; Sat, 12 Jul 2025 15:59:55 -0400 Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-87640a9e237so263881939f.2 for <78995@debbugs.gnu.org>; Sat, 12 Jul 2025 12:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752350386; x=1752955186; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=YmdmqeRxYuw+x2E7xXDEVXg9sGLk51wJHB7DdDAoItU=; b=ISh33Dj8ObPYmJY/h7a7IZrgvyBlgDZ6c4mvjV7Yn+FSzAXlpyzdlPUe334A1gzKNF Gm9OS5jYqPDXe5A1QM4VZFL05/GOMt0DNgvTY7vsauxBcvouv9478LdV4twkoPUSs5un XwNR4lbUxXQRczuSQGTBOXLJLwJOGyg0HZ94IZPD26jcp/dXHG/F4mZCGssF4/gUyyYj 9B/a+VB6WYsXWCGoAmmyh4KngbW1enh6mKQJE+xss51UJvP2ziLNER5TDNJ+xTEH2swA D9DBtoKuwsmr+kmSFIZ+frdE5rzFu0amVNEIwdRQYNargac1BaBlG2+KNPFURs2gmje2 FZVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752350386; x=1752955186; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YmdmqeRxYuw+x2E7xXDEVXg9sGLk51wJHB7DdDAoItU=; b=squrnxlVsDX2IBkoyN8mz9eRLqPkCbYrr9XGGJMAfZs6Vzb9A5yDF+89HOizDxDmqC 2Tmr7NAc8CRSrRy8SwEQWsIYZj12PczqHOuaBx6bwUujIdSWvTWLzVHErk6DeUrAlHHU VMQJn75gyFoR3SbfZUXioS4HvyB6XzweihzcwoaxLGc69pESnrXyF4FXGNAuN84SQ9IM cUAvOwTYVP7xfgiEijg5BGOAHT2bxqZAgdrX4aRpu5tgF2g3gaM592YnEfwP6FaHmyfa T88dzy/seU4sydAs552OH2ZIGSVlDOVelUAjLJVzKHNz+ILnesXU1TB/+wDvCfK02eES lguQ== X-Gm-Message-State: AOJu0YzoHhq2JbgTRkcdanjDm+26K0uI1MfKx1xst7X/ZxbLqT6vcxqh Xxx2XE0HyuZ/L2mLwi9lknKH8dkBlWBip9MTOWCT2wKiFVZA/Z/UJxoa1Cs7BA== X-Gm-Gg: ASbGnctbYuDtW2ZRAaU9Ug7Xo4A+fC3V1rPggnque09WTd5kuTli8908uZl+xahENZ8 vG0k/1+L+c/QKHOe51NxqIoPshoWAubgk0LMZfr9PrnccvplLF6y/hPbH0bZLP+S8tiyn3ZbKLi qtVBhmFdrD/FYJaOUv6a+lYep7UBmEFJ7oMC7FB4IpkCXwM9ORWBO3JzGarBCLS93PvCVNxNOkA YSagdHebbO2/cjHxDzpL6iiH1Nqv/HYdFjVxQMeNG4W9RemyvrJG6mmP2n3sBuTtr0WSu610xX5 pdLruRt0HQxKWMYU6fHAWwEB0f0qVJlm6PtiJ66HYUUJHPQ7zO5C23pKoeCIzZ+Q42vELZVEGje z2fpZDfq2uT6PqtERbxAAOaITExTExUuvcg63kFNQJjakzlOqcYnvjIIL X-Google-Smtp-Source: AGHT+IGOUKYZEKQ3YnLPaClEG+dhbOYOsXqtJX2mxpn+ZsI5s3kf42GHK1DwyGmBWrCMQQmKd9VIJw== X-Received: by 2002:a05:6e02:310e:b0:3df:4cf8:dd50 with SMTP id e9e14a558f8ab-3e2533419d8mr89517425ab.19.1752350386426; Sat, 12 Jul 2025 12:59:46 -0700 (PDT) Received: from moss-3 (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-50556532a23sm1398369173.10.2025.07.12.12.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jul 2025 12:59:45 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Sat, 12 Jul 2025 13:51:09 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sat, 12 Jul 2025 15:59:44 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >>> I've been wanting to add the feature you propose, but this "macro is not >>> defined" has gotten in the way until now. I think we need to add >>> something like a file-local `autoload-requires-for-macros`. >> How about this solution? If the car of the following form is not a >> macro (and not a function), attempt to load the file itself (temporarily >> expanding `load-path' to include the file's containing directory). If >> that fails to define the macro, warn the user, and simply proceed >> without expansion. > > I don't think it's good enough. Many of the use-cases I've bumped into > use macros defined in another file (or even another package). Doesn't a file usually need to require such files/packages in order to make use of their macros? Or is the concern that those other files/packages would not be in the current directory or on the load-path? I think package-install installs all requirements first, so that shouldn't happen for it. Or perhaps the issue arises in cases like multi-file packages where `declare-function' is used because you know the load order. I.e. if: 1. A.el always requires B.el and is its entry point, 2. B.el uses a macro from A.el with an ;;;###autoload-expand, and 3. B.el does _not_ require A.el, only (possibly) mentioning it via `declare-function`. Then loading B.el is, as you say, not good enough. This is tricky to work around. > I think we should aim to provide a mechanism that lets us reduce the > size of the hardcoded list (ideally to nothing). There are actually _multiple_ hard-coded lists in `loaddefs-generate--make-autoload': 1. Macros to expand (by name) and recurse on the expansion. 2. "Function-like operators", which get an `(autoload ...)' form created for them. 3. Macros which are known to produce interactive function definitions (to set the INTERACTIVE arg for the generated autoload). What about just mentioning in the docs that using ;;;###autoload-expand successfully requires that the macro to be expanded is defined upon loading the containing file? There is a prominent warning if loading the file fails to define the macro, so developers should be aware (or made aware by their users). They can always, e.g., factor out their macro to a common file they can require. The "fallback" is equivalent to the current behavior: copy the full form into the autoload file. Otherwise, if a documentation solution is not good enough, we could create an additional file-local variable that could be consulted if the user of ;;;###autoload-expand needs to give it some help, e.g.: - `autoload-macro-expansion-files': a file-local list of additional file(s) to load prior to macro expansion, if any macros in calls directly preceded by ;;;###autoload-expand are undefined. A symbol `file' in this list indicates the current file. Defaults to `(file)'. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 12 18:44:09 2025 Received: (at 78995) by debbugs.gnu.org; 12 Jul 2025 22:44:09 +0000 Received: from localhost ([127.0.0.1]:48014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uaiwy-0005TU-OF for submit@debbugs.gnu.org; Sat, 12 Jul 2025 18:44:09 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:13580) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uaiwv-0005S0-TB for 78995@debbugs.gnu.org; Sat, 12 Jul 2025 18:44:06 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4825344125F; Sat, 12 Jul 2025 18:43:59 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1752360238; bh=XQLoFPZoESl/F9vJubeTh1rzx3I6St6b4m5UPtKLJ+E=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=mhcHwnpdEGGTHJtDZJfxxlNdbmAL/fOmpLFq/7Q7AazTpE8w1Qo/VVHs6J4fNMwce vZXjBSNw35F9Ux/wjCjzNdXTQ2tVctK9Muixhf9MZP1RZ7UkoLEyL8y5Xqs7gLXChV GnpNgJgrWE75vB+JBpLaQsdHjYCihMq+4VER1nS7RXIfjrLJUkKrzfemnXsEw81ePh gQmJJQeK20y/2TxowfasjpzFK6Oa8s52pV6y3QPXBZCob0cX/bXzBQ7v5U+8OFdCD0 W6oY4C4R7Fbh2zHH/aDQp8wTMOMGqHmT2sk7cg/vw/uAMQvAhtkfABKdpxancHbKpM lvnQNWGfuaZtA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3828244097A; Sat, 12 Jul 2025 18:43:58 -0400 (EDT) Received: from pastel (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1395B120AB0; Sat, 12 Jul 2025 18:43:58 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sat, 12 Jul 2025 18:43:56 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.267 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> I don't think it's good enough. Many of the use-cases I've bumped into >> use macros defined in another file (or even another package). > Doesn't a file usually need to require such files/packages in order to > make use of their macros? Duh! You're right. > Or perhaps the issue arises in cases like multi-file packages where > `declare-function' is used because you know the load order. I.e. if: No, no, these are "evil" and they get what they deserve. >> I think we should aim to provide a mechanism that lets us reduce the >> size of the hardcoded list (ideally to nothing). > > There are actually _multiple_ hard-coded lists in > `loaddefs-generate--make-autoload': > > 1. Macros to expand (by name) and recurse on the expansion. > 2. "Function-like operators", which get an `(autoload ...)' form > created for them. > 3. Macros which are known to produce interactive function definitions > (to set the INTERACTIVE arg for the generated autoload). The only list that I've found a need to extend is the (1) above, so I wouldn't worry too much about the other two. [ Declaring specific macros as "to be expanded for autoload" (as opposed to marking specific autoloaded macro calls), would still be overall better, since it would solve the question of "what about macros that expand to something that also needs expanding". ] Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 12 22:25:18 2025 Received: (at 78995) by debbugs.gnu.org; 13 Jul 2025 02:25:19 +0000 Received: from localhost ([127.0.0.1]:49357 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uamOz-0007qX-RY for submit@debbugs.gnu.org; Sat, 12 Jul 2025 22:25:18 -0400 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]:43369) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uamOv-0007mC-5L for 78995@debbugs.gnu.org; Sat, 12 Jul 2025 22:25:15 -0400 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-86d029e2bdeso154777839f.1 for <78995@debbugs.gnu.org>; Sat, 12 Jul 2025 19:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752373507; x=1752978307; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=0V4+PBg0J4+osErg1tBXCHBZKx0hUHnCOBtQn7JJN/Q=; b=j1jnfUAtV2vWmRuJ5Jgh57QoPuZhemX3OTbNYyYgCLXyGNguKJMMFhvRs8WgY+XA/e O9blj/jVpSbbiMR2Z5Jy5xDMNMxf32zKV7B3kkFC0RoIxc4Ax5ItceBChABzTT5IMn5I PYoVerbx72HTvnAjvIleyKColIfxVaM25NNVgYb87b3Jzh2L3C8HipwdLTBOb2JuBDGM nRgfggPVjTT8C8SJuJVyZ5vgG5Wmk/N8YYiiAXiBBhm6mZdbScFnVkV4ydQdfepCYKyZ Ed5NDi/jM7vDFydbS27FsuK17jGfwtGSMBOE5lD4nlMIhLz/loNT8w0OfJE7piwcA7Ik x1Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752373507; x=1752978307; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0V4+PBg0J4+osErg1tBXCHBZKx0hUHnCOBtQn7JJN/Q=; b=AnuLpMqe1hb8gme1GoSTFRu4eU1Ym87qHB6MzkYOnWZoLswN6Nw6c6dV0FvI9r7Fvi OkhYHwt9YbCW4OZEnvMXIMiHvT0MmAWQXyyn8R6oPKlgJl+Psa0n+PbCQ1QVgpft59t7 xr45Zy/e9OGdL4KYqVj9Vk4TvFdzqQog0EobjgJqhGk3Y6yJchjcJTiuCpmfRb9skEFR Oa5VsPH08S2Mmprw/wJI45hreYxKsyYpD7Dago4nTOzKf3i9ollIfkWscbMBdGtNsLzu Nq351ryo9C7RMO/1yx187vme/LWynDeMGCk3JCwsMpLeDChUqhYl74FcomypVnG7wKlI qFEw== X-Gm-Message-State: AOJu0YxFQud2khHv2guieeI4qZOtM5UByI796ZIKYP2XMIAP6bSnuUmp XAibL5rkQ2Jm8j2Zd2jl/hjaCU36hJYsRewjOeBbBEnu47VtVUAULEuLMdcqvQ== X-Gm-Gg: ASbGncvQOnkzrAk96EiBLZsCnFvZlShruPQM/wUNQKc1ZHIUH7HEnaVe5PoOUg06PrY w/KAlbwU3a3RGajFekUhWMEoTw7Pwc8SCPHh7DtVFo+Y6b20Rh+053oDAyQy4O99siLpg0EY3Uy hJmu8ibM9BWEnYY6oMFuqsjjfpSLk07XHtLVDdZo5OReJcjQMmunsPxZWD2C4Fht7x7czeTnJbe XN5IS2y1amNgvaCED9xg7EGIjKJxamYVdK2m+urJ46JkBYDbazqQSxpTCZC6E90uMFeMe0BRfr1 nD+2vCdtCa3HUxOYwBk+Vm2htTBLK621iPKxUomXffN3wTNPj7l0eESnCJ0g3ytNE533syY+OXy pZU7DsO7WTY3E0YwebtpmEr2VNOYHGJsxGWm0lv9LG67OWYbaCdgU8sP3XjO3aVOfQS0= X-Google-Smtp-Source: AGHT+IF9sxiVOTV2W1QllGvxHHrFWbWyh1nBv8/WLYVJwY1NSVfnOglbbEwchRe//ExprhcWd+ii+w== X-Received: by 2002:a05:6602:1609:b0:879:39eb:988f with SMTP id ca18e2360f4ac-87966f0a324mr1324718239f.2.1752373506695; Sat, 12 Jul 2025 19:25:06 -0700 (PDT) Received: from moss-3 (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-50556970df3sm1443364173.90.2025.07.12.19.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jul 2025 19:25:06 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Sat, 12 Jul 2025 18:43:56 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sat, 12 Jul 2025 22:25:05 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: > The only list that I've found a need to extend is the (1) above, so > I wouldn't worry too much about the other two. > > [ Declaring specific macros as "to be expanded for autoload" (as opposed > to marking specific autoloaded macro calls), would still be overall > better, since it would solve the question of "what about macros that > expand to something that also needs expanding". ] That's a good point. It would relieve us of the binary choice of "expand just this form" vs. "expand any and all macros this form expands to", which isn't ideal. But I wonder what the best approach is? A file-local variable, which extends the (1) list only for that file? We _could_ do both: an ;;;###autoload-expand magic comment for "expand this one", and a optional file-local variable, something like `autoload-extra-expand-macros', naming additional macros to expand at any depth[1] (if needed). We could even allow elements of the list to look like (MACRO . FILE) for an additional FILE to define MACRO load (for the evil people), defaulting to `(file)' (meaning: this file). That's some duplication of purpose, and you don't technically need the magic form, but formatting file-local variables is a pain if you don't need them. [1] Would we possibly have to guard against recursive macro definitions? An advantage of "just this next form" expansion is you don't have to worry about that. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 12 22:48:03 2025 Received: (at 78995) by debbugs.gnu.org; 13 Jul 2025 02:48:03 +0000 Received: from localhost ([127.0.0.1]:49474 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uaml0-0001EI-Fe for submit@debbugs.gnu.org; Sat, 12 Jul 2025 22:48:03 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39904) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uamkv-0001D4-LK for 78995@debbugs.gnu.org; Sat, 12 Jul 2025 22:48:00 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C33AF8009A; Sat, 12 Jul 2025 22:47:50 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1752374865; bh=JhMAUW+taUxYdl1V7bSjSEvROgzGDIMvVfbYOzA/wrQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=R6cyGU11gL+Jyi3056BsurWqYMAM3O1DYjXqfId83xr3MRCS4K8ipq0fZBNU3084T q3DEJ+Sal441+EBUCxmyIYClGaRpp9vqkBPa62PkE3L0A8cYRt1T79jFurhlpLP+ZE cEB3e0tmoG2VLEhErXWKihDERIl29XzolHny1B6Ntcg7YJyKt8iIsefKVqnBl/zkau DCpWuRe6PzjagyPPf1q6rDOZm9Cy4NCYBLycGIlxz25hXm4ll/X6iKSdeSw+6X2IKH s+GsA14pEZCLGH7zOLB+EKG5omiusWeHBwrTmUHwc5mYIDgIPGOG+LmjIsVH8II5US aNdtQEt3IpsoQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B034C80387; Sat, 12 Jul 2025 22:47:45 -0400 (EDT) Received: from pastel (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 86052120874; Sat, 12 Jul 2025 22:47:45 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sat, 12 Jul 2025 22:47:44 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.282 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> The only list that I've found a need to extend is the (1) above, so >> I wouldn't worry too much about the other two. >> >> [ Declaring specific macros as "to be expanded for autoload" (as opposed >> to marking specific autoloaded macro calls), would still be overall >> better, since it would solve the question of "what about macros that >> expand to something that also needs expanding". ] > > That's a good point. It would relieve us of the binary choice of > "expand just this form" vs. "expand any and all macros this form expands > to", which isn't ideal. But I wonder what the best approach is? FWIW, I've come to the opinion that what you propose and what I want match different use-cases. The one I care about is when a package provides a (typically autoloaded) macro like `define-minor-mode`, for use by other packages. But what you propose matches the use-case where a package defines its own macro for it own internal use, usually with no intention to autoload it. > A file-local variable, which extends the (1) list only for that file? I'm thinking we should replace the hardcoded list with a symbol property. When defining macros like `define-minor-mode` we'd set this `autoload-macroexpand` property to a non-nil value, and `autoload.el` would simply check the property instead of looking inside the hardcoded list with `memq`. This would work only for predefined or autoloaded macros (where the `autoload-macroexpand` setting would be also pre-defined/loaded), so it wouldn't work conveniently for a locally-defined and locally-used macro, since you'd then need to somehow set the property and define or autoload the macro before `autoload.el` gets to the macro calls. So I think your approach might be a good solution for the case of local macros. I don't know how often we need such a thing, tho. I can't remember bumping into it, but it might be because I'd intuitively avoid it, knowing we don't have support for it. I assume there's a concrete use-case which motivated your patch. Do you mind sharing it? Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 13 09:48:00 2025 Received: (at 78995) by debbugs.gnu.org; 13 Jul 2025 13:48:00 +0000 Received: from localhost ([127.0.0.1]:52545 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uax3f-0004mp-Cq for submit@debbugs.gnu.org; Sun, 13 Jul 2025 09:48:00 -0400 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]:56540) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uax3c-0004mM-1j for 78995@debbugs.gnu.org; Sun, 13 Jul 2025 09:47:57 -0400 Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3e058c64a76so22035315ab.0 for <78995@debbugs.gnu.org>; Sun, 13 Jul 2025 06:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752414470; x=1753019270; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=JFHDJIPT1MkW1b6ITBvScTtQuUhx3kmpAqHHU3lTZt4=; b=g3/x/aKvBYIN5Eq6rrFU4apk1v5bQYsf0WQxVbfiHxXyQ+S1Au4+lHcgtQlDRSxLxM A29YhlpW4Nu3UeMckcnEG4ddlsxy1nxg7TLePaAGkkBqJjvXiIbyoQbZ85bRt6HPEJ0q S7/wX0Z4xAOjHiDyg7YTyUadXbRI/dfZFl7lse+gZPsv5EDmRsFUVJsQmibXj5UFcX2n 2XCXhI18L483LweOg/AjQQ7P6BFR0jN3TqBasWsd2vjJealBRiBjRpfpaukazgNDGvF5 j7zwZ+oJC3GNiZhRsN/oLJFjG6nO2Ap/xopIcUcz14mwBSMJQTjkKDbit+sUQ7whP0GF n3KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752414470; x=1753019270; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JFHDJIPT1MkW1b6ITBvScTtQuUhx3kmpAqHHU3lTZt4=; b=s6jXORxLplmEtYXmI0NMOtr3NXcQcUI0qa1vJ2v0O513FEqpYEsCeveatR99Y/47XG bF7Ee8gv5GQjtKEarUh3SCUrjtzYe86HoxSfueGrVeoqXYOwYblF54BCaZqVYY02N8tr HYDhkSW9MrFgl0Z6693U+pUpxE9OR1Y0riBdSOsEjWWemzhE9nQe01f47ksBQC3Guh+j 6nNfgF8ucsuzhLlo2Zj2m5/1Id54BaADduf3WWBBj4ZKM3l3A22YHjNm9qsETt8bzh4M brjJVhjO+PnGWmwwL0Lwc6p/OLCMspmvGr0jfx1LyONrMiSfi0xVUL6qIxOkYeoLLMia q/Xw== X-Gm-Message-State: AOJu0Ywv3RFezt9tBR3w57vCs8pZMubI3bw/jIxrAWMzmeieNVU32Q0b QuP0yzpNYOX4HHA/oqIpcXEx/Y+awD1myj6OXVG3WlEtOJHUHKodpv+5hblKvQ== X-Gm-Gg: ASbGnctdZuoVJNa1OHhkKQ7eM9tM4iXoWglaiDQhe5tOnHZc1YXcCfCcAXSo+4lNq6G eQQ5XR/g7ULAOy4x9YW8ct8ySmlEu3DqO6DrhhkosPQXcCzwDEMBikhF+6wmzk4SEtSrtp678KO NoMNPgE7C6283OxX3jDz4LWKA2TEByZ3YNYmIQ/iGRx7Nb76IGbkE7NcWAw0Y9DRjGZEE5ymnGd 9AILjfTZRHnrRiNXynNaz1lxrA3fnzUHtNqA6N0kFlQ0UW8vBa99cGgO/6bpggfFc17QkV70qJn n2VCvLn2ZnO+Ih+eaNMikRbrJGQK4e3XP9vtZdsxPaWoTaHid3PU2ZTq76N8kS3MSW8hdOLQluY 1Ld6txUt+z2arSMbWsk+6xbhJRKV91abcYqUploht19Jfmv4Vf0+EjGyt X-Google-Smtp-Source: AGHT+IGGW8e7vbv2iZC0Dpqt0kvmS2CyFdLNbXIM4j5Tu9FLN1f9IuIliITeDn9vS5unw2rY185hrg== X-Received: by 2002:a05:6e02:3809:b0:3df:52fc:42ea with SMTP id e9e14a558f8ab-3e2542faf08mr71513465ab.13.1752414469602; Sun, 13 Jul 2025 06:47:49 -0700 (PDT) Received: from moss-3 (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-506cb96d6a4sm53487173.56.2025.07.13.06.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jul 2025 06:47:49 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Sat, 12 Jul 2025 22:47:44 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sun, 13 Jul 2025 09:47:48 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> A file-local variable, which extends the (1) list only for that file? > > I'm thinking we should replace the hardcoded list with a symbol > property. When defining macros like `define-minor-mode` we'd set this > `autoload-macroexpand` property to a non-nil value, and `autoload.el` > would simply check the property instead of looking inside the hardcoded > list with `memq`. Oh, this is much better! It relieves the _user_ of the macro the burden of remembering to "auto-load it correctly." For macros which are defined in every session, you're done. No special autoload-expand magic comment needed. It also makes it possible to entirely eliminate hard-coded list #1. You'd just need to insert, e.g.: (put 'defun 'autoload-macroexpand t) where the special macros are _defined_. This would be a a bit more self-documenting too. We'd leave the "function-like operator" hard-coded list, but it could probably be trimmed down with the new `autoload-macroexpand' feature. For example, `transient-define-prefix' boils down to a defalias, which is already supported. > This would work only for predefined or autoloaded macros (where the > `autoload-macroexpand` setting would be also pre-defined/loaded), so > it wouldn't work conveniently for a locally-defined and locally-used > macro, since you'd then need to somehow set the property and define or > autoload the macro before `autoload.el` gets to the macro calls. We could be aggressive about it. If the car of some form encountered during file scanning (including expansion) is a macro, we check its `autoload-macroexpand' property and act accordingly. But if it not already a known special-form, function, or macro, we load the file to see if that defines it. If it _remains_ undefined, we just include the whole form in the autoload file, just as we do now (generating a warning). But if loading the file _did_ define it as a macro, we check its `autoload-macroexpand' property, and proceed as before. I was curious how many existing ;;;###autoloads this would affect, since I almost always see it used with `defun' or `define-minor-mode'. I looked through the entire emacs-30 lisp codebase[1] and could only find `define-erc-module' as the car of a top-level autoload form which wasn't already a known function, macro, or special form. I repeated this exercise among my 171 installed packages, and found only: Unknown autoload car: cape-char--define Unknown autoload car: define-erc-module Importantly, in all of these cases, they are actually using adorned magic comments, like: ;;;###autoload (autoload 'cape-tex "cape-char" nil t) (cape-char--define tex "TeX" ?\\ ?^ ?_) so not relevant to our proposal (except that they could be improved by it.) > I assume there's a concrete use-case which motivated your patch. > Do you mind sharing it? I have a large package in development which has a flexible extension system. I'd like to enable "3rd-party" extensions with a convenience `define-extension' macro. In addition to defining a minor mode, this macro will generate various `(put some-extension-mode ...)' statements, which themselves need to be auto-loaded, as they are used to determine when to load the extension (including, possibly, at package load time). [1] Here's the distribution of pure ;;;###autoload forms in the emacs-30 codebase: defun: 3226 defcustom: 181 define-minor-mode: 173 define-derived-mode: 157 defmacro: 130 defalias: 101 put: 88 defvar: 74 define-obsolete-function-alias: 27 defvar-local: 20 define-overloadable-function: 19 cl-defgeneric: 19 defconst: 15 define-globalized-minor-mode: 15 progn: 12 defclass: 8 add-to-list: 8 cl-defun: 8 defsubst: 7 cl-defmacro: 5 define-mail-user-agent: 4 or: 3 pcase-defmacro: 3 define-global-minor-mode: 2 make-variable-buffer-local: 2 eval-after-load: 2 dolist: 2 define-key: 2 unless: 1 autoload: 1 def-edebug-elem-spec: 1 defvar-keymap: 1 define-inline: 1 when: 1 define-compilation-mode: 1 define-skeleton: 1 let: 1 fset: 1 setq: 1 Created with: rg -IA 1 -t elisp '^;;;###autoload *$' | perl -ne '$AL{$1}++ if /^\(([^ ]+) /; END { foreach $k (reverse sort { $AL{$a} <=> $AL{$b} } keys %AL) {print "$k: $AL{$k}\n"}}' From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 13 11:19:33 2025 Received: (at 78995) by debbugs.gnu.org; 13 Jul 2025 15:19:33 +0000 Received: from localhost ([127.0.0.1]:54371 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uayUH-0005b9-6Q for submit@debbugs.gnu.org; Sun, 13 Jul 2025 11:19:33 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:15186) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uayU9-0005aG-Ps for 78995@debbugs.gnu.org; Sun, 13 Jul 2025 11:19:30 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 49A8780119; Sun, 13 Jul 2025 11:19:17 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1752419955; bh=YSt1+7Ea3amFXmLxuvBm/tDtt8bdeK1YWCdWCH9MwfI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=SM/FI5kyAM5d7BO6ltIFIRMmZ+A8J11M/aQpw0xGAfLcTWzCZnmZ5Zorq4KbTw3vJ 9VRMUZVT5rpHnlPbgsNR+Oey6T60goG1kY/dJ0KnGGr3kq/73dgjA0WIpSrIZOEraR Tpz9bI09rLxuyB/Rlqry8BSvXWmBwtVoVYQN6FdzRV1SO+B3/3kg4cTXxTyOHCrrBE mEPlGlr+uGv5E5Dn3bOMStr5yrFFbFrYnNDC8MVlUaCcjPy+7VBVVcN+mLiwGJCYVu 4W140LCQVZEczV38jZL8urW0ZBYnlhAf9F/zPFORV5WiLH94NosVyMeRCZ58G5fwte s+x5aPKo4wODg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E664D801F6; Sun, 13 Jul 2025 11:19:15 -0400 (EDT) Received: from pastel (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BB454120874; Sun, 13 Jul 2025 11:19:15 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sun, 13 Jul 2025 11:19:08 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.280 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >>> A file-local variable, which extends the (1) list only for that file? >> I'm thinking we should replace the hardcoded list with a symbol >> property. When defining macros like `define-minor-mode` we'd set this >> `autoload-macroexpand` property to a non-nil value, and `autoload.el` >> would simply check the property instead of looking inside the hardcoded >> list with `memq`. > > Oh, this is much better! It relieves the _user_ of the macro the burden > of remembering to "auto-load it correctly." For macros which are > defined in every session, you're done. No special autoload-expand magic > comment needed. It also makes it possible to entirely eliminate > hard-coded list #1. You'd just need to insert, e.g.: > > (put 'defun 'autoload-macroexpand t) > > where the special macros are _defined_. This would be a a bit more > self-documenting too. Yes, tho we'd probably define a `declare` thingy so you wouldn't write the `put` but you'd write (defmacro define-minor-mode ... (declare (... (autoload macroexpand) ...)) ...) > We'd leave the "function-like operator" hard-coded list, but it could > probably be trimmed down with the new `autoload-macroexpand' feature. > For example, `transient-define-prefix' boils down to a defalias, which > is already supported. Ah, yes, I had not noticed that `transient-define-prefix` had been added there, and now that I see it, it does make it seem like my impression that it was unimportant may have been wrong. Usually macroexpanding those things is enough (the macro can be defined appropriately). We could still refine the above with something like: (defmacro transient-define-prefix ... (declare (... (autoload function) ...)) ...) tho this probably needs more thought/design because we need more info (where's the name of the defined thing, whether it's a macro or a function, what's the list of arguments, ...). >> This would work only for predefined or autoloaded macros (where the >> `autoload-macroexpand` setting would be also pre-defined/loaded), so >> it wouldn't work conveniently for a locally-defined and locally-used >> macro, since you'd then need to somehow set the property and define or >> autoload the macro before `autoload.el` gets to the macro calls. > > We could be aggressive about it. If the car of some form encountered > during file scanning (including expansion) is a macro, we check its > `autoload-macroexpand' property and act accordingly. But if it not > already a known special-form, function, or macro, we load the file to > see if that defines it. Oh, yeah, neat. > Importantly, in all of these cases, they are actually using adorned > magic comments, like: > > ;;;###autoload (autoload 'cape-tex "cape-char" nil t) > (cape-char--define tex "TeX" ?\\ ?^ ?_) > > so not relevant to our proposal (except that they could be improved by > it.) Yes, these are the ones that "document" a need for the new feature. Stefan diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 6412c8cde22..654b67ada1b 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -286,6 +286,11 @@ (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload-macro + #'(lambda (name _args spec) + (list 'put (list 'quote name) + ''autoload-macro (list 'quote spec)))) + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -365,8 +370,10 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + (list 'autoload-macro #'byte-run--set-autoload-macro) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 8a131bf885f..b8dfe095589 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -198,19 +198,20 @@ (when exps (cons 'progn exps))))) ;; For complex cases, try again on the macro-expansion. - ((and (memq car '( define-globalized-minor-mode defun defmacro + ((and (or (eq 'expand (get car 'autoload-macro)) + (memq car '( define-globalized-minor-mode defun defmacro define-minor-mode define-inline cl-defun cl-defmacro cl-defgeneric cl-defstruct pcase-defmacro iter-defun cl-iter-defun ;; Obsolete; keep until the alias is removed. easy-mmode-define-global-mode easy-mmode-define-minor-mode - define-global-minor-mode)) + define-global-minor-mode))) (macrop car) (setq expand (let ((load-true-file-name file) (load-file-name file)) (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) + (not (eq car (car expand)))) ;; Recurse on the expansion. (loaddefs-generate--make-autoload expand file 'expansion)) From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 13 15:01:18 2025 Received: (at 78995) by debbugs.gnu.org; 13 Jul 2025 19:01:18 +0000 Received: from localhost ([127.0.0.1]:55506 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ub1wr-0004wD-Ot for submit@debbugs.gnu.org; Sun, 13 Jul 2025 15:01:18 -0400 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]:61709) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ub1wp-0004vf-DH for 78995@debbugs.gnu.org; Sun, 13 Jul 2025 15:01:16 -0400 Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-3da73df6b6bso13498855ab.3 for <78995@debbugs.gnu.org>; Sun, 13 Jul 2025 12:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752433269; x=1753038069; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=PLpRrjKKLgkzORAlS/QdKOmN57MA28VjF+KQbVwDEnY=; b=BldadyYZC95yD9CuIq55t/36t2rxkIDy6nzVhOIoB+m3zjlC+FCsIJ4qa6msuMRXUF CBPvhlUgCNed6iyxEbWj2pKm4O2xwdD3d4A9p1h+NI+G5y20vBZxhEyJ+6kCDn2DuUug wc8h/Vs+PX0Dj7h+xXpNQNxRNoU+x03abswUa+k3R/pIJ+Dt7u6O5jOcLfCzGJ87e1/l +tnlhDLEY3OKAGoW5hBh9dJr5P2e4gKHlIcSS2JATJhR5d9MbkXnswiILmiOsvSggS8i sY5Fh83+SacyRh5ZLkGBkKoxfmQpVKIY7NziOUyX3rKc+P1Q7OkP1XvD/4VUPMI4kBVg Lxlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752433269; x=1753038069; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PLpRrjKKLgkzORAlS/QdKOmN57MA28VjF+KQbVwDEnY=; b=uXPWf3/FeNhxDLb21b+lSGItUh8YNLy6+iPrj0+qZOpufEufekd7RBKdPjzsLitPYe bmOnNV7CArl+0lyo32qLW72XY0YQ/ThI0x8shygnB9n9JRey/VQGFmardtTL19S0b9WN bpBkIKUe0zll4b2FmGvc31dGBGh5zvaLnAnQuzeW62dn5VCfUH2fyubQz/7Ijyj4jVVK CF2zCqISxqhNzWUPVasPmh38krEJPHRKUYsGIPBFjazoZ8mZWQLy5JYxxrJj3ceeng8I NZqIzaJ+Dk7cK+eeuB5ccT8QNgt3hMHuYx6ZnQmfaK5VBaYGENX5s4uEjwxw4rbcPt/E UKzg== X-Gm-Message-State: AOJu0YwJNwXkLLgBc/KmHnIUqdA+nqzXEzDxQSCO8Yq1JUpxb/Pab1s7 ykwYzzeWtziUA/aCmH4n1lh1vEhIkHN8pK2j5IGtU43e3Qlv7hJ2MDIrxOonTw== X-Gm-Gg: ASbGncvByHzdql502itEnUZUQjOSdjUm9pbtCU4rrZMemA0aK9APr598DUmtivYn2BP AONs9LJcory70mtemOY8Zn4SQwz94dug0+XAXWgpMQo8N9N1uXb1TOQ8PguSvmI33xTsdU6Ix4t menX6HiD6oD1M+ZICodOrrGhnhhqeOy/2nzW1RfOJIMuMOAR8MZPgKV9DRLrBPgOBK+CW2WZnwb vi94/cThwyY6crZolKzkthyqZEqX2MjnmPccdxu/8pVN2GaQb+OD4IkSJadgyBfErBJV/1xlBH7 jIkUTtVQnszBkUh2g8GbstCLNy/xnSAbPZe28GtaE7Kcp42VtYIgu5VepUtg+y4oTgJxSmcJ/cs srL3910/nN8oUh72i0LzH5e3hO+X6B4TLZgp0ePD8Ap7MQ2WxRxtNtIgt X-Google-Smtp-Source: AGHT+IH6MyeZGR2WMxg5DjNhWGOkdbFRTHmZbXxrOtqs7QkqBikD4BqBpK35zDi0pWvZqXkH21Akkw== X-Received: by 2002:a05:6e02:2193:b0:3df:3154:2e90 with SMTP id e9e14a558f8ab-3e25429f52dmr102949075ab.19.1752433268944; Sun, 13 Jul 2025 12:01:08 -0700 (PDT) Received: from moss-3 (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-50556b0f297sm1751909173.122.2025.07.13.12.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jul 2025 12:01:08 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Sun, 13 Jul 2025 11:19:08 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sun, 13 Jul 2025 15:01:07 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> You'd just need to insert, e.g.: >> >> (put 'defun 'autoload-macroexpand t) >> >> where the special macros are _defined_. This would be a a bit more >> self-documenting too. > > Yes, tho we'd probably define a `declare` thingy so you wouldn't write > the `put` but you'd write > > (defmacro define-minor-mode ... > (declare (... > (autoload macroexpand) Wow, this is even nicer! Never knew those `delare's were so simple. >> We'd leave the "function-like operator" hard-coded list, but it could >> probably be trimmed down with the new `autoload-macroexpand' feature. >> For example, `transient-define-prefix' boils down to a defalias, which >> is already supported. > > Ah, yes, I had not noticed that `transient-define-prefix` had been added > there, and now that I see it, it does make it seem like my impression > that it was unimportant may have been wrong. > Usually macroexpanding those things is enough (the macro can be defined > appropriately). We could still refine the above with something like: > > (defmacro transient-define-prefix ... > (declare (... > (autoload function) I mean `defalias' is supported because `defun' expands to it. Isn't that enough? I guess some macros are complex enough you want to take the quick short cut and turn them right into an `(autoload ...)' statement, without having to design them carefully? > tho this probably needs more thought/design because we need more info > (where's the name of the defined thing, whether it's a macro or > a function, what's the list of arguments, ...). The code in `--make-autoload' seems to think it knows how to handle all those "function-like operators". But list 1 and list 2 seem to be disjoint. E.g. `transient-define-prefix' is on list 2, but _not_ on list 1. So it would like to be treated as a function operator, but not expanded. Actually I'm confused about that logic. Take `define-minor-mode'. It's on list 1 (expand the macro) and list 2 (treat it as a function operator). I don't see how it could ever get list 2 treatment, since it always would have been expanded first by the list 1 logic above. There are many macros in the 1 & 2 category: ;; Expand but don't treat as a special function (1, not 2): (defun defmacro define-inline cl-defgeneric cl-defstruct pcase-defmacro iter-defun cl-iter-defun) ;; Only treat as a special function op (2, not 1): (define-skeleton define-derived-mode define-compilation-mode define-generic-mode defun* defmacro* define-overloadable-function transient-define-prefix transient-define-suffix transient-define-infix transient-define-argument) ;; Expand _and_ treat as a special function op (1 & 2): (define-skeleton define-derived-mode define-compilation-mode define-generic-mode easy-mmode-define-global-mode define-global-minor-mode define-globalized-minor-mode easy-mmode-define-minor-mode define-minor-mode cl-defun defun* cl-defmacro defmacro* define-overloadable-function transient-define-prefix transient-define-suffix transient-define-infix transient-define-argument defun defmacro define-inline cl-defgeneric cl-defstruct pcase-defmacro iter-defun cl-iter-defun) What am I missing? From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 13 18:49:42 2025 Received: (at 78995) by debbugs.gnu.org; 13 Jul 2025 22:49:42 +0000 Received: from localhost ([127.0.0.1]:56691 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ub5Vt-0007Wo-NO for submit@debbugs.gnu.org; Sun, 13 Jul 2025 18:49:42 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:5617) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ub5Vq-0007W1-Te for 78995@debbugs.gnu.org; Sun, 13 Jul 2025 18:49:39 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B0BEA807F1; Sun, 13 Jul 2025 18:49:32 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1752446971; bh=WrHeU3DMaq4zseX0KNrhE7EQ4K18BXPJK9ZMUto8Ook=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Kjj+W+hOIAx9QU09fVOKMq727xmLyBTMODX1rGxoYVBEs+ct2IOEpmMiGwW0j2KQR LeROhZhlmQwnseFVpDv40dsTrObrCURwnI935Unfm0bEOyvGsr7476TxBHodr9Yx5y 7N8pMpNNGsltAUbamC2pIqFKp/Lm36Gm3rWoVU/sSg3P7H8Di4/YTxHBbKWUMnMUwc uUCwHrbtQ0nWkM90z8/LLFEdUpvLBJOe2wxNaEpXv++HAOQ5YYT+4bkLqADzt/MX4Q 0Q1fu7Q74u0FsguZfcJ/d2jomYF3V1ndissbYe2CmscS92OiUSqZg0Ah2rntclTUpj QTrL2K8O5DSDQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4C4A08001E; Sun, 13 Jul 2025 18:49:31 -0400 (EDT) Received: from alfajor (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1C69512059D; Sun, 13 Jul 2025 18:49:31 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sun, 13 Jul 2025 18:49:30 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.280 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> (defmacro define-minor-mode ... >> (declare (... >> (autoload macroexpand) > > Wow, this is even nicer! Never knew those `delare's were so simple.=20 =F0=9F=99=82 [ Of course, third-party code would have to use `put` in the short term for backward compatibility reasons. =F0=9F=99=81 ] >> (defmacro transient-define-prefix ... >> (declare (... >> (autoload function) > > I mean `defalias' is supported because `defun' expands to it. Isn't > that enough? Yes, I think we could mark `transient-define-prefix` as `expand`. My understanding is that currently putting it in "list 1" wouldn't work simply because it's not autoloaded. > The code in `--make-autoload' seems to think it knows how to handle all > those "function-like operators". But list 1 and list 2 seem to be > disjoint. E.g. `transient-define-prefix' is on list 2, but _not_ on > list 1. So it would like to be treated as a function operator, but not > expanded. As mentioned above, I think it's just because of a lack of autoloading. > ;; Expand _and_ treat as a special function op (1 & 2): > (define-skeleton > define-derived-mode > define-compilation-mode > define-generic-mode > easy-mmode-define-global-mode > define-global-minor-mode > define-globalized-minor-mode > easy-mmode-define-minor-mode > define-minor-mode cl-defun > defun* > cl-defmacro > defmacro* > define-overloadable-function > transient-define-prefix > transient-define-suffix > transient-define-infix > transient-define-argument > defun defmacro define-inline > cl-defgeneric > cl-defstruct > pcase-defmacro > iter-defun > cl-iter-defun) I don't see `cl-defstruct` in list 2 (same for several others), so I think the above list isn't right. But yes, some are in both lists and it's mostly "historical accidents". IIRC `easy-mmode-define-minor-mode` started in list 2 and was later added to list 1 so as to get a better result (e.g. more complete docstring) in those cases where the macro happens to be defined. But I think your trick of evaluating the file (to cause the macros to be defined) should allow us to focus on list 1 and leave only the strict minimum in list 2. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 13 20:05:18 2025 Received: (at 78995) by debbugs.gnu.org; 14 Jul 2025 00:05:18 +0000 Received: from localhost ([127.0.0.1]:57209 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ub6h4-0005kV-3d for submit@debbugs.gnu.org; Sun, 13 Jul 2025 20:05:18 -0400 Received: from mail-il1-x12c.google.com ([2607:f8b0:4864:20::12c]:42268) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ub6h1-0005fk-F1 for 78995@debbugs.gnu.org; Sun, 13 Jul 2025 20:05:16 -0400 Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-3df210930f7so15211365ab.1 for <78995@debbugs.gnu.org>; Sun, 13 Jul 2025 17:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752451509; x=1753056309; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=tMkLywxixLBgOW1vRQtieTJ8VFONkM0VJqFaa9DMJqg=; b=KW38pCQzzUwspq9z01dmQPvzzOiDwvSViDPq4c8SDfEKcIpPYoRbo6TBGlG66nbjzh fx3Cb4urMdlf9aRV04BsWS10IgNToyjW31AFsF7ecYaeyiduo4sY0emDpuMr43h7uT3+ UvRAelLn+sKjBJ3qgn83bcK/MiVKlRohasvKMt0TCHRO74p8ZPJdNGwvquCPap4ClLWx XL7bGvzNly40I5HhhuH6m0MZBhCCnaEph9+SDOweT2cdwVHuG6dbOIxsHVUxFOQbcTv6 IDLItGcGBx3FU223cM81nfZy//PQrFk1jxUuUnFNbctLtiep/T49y94AAz6Xct+eZiXJ 3uJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752451509; x=1753056309; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tMkLywxixLBgOW1vRQtieTJ8VFONkM0VJqFaa9DMJqg=; b=Z9UM+mvsRvEr7rhtoPLUbIXRFJ1RgH+MImPmr9URpM1sdcrKoQ2iSTsX6t/7Ks4XU1 Hc4HNol4QOMiJFCY/mKPrhMmEHHUw9mZkellBzDnccDk+IKAcdTFvxSAACVlrg8IZF7I 0UbaGRRDlZjQ+HCuixdGSbtTn05C9Vl+FvnmRbK0rUnHyMXBOfKX2Qc0ilYqV5mTIEvA jy9YKumdRFwo99I88hYLBU1bU4MQoKq7FiTEwKvnjJVYxfvjWhPqMtT53RYLoxhw0PbP XvJnlGm2ozj/5ZL2ZU3SLJQ0hvlrIQ4pXDhDzyHjBwn8jP5wy/lV2ev5RTIE6qxYg1xE sSKw== X-Gm-Message-State: AOJu0YzFnJXfTEpPoxl6/B1XklXB79yRICzgPA0RPCuTtJeRh05h9Vcw rj4NWl1LVhjuzpAz4HG/Dyx1oJmgWJ6rvyRb05Os78GmC/R2lX7bw62910/xfg== X-Gm-Gg: ASbGncutsZeCSUkiKSXn8f7BYxFPod+bbs4jwzIpe8Lauhb4KQNtqxOOW2VXXbCF5qc BEW45CMGIzH0YUCgr5UcWlWpvDTe9aDnk9fpOPhRKBHxiF4ljQKcMZa4rN9I09kbKMkeRygkcr/ af2RXtLSVg8bTQRcytrMb3MtFdJiZ6c4En5ZnXrAbnejI2MUWNOH5CCXdyoHZPObvuYX8tAdOfQ nvYUQKUWBxL0X6cTwi0GMAhQHm7GVVs185Vtlw+EIEu9dofXlzIP3VLFZ27CzwA5Wer3fCey3Gp SzbhaA5VhIKMTFwT8drNwMQ51PudBdlU7Ii/VpaDt0h394RqIBLjr2X6DfnyDsMVQkpboblfQWk c5XnL3M/cXJ/QGGnXyGe5X/BTPMolxc8m8xASSCBy+qkZ9yQNHmOzf6oS X-Google-Smtp-Source: AGHT+IHcJWFKuAdRkh7VU74IPafGPqBl9Cit20mHqUKlYZWkCu9pawNbCv/iZnuZBzo0C27VhBCVGw== X-Received: by 2002:a05:6e02:1a88:b0:3dc:7b3d:6a45 with SMTP id e9e14a558f8ab-3e2534478c4mr109901235ab.0.1752451509064; Sun, 13 Jul 2025 17:05:09 -0700 (PDT) Received: from moss-3 (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3e24627788asm26000415ab.70.2025.07.13.17.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jul 2025 17:05:08 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Sun, 13 Jul 2025 18:49:30 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sun, 13 Jul 2025 20:05:07 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: > I don't see `cl-defstruct` in list 2 (same for several others), so > I think the above list isn't right. Oops, wrong set function. It's: ;; Expand and treat as function op: (easy-mmode-define-global-mode define-global-minor-mode define-globalized-minor-mode easy-mmode-define-minor-mode define-minor-mode cl-defun cl-defmacro) > some are in both lists and it's mostly "historical accidents". Makes sense. > But I think your trick of evaluating the file (to cause the macros > to be defined) should allow us to focus on list 1 and leave only the > strict minimum in list 2. I will work up a patch using this approach unless you'd like to (will be a few days min). I think we are in agreement that a simple (autoload macroexpand) will suffice. We could leave list 2 as-is for now, with a note that it can be trimmed once `declare' for list 1 is fully operational. Probably would also need to loop in package authors, e.g. for transient, to ensure they are aware of the change. From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 13 22:32:10 2025 Received: (at 78995) by debbugs.gnu.org; 14 Jul 2025 02:32:10 +0000 Received: from localhost ([127.0.0.1]:57821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ub8zC-0001aS-0Z for submit@debbugs.gnu.org; Sun, 13 Jul 2025 22:32:10 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:18085) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ub8z8-0001Za-IH for 78995@debbugs.gnu.org; Sun, 13 Jul 2025 22:32:07 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 3175580966; Sun, 13 Jul 2025 22:32:00 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1752460319; bh=KNDNvULzUGvknj6GNaQEDKMukTVo59a33WygurOsTVw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=GRj+HSxQspZVHv+XD1HzOFcAIArg/y8365A0XVVN9TOBFG+EPSxCy3AKUV8oLsknt +kH8Am5PyhD8h/ngGn2VveIq6RzUCQyyAicNbJcJBpPRI81eVhm9gCopm66GJg7jHW zNVOCJCXs48weAVMU1BdCPBb794qSYPO3BEvjL5JFZMveEHNeND5fmjf8eReJ6h4cC X2d8Kv9RorcycBm9ypwT99Yzir19VZvQ5IBb1l48s4r9VUJ/4GoF+gElFKF0EfqOde HCm/deNUPKOwevFThUFA/DcB3oL9pVIs5G3fQ70PChvit9RJXcfunxuZZ68fVJgXMu YuLEy99QKpJ0g== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5820F8013C; Sun, 13 Jul 2025 22:31:59 -0400 (EDT) Received: from pastel (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 301C71209F7; Sun, 13 Jul 2025 22:31:59 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sun, 13 Jul 2025 22:31:58 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.279 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I will work up a patch using this approach Sounds good. =F0=9F=99=82 > I think we are in agreement that a simple (autoload macroexpand) will > suffice. We could leave list 2 as-is for now, with a note that it can > be trimmed once `declare' for list 1 is fully operational. > > Probably would also need to loop in package authors, e.g. for transient, > to ensure they are aware of the change. I think we can start by removing those entries that we can turn into `declare` directly in Emacs (e.g. not those for Transient). And then wait for the relevant package authors to start using the new functionality before we remove the rest, bit by bit. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 15 23:36:10 2025 Received: (at 78995) by debbugs.gnu.org; 16 Jul 2025 03:36:10 +0000 Received: from localhost ([127.0.0.1]:46648 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ubswD-0007yT-AL for submit@debbugs.gnu.org; Tue, 15 Jul 2025 23:36:10 -0400 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]:45395) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ubsw6-0007xY-6n for 78995@debbugs.gnu.org; Tue, 15 Jul 2025 23:36:06 -0400 Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-879399faac9so470567039f.3 for <78995@debbugs.gnu.org>; Tue, 15 Jul 2025 20:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752636956; x=1753241756; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=n32CI8lGzZNnMyyExgu6HSDYzllykE2YiJvTzi/z84I=; b=KrKPSq5iH1M3hu3BtE/p1eVxlprhWutZUi89FrSmJLMmP0Eofku0xq6yxiNU9lCptv o+KAkBS3lwfICkwvxuyGroOR7wwcid0levKUJov5KPTxqF7LlpAkHqXy8DYGCK6RkUGC okVAF0Rqimfbt1j/4FZcsbIj5u4a1wvZZFxPR2xFNtYWmdCc5AJkzAOyoMsSRh9OiNW5 jhCeDsUiJslTxOYRPR/fnSLIBaRV4ZwjAh7SjH3amJG2qtQe1mbtIXJJofgwaXWEWr1r HI1OtT0brOgAHTwga/IG20IWUoSCpEHSVdgGAglR0RpD4tcGVUK8qtTmFYrAthOjJf10 1gRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752636956; x=1753241756; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=n32CI8lGzZNnMyyExgu6HSDYzllykE2YiJvTzi/z84I=; b=DyffAVXNVxgykXFGU9ftJGv1qHtFAl6GcIP6DxULlctU+G88ve0uNlR2idzrVAHMs0 qZqf2ZWvHIA5P1MYyszSNH6oOD/+mSDmLKiINhKVSEFpx2STLHBcVARiXzNhxab3LWDB 2NYmFRrFz/NjXKd4I7NYH3Ik425EiigSkJNOqxOw9rMzNnDpc2tqHstRfhzbDR/sHk/W ic0oxaRn9HGsG16crY+Oc4ph8Uzws3bA1K/EzQBr71zVi5nqJlnHO7cxykqY87C4pqBX oxKk2IvRd3dv0VrxEmBhN8hPQrtN502H6dqQmRSSPCmAWgDp9XSLEnk+kehlzxkrXdTe ZV3A== X-Gm-Message-State: AOJu0YxxfcySxqAmAO9ii8zVDjrXJb2mu8hn/CxxForgAo3ZR73gugir wG2QQMUDRYJaD6p+GwqedrTV7VS4frpb1H7q/ID/c2MN5CXRb2FTJ0ZI X-Gm-Gg: ASbGncsLU4/T5lmndh82FfJFrrC+7APR+sk506qglDfOogVOgN44gPeWNG/uDL7piPv fM0u4PliqEBzNjFM7E7G6SnI+F+9IOYXSHrYRFOKhA5X6MGaxyS6GVoklm/V7KcR1V5ZjPAAV8M VrDG/0dP8i/mY1qmtXfa7dLFjtomCEvplUgEMdPMImrOWvGsRz+t3WrZxhclbwpms8zhk8HXi93 64h+vd4QTnh83rhnjphZKR1bfj+nvNbAeDqiFmCW4ie/4/4MYl2wilIEhCBSS+MVYYHbTmxzu8j v9EyYsUiQjtHUSSFVLKuhoBzmbIa+MHj28sn7SvtelS/8Kh5smXQKCqrONqG9fbs+8j5mQlmod+ EGXeaCrs0sqh6ZNT/dCQvYkH+yIMNF2mz3q6OqxOibO/v3gIaufPB+5xI X-Google-Smtp-Source: AGHT+IEWCiiMNFUmaVL/3D929Ua82yy3e35xVBh+K8l6caklkU5jfpMHVlWhgCPtfcD9s0ja2D57wA== X-Received: by 2002:a05:6602:340b:b0:86d:5f:aef4 with SMTP id ca18e2360f4ac-879c07cab82mr229122739f.0.1752636955893; Tue, 15 Jul 2025 20:35:55 -0700 (PDT) Received: from moss-3 (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-50556b14173sm2765762173.130.2025.07.15.20.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jul 2025 20:35:55 -0700 (PDT) From: "J.D. Smith" To: 78995@debbugs.gnu.org, Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> (JD Smith's message of "Fri, 11 Jul 2025 15:28:03 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Tue, 15 Jul 2025 23:35:54 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Here is an update on progress. The attached is working reasonably well, reproducing lisp/loaddefs.el with a few changes (see attached). I went with (declare ((autoload . macro-expand))) on the notion that there might be other autoload-related declarations in the future, but open to suggestion. I've now fully eliminated list 1 in favor of declare statements, but also had to handle the case of _aliased_ macros, e.g. all the [easy-mmode]-define-global[ized]-minor-mode yada yada. There are a couple things I need to check on. 1. Non-repeatable loaddefs: When you re-run make and it needs to regenerate lisp/loaddefs.el, it appears easy-mmode is _not_ loaded by whatever emacs process conducts that subsequent autoload-generation round. Consequently, `define-minor-mode' isn't loaded, so calls to it produce only partial autoload entries (via, I believe, list 2). Maybe that's why list 2 duplicates entries from list 1, as a backup against this non-repeatable build. But it seems strange to have different packages loaded on different passes of the same Makefile target. You can confirm this by: % mv lisp/loaddefs.el lisp/loaddefs_orig.el % make % diff -u lisp/loaddefs_orig.el lisp/loaddefs.el I'm not clear if this has anything to do with this patch, or could even be a pre-existing build bug. Once you are in this situation, you basically have to `make bootstrap' to get the full and complete autoload statements to appear again in loaddefs. 2. Some files are now being loaded during autoloads generation: I noticed a few files among bundled lisp packages that now get loaded, because they autoload undefined macros: loaddefs-gen: loading file frameset (cl-defun) Loading frameset... INFO Scraping 1565 files for loaddefs...15% loaddefs-gen: loading file ede/cpp-root (defclass) Loading ede/cpp-root... INFO Scraping 1565 files for loaddefs...25% INFO Scraping 1565 files for loaddefs...47% INFO Scraping 1565 files for loaddefs...64% loaddefs-gen: loading file tramp-adb (tramp--with-startup) Loading tramp-adb... INFO Scraping 1565 files for loaddefs...80% loaddefs-gen: loading file grep (define-compilation-mode) Loading grep... These mostly seem to be innocuous in that after loading them, it becomes clear that these particular autoloaded macros don't request macro-expansion, so nothing different happens. But it does represent a few new "internal" load calls during autoload generation. I think list 1 is now "doing more work" because of this pre-load mechanism. Thoughts and suggestions very welcome. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=autoload-expand_2.patch Content-Description: A WIP Patch for autoload expand diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 366423904db..d2781021003 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -271,6 +271,12 @@ 'byte-run--set-debug (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload + #'(lambda (name _args spec) + (list 'progn :autoload-end + (list 'function-put (list 'quote name) + ''autoload (list 'quote spec))))) + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -350,8 +356,10 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + (list 'autoload #'byte-run--set-autoload) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -397,6 +405,7 @@ 'defmacro (if declarations (cons 'prog1 (cons def (car declarations))) def)))))) +(function-put 'defmacro 'autoload 'macro-expand) ; Since we cannot `declare' it ;; Now that we defined defmacro we can use it! (defmacro defun (name arglist &rest body) @@ -409,7 +418,7 @@ defun The return value is undefined. \(fn NAME ARGLIST [DOCSTRING] [DECL] [INTERACTIVE] BODY...)" - (declare (doc-string 3) (indent 2)) + (declare (doc-string 3) (indent 2) (autoload macro-expand)) (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 3aa26fba3c3..1546da08ec2 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -258,7 +258,8 @@ cl-defgeneric cl--generic-edebug-make-name in:method] lambda-doc def-body)]] - def-body))) + def-body)) + (autoload macro-expand)) (let* ((doc (if (stringp (car-safe options-and-methods)) (pop options-and-methods))) (declarations nil) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2a0a9e5c6de..27db30f414e 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -398,7 +398,8 @@ cl-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload macro-expand)) `(defun ,name ,@(cl--transform-lambda (cons args body) name))) ;;;###autoload @@ -416,7 +417,8 @@ cl-iter-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload macro-expand)) (require 'generator) `(iter-defun ,name ,@(cl--transform-lambda (cons args body) name))) @@ -475,7 +477,8 @@ cl-defmacro (declare (debug (&define name cl-macro-list cl-declarations-or-string def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload macro-expand)) `(defmacro ,name ,@(cl--transform-lambda (cons args body) name))) (def-edebug-elem-spec 'cl-lambda-expr @@ -3011,7 +3014,8 @@ cl-defstruct sexp])] [&optional stringp] ;; All the above is for the following def-form. - &rest &or symbolp (symbolp &optional def-form &rest sexp)))) + &rest &or symbolp (symbolp &optional def-form &rest sexp))) + (autoload macro-expand)) (let* ((name (if (consp struct) (car struct) struct)) (warning nil) (opts (cdr-safe struct)) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index f53db48f0b7..cd36a56a89a 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -222,10 +222,11 @@ define-minor-mode (indent defun) (debug (&define name string-or-null-p [&optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp] + &optional [¬ keywordp] sexp + &optional [¬ keywordp] sexp] [&rest [keywordp sexp]] - def-body))) + def-body)) + (autoload macro-expand)) (let* ((last-message (make-symbol "last-message")) (mode-name (symbol-name mode)) @@ -487,7 +488,7 @@ define-globalized-minor-mode on if the hook has explicitly disabled it. \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" - (declare (doc-string 2) (indent defun)) + (declare (doc-string 2) (indent defun) (autoload macro-expand)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 344e11e245e..0770a66f78d 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -675,7 +675,8 @@ iter-defun of values. Callers can retrieve each value using `iter-next'." (declare (indent defun) (debug (&define name lambda-list lambda-doc &rest sexp)) - (doc-string 3)) + (doc-string 3) + (autoload macro-expand)) (cl-assert lexical-binding) (let* ((parsed-body (macroexp-parse-body body)) (declarations (car parsed-body)) diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index c015e2b57d0..ac0476ce826 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -135,7 +135,7 @@ define-inline This is like `defmacro', but has several advantages. See Info node `(elisp)Defining Functions' for more details." ;; FIXME: How can this work with CL arglists? - (declare (indent defun) (debug defun) (doc-string 3)) + (declare (indent defun) (debug defun) (doc-string 3) (autoload macro-expand)) (let ((doc (if (stringp (car-safe body)) (list (pop body)))) (declares (if (eq (car-safe (car-safe body)) 'declare) (pop body))) (cm-name (intern (format "%s--inliner" name))) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..b080fae0f40 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -147,7 +147,9 @@ loaddefs-generate--make-autoload Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. Note +that macros can request expansion by including `(autoload macro-expand)' +among their `declare' forms." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -196,21 +198,31 @@ loaddefs-generate--make-autoload (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) - (macrop car) - (setq expand (let ((load-true-file-name file) - (load-file-name file)) - (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) + ;; For macros which request it, try again on their expansion. + ((progn + ;; If the car is unknown, we load the file first to give + ;; packages a chance to define their macros. + (unless (or (null car) (macrop car) (functionp car) (special-form-p car) + (alist-get file load-history)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s (%s)" file car) + (condition-case e (load file) + (error (warn "loaddefs-gen: load error\n\t%s" e))))) + (and (macrop car) + (eq 'macro-expand ; a macro can declare (autoload macro-expand) + (or (get car 'autoload) + (get (car-safe (last (function-alias-p car))) 'autoload))) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) + (not (eq car (car expand))))) ;; Recurse on the expansion. (loaddefs-generate--make-autoload expand file 'expansion)) - ;; For special function-like operators, use the `autoload' function. + ;; For special function-like operators, use the `autoload' + ;; function. + ;; TODO: some macros can be removed from here once they set + ;; (declare (... (autoload macro-expand) ...) ((memq car '(define-skeleton define-derived-mode define-compilation-mode define-generic-mode easy-mmode-define-global-mode define-global-minor-mode diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 73554fd66fd..c116cece684 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -537,7 +537,7 @@ pcase-defmacro By convention, DOC should use \"EXPVAL\" to stand for the result of evaluating EXP (first arg to `pcase'). \n(fn NAME ARGS [DOC] &rest BODY...)" - (declare (indent 2) (debug defun) (doc-string 3)) + (declare (indent 2) (debug defun) (doc-string 3) (autoload macro-expand)) ;; Add the function via `fsym', so that an autoload cookie placed ;; on a pcase-defmacro will cause the macro to be loaded on demand. (let ((fsym (intern (format "%s--pcase-macroexpander" name))) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=loaddefs.diff Content-Description: difference in loaddefs.el arising from patch --- lisp/loaddefs_old.el 2025-07-15 17:56:40 +++ lisp/loaddefs.el 2025-07-15 23:16:42 @@ -5212,6 +5212,8 @@ The mode's hook is called both when the mode is enabled and when it is disabled. + +\\{compilation-shell-minor-mode-map} (fn &optional ARG)" t) (autoload 'compilation-minor-mode "compile" "\ @@ -5234,6 +5236,8 @@ The mode's hook is called both when the mode is enabled and when it is disabled. + +\\{compilation-minor-mode-map} (fn &optional ARG)" t) (autoload 'compilation-next-error-function "compile" "\ @@ -8813,7 +8817,7 @@ A call with prefix PREFIX reads the symbol to insert from the minibuffer with completion. -(fn PREFIX)" '("P")) +(fn PREFIX)" t) (autoload 'ebrowse-tags-loop-continue "ebrowse" "\ Repeat last operation on files in tree. FIRST-TIME non-nil means this is not a repetition, but the first time. @@ -10549,7 +10553,7 @@ and defers to `erc-compute-port', `erc-compute-user', and `erc-compute-nick' for those respective parameters. -(fn &key SERVER PORT NICK USER PASSWORD FULL-NAME ID)" '((let ((erc--display-context `((erc-interactive-display . erc) ,@erc--display-context))) (erc-select-read-args)))) +(fn &key SERVER PORT NICK USER PASSWORD FULL-NAME ID)" t) (defalias 'erc-select #'erc) (autoload 'erc-tls "erc" "\ Connect to an IRC server over a TLS-encrypted connection. @@ -10572,7 +10576,7 @@ node `(erc) Connecting' for a fuller description of the various parameters, like ID. -(fn &key SERVER PORT NICK USER PASSWORD FULL-NAME CLIENT-CERTIFICATE ID)" '((let ((erc-default-port erc-default-port-tls) (erc--display-context `((erc-interactive-display . erc-tls) ,@erc--display-context))) (erc-select-read-args)))) +(fn &key SERVER PORT NICK USER PASSWORD FULL-NAME CLIENT-CERTIFICATE ID)" t) (autoload 'erc-handle-irc-url "erc" "\ Use ERC to IRC on HOST:PORT in CHANNEL. If ERC is already connected to HOST:PORT, simply /join CHANNEL. @@ -10804,7 +10808,9 @@ If NAME is already defined as a test and Emacs is running in batch mode, an error is signaled. -(fn NAME () [DOCSTRING] [:expected-result RESULT-TYPE] [:tags \\='(TAG...)] BODY...)" nil 'macro) +(fn NAME () [DOCSTRING] [:expected-result RESULT-TYPE] [:tags \\='(TAG...)] BODY...)" nil t) +(function-put 'ert-deftest 'doc-string-elt 3) +(function-put 'ert-deftest 'lisp-indent-function 2) (autoload 'ert-run-tests-batch "ert" "\ Run the tests specified by SELECTOR, printing results to the terminal. @@ -13170,6 +13176,8 @@ The mode's hook is called both when the mode is enabled and when it is disabled. + +\\{flymake-mode-map} (fn &optional ARG)" t) (autoload 'flymake-mode-on "flymake" "\ @@ -16874,7 +16882,8 @@ change its definition, you should explicitly call `ibuffer-recompile-formats'. -(fn SYMBOL (&key NAME INLINE PROPS SUMMARIZER) &rest BODY)" nil 'macro) +(fn SYMBOL (&key NAME INLINE PROPS SUMMARIZER) &rest BODY)" nil t) +(function-put 'define-ibuffer-column 'lisp-indent-function 'defun) (autoload 'define-ibuffer-sorter "ibuf-macs" "\ Define a method of sorting named NAME. DOCUMENTATION is the documentation of the function, which will be called @@ -16885,7 +16894,9 @@ buffer object, and `b' bound to another. BODY should return a non-nil value if and only if `a' is \"less than\" `b'. -(fn NAME DOCUMENTATION (&key DESCRIPTION) &rest BODY)" nil 'macro) +(fn NAME DOCUMENTATION (&key DESCRIPTION) &rest BODY)" nil t) +(function-put 'define-ibuffer-sorter 'lisp-indent-function 1) +(function-put 'define-ibuffer-sorter 'doc-string-elt 2) (autoload 'define-ibuffer-op "ibuf-macs" "\ Generate a function which operates on a buffer. OP becomes the name of the function; if it doesn't begin with @@ -16924,7 +16935,9 @@ marked buffer. BODY is evaluated with `buf' bound to the buffer object. -(fn OP ARGS DOCUMENTATION (&key INTERACTIVE MARK MODIFIER-P DANGEROUS OPSTRING ACTIVE-OPSTRING BEFORE AFTER COMPLEX) &rest BODY)" nil 'macro) +(fn OP ARGS DOCUMENTATION (&key INTERACTIVE MARK MODIFIER-P DANGEROUS OPSTRING ACTIVE-OPSTRING BEFORE AFTER COMPLEX) &rest BODY)" nil t) +(function-put 'define-ibuffer-op 'lisp-indent-function 2) +(function-put 'define-ibuffer-op 'doc-string-elt 3) (autoload 'define-ibuffer-filter "ibuf-macs" "\ Define a filter named NAME. DOCUMENTATION is the documentation of the function. @@ -16939,7 +16952,9 @@ will be evaluated with BUF bound to the buffer object, and QUALIFIER bound to the current value of the filter. -(fn NAME DOCUMENTATION (&key READER DESCRIPTION) &rest BODY)" nil 'macro) +(fn NAME DOCUMENTATION (&key READER DESCRIPTION) &rest BODY)" nil t) +(function-put 'define-ibuffer-filter 'lisp-indent-function 2) +(function-put 'define-ibuffer-filter 'doc-string-elt 2) (register-definition-prefixes "ibuf-macs" '("ibuffer-")) @@ -19797,8 +19812,6 @@ ;;; Generated autoloads from emacs-lisp/loaddefs-gen.el (put 'autoload-compute-prefixes 'safe-local-variable #'booleanp) -(put 'autoload-expand-macros 'safe-local-variable #'listp) -(put 'autoload-expand-macros 'safe-local-variable #'listp) (put 'generated-autoload-file 'safe-local-variable 'stringp) (put 'generated-autoload-load-name 'safe-local-variable 'stringp) (autoload 'loaddefs-generate "loaddefs-gen" "\ @@ -27069,6 +27082,8 @@ The mode's hook is called both when the mode is enabled and when it is disabled. + +\\{rectangle-mark-mode-map} (fn &optional ARG)" t) (register-definition-prefixes "rect" '("apply-on-rectangle" "clear-rectangle-line" "delete-" "extract-rectangle-" "killed-rectangle" "ope" "rectangle-" "spaces-string" "string-rectangle-")) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 23 17:20:26 2025 Received: (at 78995) by debbugs.gnu.org; 23 Jul 2025 21:20:26 +0000 Received: from localhost ([127.0.0.1]:52327 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uegsz-0000Ar-Mx for submit@debbugs.gnu.org; Wed, 23 Jul 2025 17:20:26 -0400 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]:60637) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uegsv-00008t-NN for 78995@debbugs.gnu.org; Wed, 23 Jul 2025 17:20:23 -0400 Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-87c04c907eeso28395439f.0 for <78995@debbugs.gnu.org>; Wed, 23 Jul 2025 14:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753305616; x=1753910416; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=nP9zzduOhoH2H3F5pwQSLlrohNNnpr9re2wG/00ABrE=; b=aMsg/0DZqRKh1f/tyzvhDwpZ6drXZVDfmBBCixnDbOP1mwolBQy3eRQTnQwGuNSBzG CoTujJ7++RwnxOG3tDP1suVZL049t9DlDMSkx7YvAV7Pg6Nr+naCccGeEBD3Ihj/ZlDp eQlw+cATPMi6M1UxCvHQQl7G3k4iSeVvZQKINPeHYz16J38d4AYhnWB6VD1X7v13zhKA hICJyQCjZU4kH4ZMem6VSOafQznUOvn6cp3urR7h8cdDHGARRsWh50XwwY74eE5gx45k evXQs4LbKREs++ad/Xv5od0SXp1W+NgDvyW8H5PaRHnFyfw6WweKyJ181Mst+jhsTad9 wMLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753305616; x=1753910416; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nP9zzduOhoH2H3F5pwQSLlrohNNnpr9re2wG/00ABrE=; b=hzBtcJv47ZnGas5Y1zO14zd0QucHhDuIpUh9gvHKbFZT5/1YLlaeXd+58/Gq25qtwQ NDIzXZKITJnTo/iDRRLGcec+9iZJTe4iIEAhgPTTK+fDh92PdZr/reDleHRn571RdaBc RRpggQkvf0/S/XW8M66dVE/ZMLoVpwS3B41ysHkeM10CGNN/a8Xc+wHuQKofgzQ+a5gb RAd7ogciBDhAtYgEsAUEssjaq9XxTUHMrP9KGe8miJqOu4OFIQCZMMyS05P22dQ49mEJ 6ucxWpCNJoANeIcJYgvMCInIPAzmzXTj+bgTcy3yASWm/kpTkDUslbIAGeaFW/+hjbF9 qWvg== X-Gm-Message-State: AOJu0YzVhaMhcWTFQIHTMhcWzbhjKYHaqMvwxbac7C3iLaJhJ64Inux2 wbHn4MhxJ4+IEtxWlmFqtuP1aLmWZld8wrTpN3v7qjtZAnwuIcAio7ox X-Gm-Gg: ASbGncuHJZGxVUoXfeY1mQPbmvAPpN0MbTaBWdMFS3cORK8o52+FtG++JGyYAoeHVzX IhCdp7c9wIbJDgRpeRdt7IURoy2TZ1XGdCe97ZLYuhlRUyh4DU+ue3acQN61PhJX1gdxo1Ttym+ 59xE77OQ3IjicU8qtv9nvybx+Ab3PCBOaaBxLhmurszgbhFb+cpz77IuW1Fid3fhtdTlV14h0gi gZPJm0YC+F58yGwAcMm4vCa+sflaZf9n1cVP2wdI5KC8lNvkk2wLOEmpna9WUPkOaLLvNOFo7C3 NR7qP2gg0H7OrlfxLJRDC7+KrFY4l3bmaDh5jRYFWvy+Pf9Rc5O/mZJNa+UjwNTNASVJMNfeMDH ytISUc9qPK5PylmTWxB58Xzwix81OQrYLATmjgPqBaki/Kl4IByUucJNBvQUwibK2/r8= X-Google-Smtp-Source: AGHT+IHjw9AtB1DjC05xCqTLuDKWn4V1v3yVwYgTsV6MPt05f8CC/QxppoFsZGzty+dEhRMFmkGBxQ== X-Received: by 2002:a05:6e02:198c:b0:3e3:b74e:dd1a with SMTP id e9e14a558f8ab-3e3b74eddcbmr2149355ab.3.1753305615485; Wed, 23 Jul 2025 14:20:15 -0700 (PDT) Received: from moss-3 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3e3b7248082sm425965ab.60.2025.07.23.14.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jul 2025 14:20:14 -0700 (PDT) From: "J.D. Smith" To: 78995@debbugs.gnu.org Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (J. D. Smith's message of "Tue, 15 Jul 2025 23:35:54 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Wed, 23 Jul 2025 17:20:13 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Stefan, can you take a look at this? I think I now understand why there are slight differences in the loaddefs.el file generated by my declare-based, eager-loading patch. There is a /bug/ in the fallback "list 3" generation of autoloads, leading to incorrect autoload statements being written out. The `INTERACTIVE' arg to `autoload' is supposed to be formed as follows: If INTERACTIVE is a list, it is interpreted as a list of modes the function is applicable for. The current code mistakenly injects the actual ARG-DESCRIPTOR list into the autoload file, for those (few) macros which are not expanded but fall through to list 2, possibly just `cl-defun's. You might see for example the full `(let...` descriptors for `erc` in your loaddefs.el file. That's a bug I believe, and will presumably mess with the mode-specific M-S-x type functionality. So by expanding more eagerly with `(declare (autoload macro-expand))', this bug was "eliminated". The attached fixes it for any cases which still use fall-through to list 2. Thoughts? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=autoload-bug.patch Content-Description: Bug in List 2 Interactive autoload diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..ba7ec21eaed 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -257,8 +257,8 @@ loaddefs-generate--make-autoload t) (and (eq (car-safe (car body)) 'interactive) ;; List of modes or just t. - (or (if (nthcdr 1 (car body)) - (list 'quote (nthcdr 1 (car body))) + (or (if (nthcdr 2 (car body)) + (list 'quote (nthcdr 2 (car body))) t)))) ,(if macrop ''macro nil))))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 24 10:09:19 2025 Received: (at 78995) by debbugs.gnu.org; 24 Jul 2025 14:09:20 +0000 Received: from localhost ([127.0.0.1]:57246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uewdK-0004fX-62 for submit@debbugs.gnu.org; Thu, 24 Jul 2025 10:09:19 -0400 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]:47321) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uewdG-0004fA-Kw for 78995@debbugs.gnu.org; Thu, 24 Jul 2025 10:09:16 -0400 Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-3e2c547bc90so13387485ab.2 for <78995@debbugs.gnu.org>; Thu, 24 Jul 2025 07:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753366149; x=1753970949; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Jgcns8wskhQihEV6e37EhjdzBICLGVECVjYfVnMBShQ=; b=QzI+HN0Vxf2JYvYmKnbkygvUcAkLxtBeGNtzEWPibQ6xgCWidIhuqnBd/6fyCNdB0v G80NPS8T+kw27BfCtFBLM28URbtCn64qz8LGbks8DUXj8q/NfHA+E1/vCe1NIzAaaNMP VjZexjo+fGWsXyrOO+gQq4EDL9lM0BtvC5SJWVOQJnUKM2C+HDTrxu6S/5vWepUbaud9 J9ibCUQSoLpYEYokKw2Pz9GMa90t4OlWXA9Oo24fbQo/E6XQOwfC+Z9PqoSvRkNrVaVA iu4P1JtKhcB+WsTsWt+GO+00Zav1rhCbYY5baAwg0X6f3+8NdiqBCXSo/QTO0ONH9Ul7 60UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753366149; x=1753970949; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Jgcns8wskhQihEV6e37EhjdzBICLGVECVjYfVnMBShQ=; b=gyJtjwmb76c69iyXMldVAdxmc0seUjNAldDSTgyrSi5zUc5LVV99io1bYcZMQMNxaz VJGjFvW6ZXCNdMI1GSJIQuwpDDLpwq9x1RH7qTA19nwFuKCHK0AQpgLcl46fjspLvaiv 6kH3ClCqKpdQGcxdbICiVJkYysXbjHLHQHLHn3pOU+mM2Lkfan/TdL2wdVnX/LbeIoVB DWq+j6VCw2ltmi7jlguJmIBbQuZLQqtsOK3CvMno9/YtvAtE5mURdyf5RJCN/UMZIXnR 83SkYQlkeH1tOpNGXsRmTgO1mkchjYltvstGldGXFGk3fbj3mppEvtnquNz3lAPjoolB xy/g== X-Gm-Message-State: AOJu0YzZ6gLRGZl3VInW1DdoJHZ0ph668r5/PAE9zJ1ZembiX+h4Cpyq DXj9utj0doW3G2fqJLL+9tH3aKlYNQQeoBPgqGapbS1rjpWZDG6z3b2khH0UGQ== X-Gm-Gg: ASbGncuQtVkCtWhr+SJU24OGesD8bXiaYREiM4hUDIzj+ICfCcd6gavTb7H8SVbZIeD CodURPLMEhYwIIrIDxNA2uybP3teWkvvj7dek/lT7T/OQrbkZZ/s5qtxb0/HnZP2c1VB1tItY21 Hx1IN17ScJ7EiaCOC9/8wqHPjWV9/KzUDa4QoAO6tgn1jW3xi62c1LmAEVXUIhnCQViEuyzdAcE zW9d/us50GFSFmUkP4L422yWT5BlQp2AXE3oBUUD1YFvx4vPa6edABkYG9pZv5wUrFnNZ2EJXXU uhgjF+KIlhC/0HSCpmUcPNRpvO7sROPkA5zO+TCJxHn0Q52PgMbq0uuf+xip8I2NTlPd1CziDaF Dpd2NCkv7L9gNHt8xOrYWKg6HFYX7LBuU2/h6XHyY3hRgOdtsbywbbRmc X-Google-Smtp-Source: AGHT+IHMUi2lS1QgP52ZGmZEhiLQxar+v3K3MKBlVXh+GYILL5gJL/ZFgrThC7KxybNpn4YGw3lBiw== X-Received: by 2002:a05:6e02:2687:b0:3e2:956a:3a64 with SMTP id e9e14a558f8ab-3e331e2c813mr136489225ab.18.1753366148468; Thu, 24 Jul 2025 07:09:08 -0700 (PDT) Received: from moss-3 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-508aebd44d7sm435411173.56.2025.07.24.07.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 07:09:07 -0700 (PDT) From: "J.D. Smith" To: 78995@debbugs.gnu.org Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (J. D. Smith's message of "Tue, 15 Jul 2025 23:35:54 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Thu, 24 Jul 2025 10:09:07 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain "J.D. Smith" writes: > Here is an update on progress. The attached is working reasonably well, > reproducing lisp/loaddefs.el with a few changes (see attached). I went > with (declare ((autoload . macro-expand))) on the notion that there > might be other autoload-related declarations in the future, but open to > suggestion. Please have a look at this latest patch, which I believe solves the mentioned problems. Changes: 1. I implemented the list 2 bug fix for autoload's INTERACTIVE argument described above, correctly keeping interactive arg specs out of the loaddefs files. 2. I moved the autoload macro-expand declare up front everywhere it's used[1], to ensure the macro-expand request will be included in *-loaddefs.el files. This is important for packages which manage their own *-loaddefs.el files (e.g. `cl-macs'). 3. I have kept list 2 around[2], and count presence on this list, or the list of 4 specially-handled macros (defgroup, defcustom, deftheme, defclass) as "we know about this car". No file load will be attempted for such special macros, so only proper "user-defined UNKNOWN macros" will result in a load attempt. With these, the loaddefs.el file changes only modestly (see attached), and (almost) no files have load attempted. About that almost. There is one small order-of-operation issue yet to be solved, for packages which do clever things. Take any of the `net/tramp-*.el` files. They all require `tramp-compat`, which requires `tramp-loaddefs', which is itself an autoload file the build process is generating. For example, tramp's autoload file eventually includes the macro `tramp--with-startup'. When one of tramp's autoloads use an unknown macro like this, there will be an attempt to load the file, implicitly requiring that yet-to-exist `tramp-loaddefs.el' file, resulting in a (handled) error. Classic chicken and egg. INFO Scraping 1543 files for loaddefs...70% loaddefs-gen: loading file tramp-adb (for tramp--with-startup) Loading /Users/jdsmith/code/emacs/emacs-mac/lisp/net/tramp-adb.el (source)... Warning (emacs): loaddefs-gen: load error (file-missing Cannot open load file No such file or directory tramp-loaddefs) loaddefs-gen: loading file tramp-androidsu (for tramp--with-startup) Loading /Users/jdsmith/code/emacs/emacs-mac/lisp/net/tramp-androidsu.el (source)... Warning (emacs): loaddefs-gen: load error (file-missing Cannot open load file No such file or directory tramp-loaddefs) ... In this case these are harmless warnings, since in fact `tramp--with-startup' is /not/ requesting macro-expand, so failing to define it doesn't matter. Subsequent builds do not show this error. But this could be alarming to people, so we probably need a solution. [1] Note that the order of declare entries already matters, because some of them generate forms which include `:autoload-end', and this token, once encountered _anywhere_, puts an absolute stop to emitting additional declare-generated forms into loaddefs. E.g. `(declare (debug ...))' does this. This, by the way, is why /some/ macros have their (e.g.) `indent' declares passed through to the loaddefs files, and others do not. [2] Some of these macros aren't yet suited for full expansion anyway. For example `define-derived-mode' includes a bunch of unwanted forms if it gets the expansion treatment. So for now, leaving the shortcut list 2 intact seems to be the lesser evil. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=autoload-expand_3.patch Content-Description: autoload expand patch, iteration 3 diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 366423904db..4d3cc96db7d 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -271,6 +271,11 @@ 'byte-run--set-debug (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload + #'(lambda (name _args spec) + (list 'function-put (list 'quote name) + ''autoload (list 'quote spec)))) + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -350,8 +355,10 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + (list 'autoload #'byte-run--set-autoload) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -397,6 +404,7 @@ 'defmacro (if declarations (cons 'prog1 (cons def (car declarations))) def)))))) +(function-put 'defmacro 'autoload 'macro-expand) ; Since we cannot `declare' it ;; Now that we defined defmacro we can use it! (defmacro defun (name arglist &rest body) @@ -409,7 +417,7 @@ defun The return value is undefined. \(fn NAME ARGLIST [DOCSTRING] [DECL] [INTERACTIVE] BODY...)" - (declare (doc-string 3) (indent 2)) + (declare (autoload macro-expand) (doc-string 3) (indent 2)) (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 3aa26fba3c3..8867b83164f 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -241,7 +241,7 @@ cl-defgeneric DEFAULT-BODY, if present, is used as the body of a default method. \(fn NAME ARGS [DOC-STRING] [OPTIONS-AND-METHODS...] &rest DEFAULT-BODY)" - (declare (indent 2) (doc-string 3) + (declare (autoload macro-expand) (indent 2) (doc-string 3) (debug (&define &interpose diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2a0a9e5c6de..fd24424820d 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -390,7 +390,8 @@ cl-defun more details. \(fn NAME ARGLIST [DOCSTRING] BODY...)" - (declare (debug + (declare (autoload macro-expand) + (debug ;; Same as defun but use cl-lambda-list. (&define [&name symbolp] cl-lambda-list @@ -408,7 +409,8 @@ cl-iter-defun and BODY is implicitly surrounded by (cl-block NAME ...). \(fn NAME ARGLIST [DOCSTRING] BODY...)" - (declare (debug + (declare (autoload macro-expand) + (debug ;; Same as iter-defun but use cl-lambda-list. (&define [&name sexp] ;Allow (setf ...) additionally to symbols. cl-lambda-list @@ -472,7 +474,8 @@ cl-defmacro more details. \(fn NAME ARGLIST [DOCSTRING] BODY...)" - (declare (debug + (declare (autoload macro-expand) + (debug (&define name cl-macro-list cl-declarations-or-string def-body)) (doc-string 3) (indent 2)) @@ -3001,7 +3004,7 @@ cl-defstruct \\[describe-symbol] or \\[cl-describe-type]. \(fn NAME &optional DOCSTRING &rest SLOTS)" - (declare (doc-string 2) (indent 1) + (declare (autoload macro-expand) (doc-string 2) (indent 1) (debug (&define ;Makes top-level form not be wrapped. [&or symbolp diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index f53db48f0b7..e618a76ef4e 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -218,12 +218,13 @@ define-minor-mode INIT-VALUE LIGHTER KEYMAP. \(fn MODE DOC [KEYWORD VAL ... &rest BODY])" - (declare (doc-string 2) + (declare (autoload macro-expand) + (doc-string 2) (indent defun) (debug (&define name string-or-null-p [&optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp] + &optional [¬ keywordp] sexp + &optional [¬ keywordp] sexp] [&rest [keywordp sexp]] def-body))) @@ -487,7 +488,7 @@ define-globalized-minor-mode on if the hook has explicitly disabled it. \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" - (declare (doc-string 2) (indent defun)) + (declare (autoload macro-expand) (doc-string 2) (indent defun)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 344e11e245e..ccf4efffdc6 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -673,7 +673,8 @@ iter-defun When called as a function, NAME returns an iterator value that encapsulates the state of a computation that produces a sequence of values. Callers can retrieve each value using `iter-next'." - (declare (indent defun) + (declare (autoload macro-expand) + (indent defun) (debug (&define name lambda-list lambda-doc &rest sexp)) (doc-string 3)) (cl-assert lexical-binding) diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index c015e2b57d0..a062f88946d 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -135,7 +135,7 @@ define-inline This is like `defmacro', but has several advantages. See Info node `(elisp)Defining Functions' for more details." ;; FIXME: How can this work with CL arglists? - (declare (indent defun) (debug defun) (doc-string 3)) + (declare (autoload macro-expand) (indent defun) (debug defun) (doc-string 3)) (let ((doc (if (stringp (car-safe body)) (list (pop body)))) (declares (if (eq (car-safe (car-safe body)) 'declare) (pop body))) (cm-name (intern (format "%s--inliner" name))) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..86abdeb24a1 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -142,12 +142,28 @@ loaddefs-generate--shorten-autoload 3) form)) +;; TODO: some macros can be removed from this list once they +;; (declare ((autoload macro-expand) ...) +(defconst loaddefs--function-like-operators + '(define-skeleton define-derived-mode + define-compilation-mode define-generic-mode + easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode + easy-mmode-define-minor-mode define-minor-mode + cl-defun defun* cl-defmacro defmacro* + define-overloadable-function + transient-define-prefix transient-define-suffix + transient-define-infix transient-define-argument)) + +(defvar loaddefs--load-error-files nil) (defun loaddefs-generate--make-autoload (form file &optional expansion) "Turn FORM into an autoload or defvar for source file FILE. Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. Note +that macros can request expansion by including `(autoload macro-expand)' +among their `declare' forms." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -196,30 +212,35 @@ loaddefs-generate--make-autoload (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) - (macrop car) - (setq expand (let ((load-true-file-name file) - (load-file-name file)) - (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) + ;; For macros which request it, try again on their expansion. + ((progn + ;; If the car is entirely unknown, we load the file first to + ;; give packages a chance to define their macros. + (unless (or (null car) (macrop car) (functionp car) (special-form-p car) + (memq car loaddefs--function-like-operators) + (memq car '(defclass defcustom deftheme defgroup)) + (alist-get file load-history) + (member file loaddefs--load-error-files)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s (for %s)" file car) + (condition-case e (load file) + (error + (push file loaddefs--load-error-files) ; do not attempt again + (warn "loaddefs-gen: load error\n\t%s" e))))) + (and (macrop car) + (eq 'macro-expand ; a macro can declare (autoload macro-expand) + (or (get car 'autoload) + (get (car-safe (last (function-alias-p car))) 'autoload))) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) + (not (eq car (car expand))))) ;; Recurse on the expansion. (loaddefs-generate--make-autoload expand file 'expansion)) - ;; For special function-like operators, use the `autoload' function. - ((memq car '(define-skeleton define-derived-mode - define-compilation-mode define-generic-mode - easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode - easy-mmode-define-minor-mode define-minor-mode - cl-defun defun* cl-defmacro defmacro* - define-overloadable-function - transient-define-prefix transient-define-suffix - transient-define-infix transient-define-argument)) + ;; For special function-like operators, use the `autoload' + ;; function. + ((memq car loaddefs--function-like-operators) (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) (name (nth 1 form)) (args (pcase car @@ -257,8 +278,8 @@ loaddefs-generate--make-autoload t) (and (eq (car-safe (car body)) 'interactive) ;; List of modes or just t. - (or (if (nthcdr 1 (car body)) - (list 'quote (nthcdr 1 (car body))) + (or (if (nthcdr 2 (car body)) + (list 'quote (nthcdr 2 (car body))) t)))) ,(if macrop ''macro nil))))) diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 73554fd66fd..893e3db2b59 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -537,7 +537,7 @@ pcase-defmacro By convention, DOC should use \"EXPVAL\" to stand for the result of evaluating EXP (first arg to `pcase'). \n(fn NAME ARGS [DOC] &rest BODY...)" - (declare (indent 2) (debug defun) (doc-string 3)) + (declare (autoload macro-expand) (indent 2) (debug defun) (doc-string 3)) ;; Add the function via `fsym', so that an autoload cookie placed ;; on a pcase-defmacro will cause the macro to be loaded on demand. (let ((fsym (intern (format "%s--pcase-macroexpander" name))) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=loaddefs_2.diff Content-Description: main loaddefs.el differences for expand_3 patch --- loaddefs_old.el 2025-07-15 17:56:40 +++ loaddefs.el 2025-07-24 09:26:22 @@ -8420,6 +8420,7 @@ INIT-VALUE LIGHTER KEYMAP. (fn MODE DOC [KEYWORD VAL ... &rest BODY])" nil t) +(function-put 'define-minor-mode 'autoload 'macro-expand) (function-put 'define-minor-mode 'doc-string-elt 2) (function-put 'define-minor-mode 'lisp-indent-function 'defun) (defalias 'define-global-minor-mode #'define-globalized-minor-mode) @@ -8464,6 +8465,7 @@ on if the hook has explicitly disabled it. (fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" nil t) +(function-put 'define-globalized-minor-mode 'autoload 'macro-expand) (function-put 'define-globalized-minor-mode 'doc-string-elt 2) (function-put 'define-globalized-minor-mode 'lisp-indent-function 'defun) (autoload 'easy-mmode-define-keymap "easy-mmode" "\ @@ -8813,7 +8815,7 @@ A call with prefix PREFIX reads the symbol to insert from the minibuffer with completion. -(fn PREFIX)" '("P")) +(fn PREFIX)" t) (autoload 'ebrowse-tags-loop-continue "ebrowse" "\ Repeat last operation on files in tree. FIRST-TIME non-nil means this is not a repetition, but the first time. @@ -10549,7 +10551,7 @@ and defers to `erc-compute-port', `erc-compute-user', and `erc-compute-nick' for those respective parameters. -(fn &key SERVER PORT NICK USER PASSWORD FULL-NAME ID)" '((let ((erc--display-context `((erc-interactive-display . erc) ,@erc--display-context))) (erc-select-read-args)))) +(fn &key SERVER PORT NICK USER PASSWORD FULL-NAME ID)" t) (defalias 'erc-select #'erc) (autoload 'erc-tls "erc" "\ Connect to an IRC server over a TLS-encrypted connection. @@ -10572,7 +10574,7 @@ node `(erc) Connecting' for a fuller description of the various parameters, like ID. -(fn &key SERVER PORT NICK USER PASSWORD FULL-NAME CLIENT-CERTIFICATE ID)" '((let ((erc-default-port erc-default-port-tls) (erc--display-context `((erc-interactive-display . erc-tls) ,@erc--display-context))) (erc-select-read-args)))) +(fn &key SERVER PORT NICK USER PASSWORD FULL-NAME CLIENT-CERTIFICATE ID)" t) (autoload 'erc-handle-irc-url "erc" "\ Use ERC to IRC on HOST:PORT in CHANNEL. If ERC is already connected to HOST:PORT, simply /join CHANNEL. @@ -18809,6 +18811,7 @@ See Info node `(elisp)Defining Functions' for more details. (fn NAME ARGS &rest BODY)" nil t) +(function-put 'define-inline 'autoload 'macro-expand) (function-put 'define-inline 'lisp-indent-function 'defun) (function-put 'define-inline 'doc-string-elt 3) (register-definition-prefixes "inline" '("inline-")) @@ -19797,8 +19800,6 @@ ;;; Generated autoloads from emacs-lisp/loaddefs-gen.el (put 'autoload-compute-prefixes 'safe-local-variable #'booleanp) -(put 'autoload-expand-macros 'safe-local-variable #'listp) -(put 'autoload-expand-macros 'safe-local-variable #'listp) (put 'generated-autoload-file 'safe-local-variable 'stringp) (put 'generated-autoload-load-name 'safe-local-variable 'stringp) (autoload 'loaddefs-generate "loaddefs-gen" "\ @@ -19835,7 +19836,7 @@ loaddefs.el output file, and the rest are the directories to use.") (load "theme-loaddefs.el" t) -(register-definition-prefixes "loaddefs-gen" '("autoload-" "generated-autoload-" "loaddefs-generate--" "no-update-autoloads")) +(register-definition-prefixes "loaddefs-gen" '("autoload-" "generated-autoload-" "loaddefs-" "my/tmp-lddg-list2" "no-update-autoloads")) ;;; Generated autoloads from loadhist.el @@ -24547,6 +24548,7 @@ for the result of evaluating EXP (first arg to `pcase'). (fn NAME ARGS [DOC] &rest BODY...)" nil t) +(function-put 'pcase-defmacro 'autoload 'macro-expand) (function-put 'pcase-defmacro 'lisp-indent-function 2) (function-put 'pcase-defmacro 'doc-string-elt 3) (register-definition-prefixes "pcase" '("pcase-")) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 26 13:13:53 2025 Received: (at 78995) by debbugs.gnu.org; 26 Jul 2025 17:13:53 +0000 Received: from localhost ([127.0.0.1]:44615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ufiT2-0000nx-Vk for submit@debbugs.gnu.org; Sat, 26 Jul 2025 13:13:53 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:12049) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ufiSz-0000nE-Im for 78995@debbugs.gnu.org; Sat, 26 Jul 2025 13:13:50 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 910AC440B07; Sat, 26 Jul 2025 13:13:43 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1753550021; bh=OHOIuLMjjj6EWowy4+XIpOLyWfNh4IMoT9OhcJu1TUQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=PPcv4N70mDycQPpCW7ekEis2B2ruGZTCSTd7WhLsCIGjaBLArHIRuZm7L3Cehdp3Z siMxmPeiDKmweZy9/MVKtEKwuVAQYd/8/0v8+KUiygvFCK/wjxhMAo97aD7C6/RADq RAGse6ocUHqWsDRRPLwBMP4K/PeJpt+QcaYjn2ldFRJ7NOW1SDgO6WPc/uRAFkcRHe DY61xuJX1suANFUuFtHnokUBWDWWMcifosvjyHYncw8gCTj3W6L3RZn5g4Dm1Wj0Dx LEl8FconKoIqo272k75f6Q1K4pS5MXPpPKyS6+4zIFWs9N6tGLB28DmoH9PjF7kpkx BtHGtlFtq33ow== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0F4B4440ADA; Sat, 26 Jul 2025 13:13:41 -0400 (EDT) Received: from pastel (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D6BD11204A7; Sat, 26 Jul 2025 13:13:40 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sat, 26 Jul 2025 13:13:40 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.270 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) [ Sorry for the long delay. ] >> Here is an update on progress. The attached is working reasonably well, >> reproducing lisp/loaddefs.el with a few changes (see attached). I went >> with (declare ((autoload . macro-expand))) on the notion that there >> might be other autoload-related declarations in the future, but open to >> suggestion. [ I don't have an opinion on the naming here but I don't understand your argument: wouldn't a declaration name of `autoload` be *more* likely to conflict with another future autoload-related declaration? ] > Warning (emacs): loaddefs-gen: load error > (file-missing Cannot open load file No such file or directory tramp-lo= addefs) > ... > > In this case these are harmless warnings, since in fact > `tramp--with-startup' is /not/ requesting macro-expand, so failing to > define it doesn't matter. Subsequent builds do not show this error. > But this could be alarming to people, so we probably need a solution. Yeah, it's one of those nasty issues. One way to look at it is that the crux of the matter is that we use `;;;###autoload` for 2 different purpose: A. To copy the code into the loaddefs file. B. To arrange for the file to be autoloaded when the corresponding thingy is used. (B) is the one that deserves the name "autoload" while (A) might be better named "preload". Your `;;;###autoload-expand` was a fix for that core problem, in a sense. The distinction between the two is not that clear when you consider that a `;;;###autoload` cookie placed on a `defun` may arrange to autoload that file when calling that function but it may *also* preload some `put`s extracted from the `declare`. Maybe a "general" solution would be to introduce a `;;;###preload`. Not sure it's worth the trouble, tho. Also, I'm not sure how "general" this would be, since the same problem will tend to happen with any package which `;;;###autoload` a call to a macro that's not predefined if that package uses its own `FOO-loaddefs.el`, even if that macro is defined in some other library. So, the general problem is: your patch will sometimes `eval-buffer` for a buffer which doesn't expect to be evaluated before its package's `FOO-loaddefs.el` has been created. I suspect that in most cases this can be fixed by replacing (require 'foo-loaddefs) by (require 'foo-loaddefs nil t) It's not ideal, but I think it's acceptable. Maybe it won't always be sufficient either. E.g. in `cl-lib` we solved this problem (for a different reason) with: (unless (load "cl-loaddefs" 'noerror 'quiet) ;; When bootstrapping, cl-loaddefs hasn't been built yet! (require 'cl-macs) (require 'cl-seq) ;; FIXME: Arguably we should also load `cl-extra', except that this ;; currently causes more bootstrap troubles, and `cl-extra' is ;; rarely used, so instead we explicitly (require 'cl-extra) at ;; those rare places where we do need it. ) BTW, in the specific case of Tramp, I see: (defmacro tramp--with-startup (&rest body) "Schedule BODY to be executed at the end of tramp.el." `(add-hook 'tramp--startup-hook (lambda nil ,@body))) so I think `tramp--with-startup` *is* one of the macros that would benefit from your new `(autoload macro-expand)` declaration. > [1] Note that the order of declare entries already matters, because some > of them generate forms which include `:autoload-end', and this > token, once encountered _anywhere_, puts an absolute stop to > emitting additional declare-generated forms into loaddefs. > E.g. `(declare (debug ...))' does this. This, by the way, is why > /some/ macros have their (e.g.) `indent' declares passed through to > the loaddefs files, and others do not. Really? Sounds like a bug. Are you sure? (macroexpand '(defmacro my-foo () (declare (debug t) (indent 1)) (help)= )) gives me: (prog1 (defalias 'my-foo (cons 'macro #'(lambda nil (help)))) (progn :autoload-end (put 'my-foo 'edebug-form-spec 't)) (function-put 'my-foo 'lisp-indent-function 1)) and AFAIK the `:autoload-end` truncation is done with (let ((end (memq :autoload-end form))) (when end ;Cut-off anything after the :autoload-end marker. (setq form (copy-sequence form)) (setcdr (memq :autoload-end form) nil)) so it should only truncate to: (prog1 (defalias 'my-foo (cons 'macro #'(lambda nil (help)))) (progn :autoload-end) (function-put 'my-foo 'lisp-indent-function 1)) and thus keep the subsequent `indent` declaration intact. > [2] Some of these macros aren't yet suited for full expansion anyway. > For example `define-derived-mode' includes a bunch of unwanted forms > if it gets the expansion treatment. So for now, leaving the > shortcut list 2 intact seems to be the lesser evil. Interesting. > +(defalias 'byte-run--set-autoload > + #'(lambda (name _args spec) > + (list 'function-put (list 'quote name) > + ''autoload (list 'quote spec)))) I think the choice of `autoload` as name of symbol property is too generic and runs too high a risk of clashing with other uses. > (defconst loaddefs--function-like-operators "operators" doesn't sound quite right. Maybe "loaddefs--defining-macros"? > If EXPANSION is non-nil, we're processing the macro expansion of an > -expression, in which case we want to handle forms differently." > +expression, in which case we want to handle forms differently. Note > +that macros can request expansion by including `(autoload macro-expand)' > +among their `declare' forms." Nitpick: I'd start "Note..." on its own line. We're not trying to justify-fill the text. =F0=9F=99=82 > @@ -196,30 +212,35 @@ loaddefs-generate--make-autoload > (cdr form))))) > (when exps (cons 'progn exps))))) >=20=20 > - ;; For complex cases, try again on the macro-expansion. > - ((and (memq car '(easy-mmode-define-global-mode define-global-minor= -mode > - define-globalized-minor-mode defun defmacro > - easy-mmode-define-minor-mode define-minor-mode > - define-inline cl-defun cl-defmacro cl-defgeneric > - cl-defstruct pcase-defmacro iter-defun cl-iter-de= fun)) > - (macrop car) > - (setq expand (let ((load-true-file-name file) > - (load-file-name file)) > - (macroexpand form))) > - (memq (car expand) '(progn prog1 defalias))) > + ;; For macros which request it, try again on their expansion. > + ((progn > + ;; If the car is entirely unknown, we load the file first to > + ;; give packages a chance to define their macros. > + (unless (or (null car) (macrop car) (functionp car) (special-for= m-p car) I'd test (and (symbolp car) (not (fboundp car))) > + (memq car '(defclass defcustom deftheme defgroup)) This deserves a comment in the code. > + (alist-get file load-history) `alist-get` defaults to testing with `eq` so it won't work well with a string key. =F0=9F=99=81 I'd go with `assoc`. > + (and (macrop car) > + (eq 'macro-expand ; a macro can declare (autoload macro-expand) > + (or (get car 'autoload) > + (get (car-safe (last (function-alias-p car))) 'autoload))) I'd have expected `function-get` here. > - ;; For special function-like operators, use the `autoload' function. > - ((memq car '(define-skeleton define-derived-mode > - define-compilation-mode define-generic-mode > - easy-mmode-define-global-mode define-global-minor-mode > - define-globalized-minor-mode > - easy-mmode-define-minor-mode define-minor-mode > - cl-defun defun* cl-defmacro defmacro* > - define-overloadable-function > - transient-define-prefix transient-define-suffix > - transient-define-infix transient-define-argument)) > + ;; For special function-like operators, use the `autoload' > + ;; function. > + ((memq car loaddefs--function-like-operators) > (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) > (name (nth 1 form)) > (args (pcase car If we swap this case with the preceding one we can remove the (memq car loaddefs--function-like-operators) from the `unless` of that case. [ And it probably results in a diff that's harder to read, so thanks for not doing it this time. =F0=9F=99=82 ] > @@ -257,8 +278,8 @@ loaddefs-generate--make-autoload > t) > (and (eq (car-safe (car body)) 'interactive) > ;; List of modes or just t. > - (or (if (nthcdr 1 (car body)) > - (list 'quote (nthcdr 1 (car body))) > + (or (if (nthcdr 2 (car body)) > + (list 'quote (nthcdr 2 (car body))) > t)))) > ,(if macrop ''macro nil))))) I think you can just push this to `master` as separate patch, thank you. > @@ -19835,7 +19836,7 @@ > loaddefs.el output file, and the rest are the directories to > use.") > (load "theme-loaddefs.el" t) > -(register-definition-prefixes "loaddefs-gen" '("autoload-" "generated-au= toload-" "loaddefs-generate--" "no-update-autoloads")) > +(register-definition-prefixes "loaddefs-gen" '("autoload-" "generated-au= toload-" "loaddefs-" "my/tmp-lddg-list2" "no-update-autoloads")) Maybe better use `autoload-` rather than `loaddefs-` as prefix for the new definitions. [ I don't see `my/tmp-lddg-list2` in the patch you sent, so I assume it was something temporary. ] Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 26 21:47:00 2025 Received: (at 78995) by debbugs.gnu.org; 27 Jul 2025 01:47:00 +0000 Received: from localhost ([127.0.0.1]:46596 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ufqTa-0008MF-Nv for submit@debbugs.gnu.org; Sat, 26 Jul 2025 21:47:00 -0400 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]:56361) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ufqTX-0008Lp-1D for 78995@debbugs.gnu.org; Sat, 26 Jul 2025 21:46:56 -0400 Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-879c737bc03so93049039f.0 for <78995@debbugs.gnu.org>; Sat, 26 Jul 2025 18:46:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753580809; x=1754185609; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=0d7CGNf2dsd61AnoBXX7Vh70p27/v3JJ9SA5Y3h65aE=; b=OCS4JkrQzAajlJwDIjD5cJ0TvX2nUloILbMTStnrbvA5HFOyAOOlIDswnLwBA7D0uT qGgdFhxjicEzQoQsgDHnWDBbnTYSDwhvqnFThPiXbGl33rceMYJI1TbBZ7bfBWrNKtVp 70ez4uyR2UA+8mOL+v3rf0yIjfa8aM1Eu4qBonQUz1ifZn1hx4T1jqv3GomJORWdZtXA 5uiYyceKM/wV8Owv2zZcptFTjI0dnIvNcw7f35DYRBn8zKNFYegqmn63UyXfXP74YdHN JfHNDQhC7flLohyaUY3hjOev3WNq3bWPFVeknMc12fAziR8SIPuPq5a+RhhOKBINILxt QGyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753580809; x=1754185609; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0d7CGNf2dsd61AnoBXX7Vh70p27/v3JJ9SA5Y3h65aE=; b=Z9lcz6A43fG59MO8XNB4yGyzFH8J6DGqsEmTygk16HmLoE8ASgRYWX20oSnPjG5GJY 82L0sf2bqoW+Q+Exp8gJiMvAgj+1x8ul7+P6ly/oJulgY4SIjbZ3l8o2c3x4PffwmJNS kTvDSRRxzuHJBOBCEkmZUB74Fn/Phe/9jiI6gy995SjfabH8mUQOADiZD7WzHYOWqCTl ny0ahAbIpLg3q8J9unearW0nUsSRKAF5xsxprZMEzOQmoN9X3ZZiJ4LBFkyCa+s21by0 BmGQOK3/XOYeCvOQG6WC/yxNF1BJcTdsyuRmzsXplEGBCKL95gzyUz4owZiIIodMqy6q fgOw== X-Gm-Message-State: AOJu0Yx1W2HHfqppKRs73fbVyHQcok9Pyu6a8jJGKCerDpz4tyYYXskh Iioi22IYsqpgGCyAu0ZqmCSoL1RfmTeoPmnwdiCi02j57O2HRY/sejwCq1ueQw== X-Gm-Gg: ASbGnctLupct1ODa7V/PCkr2CSRW3V4/HPBPpXg2O9RzGnNVYx2ltZu13f9vYJpy+VN UznmDb9mqNUUr6BsPYbv1CURMDZgck1sNFAITBgfLLOekDSq+bwYUGgsKeDdlB/NSpiREir1NRv QSpMC6ARBUyDO50tE9FaCCSzRUlqPoEWiCFMfTAbGx/crubidgAXq0FQjrTcrx2L1Bj5/EiessW JURrBnLKn2dmqUoYLzUd8zNhEOAtNts2VPUfzcvjmKclyrOLiOp5sMimS2ENiKQ3rzBDVuUORxG ZQRflShIIGK5cGyq34WtgzoD+xEJMm3px6SdtboZZL2FPW1XmcDpFQUMl53YubUFWn3DkUsGgms I9aMqfmNevRhF+MvNJ7xEAzYYgaokghcn3rAEeY5aRwfUD/+lQInfH31H X-Google-Smtp-Source: AGHT+IEBSPPcbYNm1hsgQF0EHLTVk8Xkr/18jHQf1LFHJ5xac8oUSznyngt1A9VP5+zusCjjsGm6HQ== X-Received: by 2002:a05:6602:3f81:b0:87c:1cc3:c0fa with SMTP id ca18e2360f4ac-87fffa87a2bmr1204352839f.0.1753580808483; Sat, 26 Jul 2025 18:46:48 -0700 (PDT) Received: from moss-3 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-508c9373c2esm928951173.84.2025.07.26.18.46.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Jul 2025 18:46:47 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Sat, 26 Jul 2025 13:13:40 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sat, 26 Jul 2025 21:46:46 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Stefan Monnier writes: Thanks for your feedback. >>> I went with (declare ((autoload . macro-expand))) on the notion that >>> there might be other autoload-related declarations in the future, >>> but open to suggestion. > > [ I don't have an opinion on the naming here but I don't understand your > argument: wouldn't a declaration name of `autoload` be *more* likely > to conflict with another future autoload-related declaration? ] I suppose I had imagined multiple flags, =C3=A0 la: (autoload (macro-expand something-else)) but maybe that's frowned on. In which case we should just go with `(autoload-macro . expand)'. > One way to look at it is that the crux of the matter is that we use > `;;;###autoload` for 2 different purpose: > > A. To copy the code into the loaddefs file. > B. To arrange for the file to be autoloaded when the corresponding thingy > is used. > > (B) is the one that deserves the name "autoload" while (A) might be > better named "preload". That's a sensible way of looking at it. > The distinction between the two is not that clear when you consider that > a `;;;###autoload` cookie placed on a `defun` may arrange to autoload > that file when calling that function but it may *also* preload some > `put`s extracted from the `declare`. > > Maybe a "general" solution would be to introduce a `;;;###preload`. > Not sure it's worth the trouble, tho. Could be considered radical. I guess the contract would be that all `;;;###preload's would happen before all `;;;autoload's? I can imagine people confusing these two (similar to use-package's :init vs. :config). > Also, I'm not sure how "general" this would be, since the same problem > will tend to happen with any package which `;;;###autoload` a call to > a macro that's not predefined if that package uses its own > `FOO-loaddefs.el`, even if that macro is defined in some other library. It would be general if it were universally adopted, and autoload scanning proceeded across all files, first generating "stub" loaddefs for preloads, then, in a subsequent pass, doing the autoloads. The main issue as I see it is we are now (for the first time) possibly /loading/ files, vs. just scanning them passively. I think the situation where this distinction matters is quite rare. Note that the only file(s) where a load are attempted now are for TRAMP. > So, the general problem is: your patch will sometimes `eval-buffer` for > a buffer which doesn't expect to be evaluated before its package's > `FOO-loaddefs.el` has been created. I suspect that in most cases this > can be fixed by replacing > > (require 'foo-loaddefs) > by > (require 'foo-loaddefs nil t) > > It's not ideal, but I think it's acceptable. What about big packages (like tramp) that maintain and load their own autoloads, and would like to request macro expansion for some of their package-defined macros, and then also /use/ that macro in autoloads? E.g. imagine if `tramp--with-startup' wanted to be expanded instead of included as-is ("preloaded"). That's a pretty specific case, obviously. > BTW, in the specific case of Tramp, I see: > > (defmacro tramp--with-startup (&rest body) > "Schedule BODY to be executed at the end of tramp.el." > `(add-hook 'tramp--startup-hook (lambda nil ,@body))) > > so I think `tramp--with-startup` *is* one of the macros that would > benefit from your new `(autoload macro-expand)` declaration. Ah right, my imagining above was not so misguided then. Maybe the tramp maintainer will want to expand that simple macro away now. I guess package authors have to decide: - Do you want to include ("preload") your full macro and any autoloaded uses of it (as is) in *-loaddefs.el? You should be sure to require your package's custom autoload file with suppressed errors, in case it doesn't yet exist during build. - Would you prefer your package's macro is expanded at autoload generation time instead? You should require it "for real", and declare it (autoload-macro expand). - You can't get both behaviors. >> [1] Note that the order of declare entries already matters,=20 > > Really? Sounds like a bug. Are you sure? You're right, it was a transitory bug. I've moved them all back to the end (since they are most recently added that seems to make sense). >> (defconst loaddefs--function-like-operators > > "operators" doesn't sound quite right. > Maybe "loaddefs--defining-macros"? Yeah I agree, I was picking up the comment below that: ;; For special function-like operators, use the `autoload' ;; function. But I like your version better (and have changed the comment). >> +Note that macros can request expansion by including `(autoload >> macro-expand)' +among their `declare' forms." > > Nitpick: I'd start "Note..." on its own line. We're not trying to > justify-fill the text. =F0=9F=99=82 Done (even an extra blank to call it out).=20 >> + ;; If the car is entirely unknown, we load the file first to >> + ;; give packages a chance to define their macros. >> + (unless (or (null car) (macrop car) (functionp car) (special-fo= rm-p car) > > I'd test (and (symbolp car) (not (fboundp car))) For whatever reason, I get lots of nil cars. So how about: (unless (or (not (symbolp car)) (fboundp car) (null car) ... ;; try to load the file Is (eq (fboundp x) (or (macrop x) (functionp x) (special-form-p x))) =E2=88=80= x=E2=88=88 (symbolp x)? >> + (memq car '(defclass defcustom deftheme defgroup)) > This deserves a comment in the code. Done. > I'd go with `assoc`. Thanks. >> + (and (macrop car) >> + (eq 'macro-expand ; a macro can declare (autoload macro-expand) >> + (or (get car 'autoload) >> + (get (car-safe (last (function-alias-p car))) 'autoload))) > > I'd have expected `function-get` here. I was honestly vague on the difference. Seems like `function-get' should maybe chase aliases for you... > If we swap this case with the preceding one we can remove the > > (memq car loaddefs--function-like-operators) > > from the `unless` of that case. > [ And it probably results in a diff that's harder to read, so thanks for > not doing it this time. =F0=9F=99=82 ] Good idea. I only recently decided this was necessary. Though it isn't really needed anymore with this change, I think keeping a defconst is a good idea. >> @@ -257,8 +278,8 @@ loaddefs-generate--make-autoload >> t) >> (and (eq (car-safe (car body)) 'interactive) >> ;; List of modes or just t. >> - (or (if (nthcdr 1 (car body)) >> - (list 'quote (nthcdr 1 (car body))) >> + (or (if (nthcdr 2 (car body)) >> + (list 'quote (nthcdr 2 (car body))) >> t)))) >> ,(if macrop ''macro nil))))) > > I think you can just push this to `master` as separate patch, thank you. I've attached a separate patch here (I don't have commit privileges). >> @@ -19835,7 +19836,7 @@ >> loaddefs.el output file, and the rest are the directories to >> use.") >> (load "theme-loaddefs.el" t) >> -(register-definition-prefixes "loaddefs-gen" '("autoload-" "generated-a= utoload-" "loaddefs-generate--" "no-update-autoloads")) >> +(register-definition-prefixes "loaddefs-gen" '("autoload-" "generated-a= utoload-" "loaddefs-" "my/tmp-lddg-list2" "no-update-autoloads")) > > Maybe better use `autoload-` rather than `loaddefs-` as prefix for the > new definitions. > [ I don't see `my/tmp-lddg-list2` in the patch you sent, so I assume it > was something temporary. ] This last file was an inadvertent inclusion. Please take a look at the attached patches, and give a try with your own user macro declaring autoload-expand if you can. If this all looks good I can add to the docs and NEWS. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=no-arg-descriptor-in-autoload.patch Content-Description: Prevent arg descriptor from appearing in autoload diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index b43947d5b2b..20394442167 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -254,8 +254,8 @@ loaddefs-generate--make-autoload t) (and (eq (car-safe (car body)) 'interactive) ;; List of modes or just t. - (or (if (nthcdr 1 (car body)) - (list 'quote (nthcdr 1 (car body))) + (or (if (nthcdr 2 (car body)) + (list 'quote (nthcdr 2 (car body))) t)))) ,(if macrop ''macro nil))))) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=autoload-expand_4.patch Content-Description: New declare form autoload-expand diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 366423904db..3e521e18567 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -271,6 +271,11 @@ 'byte-run--set-debug (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload-macro + #'(lambda (name _args spec) + (list 'function-put (list 'quote name) + ''autoload-macro (list 'quote spec)))) + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -350,8 +355,10 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + (list 'autoload-macro #'byte-run--set-autoload-macro) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -397,6 +404,7 @@ 'defmacro (if declarations (cons 'prog1 (cons def (car declarations))) def)))))) +(function-put 'defmacro 'autoload-macro 'expand) ; Since we cannot `declare' it ;; Now that we defined defmacro we can use it! (defmacro defun (name arglist &rest body) @@ -409,7 +417,7 @@ defun The return value is undefined. \(fn NAME ARGLIST [DOCSTRING] [DECL] [INTERACTIVE] BODY...)" - (declare (doc-string 3) (indent 2)) + (declare (doc-string 3) (indent 2) (autoload-macro expand)) (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 3aa26fba3c3..86f71234657 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -241,8 +241,7 @@ cl-defgeneric DEFAULT-BODY, if present, is used as the body of a default method. \(fn NAME ARGS [DOC-STRING] [OPTIONS-AND-METHODS...] &rest DEFAULT-BODY)" - (declare (indent 2) (doc-string 3) - (debug + (declare (indent 2) (doc-string 3) (debug (&define &interpose [&name sexp] ;Allow (setf ...) additionally to symbols. @@ -258,7 +257,8 @@ cl-defgeneric cl--generic-edebug-make-name in:method] lambda-doc def-body)]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((doc (if (stringp (car-safe options-and-methods)) (pop options-and-methods))) (declarations nil) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2a0a9e5c6de..2b008f5c708 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -398,7 +398,8 @@ cl-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defun ,name ,@(cl--transform-lambda (cons args body) name))) ;;;###autoload @@ -408,7 +409,8 @@ cl-iter-defun and BODY is implicitly surrounded by (cl-block NAME ...). \(fn NAME ARGLIST [DOCSTRING] BODY...)" - (declare (debug + (declare (indent 2) + (debug ;; Same as iter-defun but use cl-lambda-list. (&define [&name sexp] ;Allow (setf ...) additionally to symbols. cl-lambda-list @@ -416,7 +418,7 @@ cl-iter-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (autoload-macro expand)) (require 'generator) `(iter-defun ,name ,@(cl--transform-lambda (cons args body) name))) @@ -475,7 +477,8 @@ cl-defmacro (declare (debug (&define name cl-macro-list cl-declarations-or-string def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defmacro ,name ,@(cl--transform-lambda (cons args body) name))) (def-edebug-elem-spec 'cl-lambda-expr @@ -3001,8 +3004,7 @@ cl-defstruct \\[describe-symbol] or \\[cl-describe-type]. \(fn NAME &optional DOCSTRING &rest SLOTS)" - (declare (doc-string 2) (indent 1) - (debug + (declare (debug (&define ;Makes top-level form not be wrapped. [&or symbolp (gate ;; FIXME: Why? @@ -3011,7 +3013,8 @@ cl-defstruct sexp])] [&optional stringp] ;; All the above is for the following def-form. - &rest &or symbolp (symbolp &optional def-form &rest sexp)))) + &rest &or symbolp (symbolp &optional def-form &rest sexp))) (doc-string 2) (indent 1) + (autoload-macro expand)) (let* ((name (if (consp struct) (car struct) struct)) (warning nil) (opts (cdr-safe struct)) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index f53db48f0b7..cfd71a69b04 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -218,14 +218,15 @@ define-minor-mode INIT-VALUE LIGHTER KEYMAP. \(fn MODE DOC [KEYWORD VAL ... &rest BODY])" - (declare (doc-string 2) - (indent defun) - (debug (&define name string-or-null-p + (declare (debug (&define name string-or-null-p [&optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp] + &optional [¬ keywordp] sexp + &optional [¬ keywordp] sexp] [&rest [keywordp sexp]] - def-body))) + def-body)) + (doc-string 2) + (indent defun) + (autoload-macro expand)) (let* ((last-message (make-symbol "last-message")) (mode-name (symbol-name mode)) @@ -487,7 +488,7 @@ define-globalized-minor-mode on if the hook has explicitly disabled it. \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" - (declare (doc-string 2) (indent defun)) + (declare (doc-string 2) (indent defun) (autoload-macro expand)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 344e11e245e..59784ff51e8 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -675,7 +675,8 @@ iter-defun of values. Callers can retrieve each value using `iter-next'." (declare (indent defun) (debug (&define name lambda-list lambda-doc &rest sexp)) - (doc-string 3)) + (doc-string 3) + (autoload-macro expand)) (cl-assert lexical-binding) (let* ((parsed-body (macroexp-parse-body body)) (declarations (car parsed-body)) diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index c015e2b57d0..5acd6f17ee2 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -135,7 +135,7 @@ define-inline This is like `defmacro', but has several advantages. See Info node `(elisp)Defining Functions' for more details." ;; FIXME: How can this work with CL arglists? - (declare (indent defun) (debug defun) (doc-string 3)) + (declare (indent defun) (debug defun) (doc-string 3) (autoload-macro expand)) (let ((doc (if (stringp (car-safe body)) (list (pop body)))) (declares (if (eq (car-safe (car-safe body)) 'declare) (pop body))) (cm-name (intern (format "%s--inliner" name))) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..b43947d5b2b 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -142,12 +142,29 @@ loaddefs-generate--shorten-autoload 3) form)) +;; TODO: some macros can be removed from this list once they +;; (declare ((autoload-macro expand) ...) +(defconst loaddefs--defining-macros + '(define-skeleton define-derived-mode + define-compilation-mode define-generic-mode + easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode + easy-mmode-define-minor-mode define-minor-mode + cl-defun defun* cl-defmacro defmacro* + define-overloadable-function + transient-define-prefix transient-define-suffix + transient-define-infix transient-define-argument)) + +(defvar loaddefs--load-error-files nil) (defun loaddefs-generate--make-autoload (form file &optional expansion) "Turn FORM into an autoload or defvar for source file FILE. Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. + +Note that macros can request expansion by including `(autoload-macro +expand)' among their `declare' forms." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -196,30 +213,10 @@ loaddefs-generate--make-autoload (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) - (macrop car) - (setq expand (let ((load-true-file-name file) - (load-file-name file)) - (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) - ;; Recurse on the expansion. - (loaddefs-generate--make-autoload expand file 'expansion)) - - ;; For special function-like operators, use the `autoload' function. - ((memq car '(define-skeleton define-derived-mode - define-compilation-mode define-generic-mode - easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode - easy-mmode-define-minor-mode define-minor-mode - cl-defun defun* cl-defmacro defmacro* - define-overloadable-function - transient-define-prefix transient-define-suffix - transient-define-infix transient-define-argument)) + ;; For macros which request it, try again on their expansion. + ;; For known special macros which define functions, use `autoload' + ;; directly. + ((memq car loaddefs--defining-macros) (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) (name (nth 1 form)) (args (pcase car @@ -262,6 +259,32 @@ loaddefs-generate--make-autoload t)))) ,(if macrop ''macro nil))))) + ((progn + ;; If the car is an unknown symbol, we load the file first to + ;; give packages a chance to define their macros. + (unless (or (not (symbolp car)) (fboundp car) (null car) + ;; Special cases handled below + (memq car '(defclass defcustom deftheme defgroup)) + (assoc file load-history) + (member file loaddefs--load-error-files)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s (for %s)" file car) + (condition-case e (load file) + (error + (push file loaddefs--load-error-files) ; do not attempt again + (warn "loaddefs-gen: load error\n\t%s" e))))) + (and (macrop car) + (eq 'expand ; a macro can declare (autoload-macro expand) + (or (function-get car 'autoload-macro) + (function-get (car-safe (last (function-alias-p car))) + 'autoload-macro))) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) + (not (eq car (car expand))))) + ;; Recurse on the expansion. + (loaddefs-generate--make-autoload expand file 'expansion)) + ;; For defclass forms, use `eieio-defclass-autoload'. ((eq car 'defclass) (let ((name (nth 1 form)) diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 73554fd66fd..ab8edf1f569 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -537,7 +537,7 @@ pcase-defmacro By convention, DOC should use \"EXPVAL\" to stand for the result of evaluating EXP (first arg to `pcase'). \n(fn NAME ARGS [DOC] &rest BODY...)" - (declare (indent 2) (debug defun) (doc-string 3)) + (declare (indent 2) (debug defun) (doc-string 3) (autoload-macro expand)) ;; Add the function via `fsym', so that an autoload cookie placed ;; on a pcase-defmacro will cause the macro to be loaded on demand. (let ((fsym (intern (format "%s--pcase-macroexpander" name))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 27 03:12:38 2025 Received: (at 78995) by debbugs.gnu.org; 27 Jul 2025 07:12:38 +0000 Received: from localhost ([127.0.0.1]:47773 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ufvYj-0001w8-KY for submit@debbugs.gnu.org; Sun, 27 Jul 2025 03:12:38 -0400 Received: from mout.gmx.net ([212.227.17.22]:42933) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ufvYf-0001vg-Bx for 78995@debbugs.gnu.org; Sun, 27 Jul 2025 03:12:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1753600346; x=1754205146; i=michael.albinus@gmx.de; bh=Tj8o6ELhrv5u0efayM3PbJ6JRgjQlh3z7tDkTFawx6Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=L3fB9orB53MrALntiiRdUJEzonXE48vPn/pJ6mNBfhfT9NGVo2HLhr4MOEsunWvC 2qQNPxnxuOgnHFfmSLX1oaen6yFbiiLMmxOjzWwq2IzlTQZlcOZE6xa6OFLEkbCfX ZplJeJDDU4z/CoqfeHCi9yaI8aeKWPPXLwxOTVtyGPWhgb4ebovK0sovtT9XeK2x3 eoBEKT14eaqmi04VS8vvquM6n6frw47KbCcA3a8JERVsiBZkyFpoejagey9Wn4948 sypJ9MG3wdpT8WaLtGHP3egsVUUqMVCYGptQ4nfWhnrmmqL5eW/4NBwD2CuL0gyPT /zNjLJrhj86hekgNtg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.61]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MXp5Q-1vBmon3r7E-00UC2y; Sun, 27 Jul 2025 09:12:26 +0200 From: Michael Albinus To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sun, 27 Jul 2025 09:12:24 +0200 Message-ID: <87pldm85uv.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:n2K2rwjU0lqDa6lwNJcub2HgaajGlaVZPKqs3Pb1g2WWnEegiiP bAr6QMKPP9hoC0g9sqzx7FiWw766RDNIBi2y0Dwr8nMClkmIf8IdNe4L2zHuBOR18Oio9Qo YttFfkAZyy1DfrEQ9A2Z3jvsZtFOmbZV1t1c0wLaqmfA0z8d9ztNGPV0ZEWij+Bsjr7XM1W 3EJ9lxwYJHQwLUAzUS6dw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:mYxrHNRna2U=;jFq02HuRtJ4kjyKZFO6sULx2pA3 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 Yky5Mup95kA== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) "J.D. Smith" writes: Hi, >> BTW, in the specific case of Tramp, I see: >> >> (defmacro tramp--with-startup (&rest body) >> "Schedule BODY to be executed at the end of tramp.el." >> `(add-hook 'tramp--startup-hook (lambda nil ,@body))) >> >> so I think `tramp--with-startup` *is* one of the macros that would >> benefit from your new `(autoload macro-expand)` declaration. > > Ah right, my imagining above was not so misguided then. Maybe the tramp > maintainer will want to expand that simple macro away now. I give this explanation to Stefan, he added this macro to Tramp years ago (commit 07d8827946f9) :-) --8<---------------cut here---------------start------------->8--- Functionally split tramp-loaddefs.el into two parts: one part run while loading it at the very beginning of loading tramp.el (holding plain autoloads and declarations), and another run at the very end of loading tramp.el (holding setup code). This should reduce infinite-recursion problems while loading. --8<---------------cut here---------------end--------------->8--- See also bug#59194, which waits for me understanding what to do. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 27 09:12:08 2025 Received: (at 78995) by debbugs.gnu.org; 27 Jul 2025 13:12:08 +0000 Received: from localhost ([127.0.0.1]:49016 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ug1Ad-0006IP-Du for submit@debbugs.gnu.org; Sun, 27 Jul 2025 09:12:07 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:3849) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ug1AV-0006HN-5H for 78995@debbugs.gnu.org; Sun, 27 Jul 2025 09:12:04 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 0912180A13; Sun, 27 Jul 2025 09:11:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1753621908; bh=fXxTn7yiXeUjzjveUX5uKydQVMxnxgjWsJVwzT8wW4o=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=g73F/sYL2wKxLdyTwAKl5iVTQJDVV2Vkipmvla8z0GaHpG2iQn3+JmfR4fB/3T6wq bwTLCmq1RSqGgdBOaXLglHtLpcsQCpQ0cvW+tu5/FFWc8+wuA8cjeCgc0PQt7yQ95P F3gxgSCHazyoDPAsB79asBfv2H3ADgnD+bUcfmMwK01hZ+wWkDaButnTBTOVp1VEso QytQHiVAnPs+y62GSlN6ylR8tcGywYpGOSmAB7G5GJbyhR6iPFEFasy0eeQ+JH8qBN TxW7qPOJU8KDYSR/0Cev+ZCmEuI+Fo04AsuRqnD/RzA7wx5x91QQMT/2cFxL+UFw4W coQihpqHC63AA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5BEF080030; Sun, 27 Jul 2025 09:11:48 -0400 (EDT) Received: from pastel (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2A2211209BC; Sun, 27 Jul 2025 09:11:48 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sun, 27 Jul 2025 09:11:47 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.264 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Michael Albinus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I suppose I had imagined multiple flags, =C3=A0 la: > > (autoload (macro-expand something-else)) > > but maybe that's frowned on. It's not frowned upon no. You could also have (autoload macro-expand something-else) >> Maybe a "general" solution would be to introduce a `;;;###preload`. >> Not sure it's worth the trouble, tho. > Could be considered radical. I guess the contract would be that all > `;;;###preload's would happen before all `;;;autoload's? I can imagine > people confusing these two (similar to use-package's :init vs. :config). Yeah, I'd rather not go there (I think it might have made sense to distinguish the two at the beginning, but now that it's been conflated for so many years it'd be much harder to introduce the distinction). >>> + ;; If the car is entirely unknown, we load the file first to >>> + ;; give packages a chance to define their macros. >>> + (unless (or (null car) (macrop car) (functionp car) (special-f= orm-p car) >> >> I'd test (and (symbolp car) (not (fboundp car))) > > For whatever reason, I get lots of nil cars. Hmm... then there's something I'm missing. I wonder in which case(s) `car` is nil here. > So how about: > > (unless (or (not (symbolp car)) (fboundp car) (null car) > ... ;; try to load the file Fine by me, tho I'd still like to understand why we need to care about `nil= `. We could also add `nil` to the (defclass defcustom deftheme defgroup) list. > Is > > (eq (fboundp x) (or (macrop x) (functionp x) (special-form-p x))) =E2=88= =80x=E2=88=88 (symbolp x)? No. E.g. `x` could be bound to a keymap, or to a string (old-style keyboard macro), or potentially to anything else (integer, hash-table, you name it: that's not useful in the `symbol-function` cell but that doesn't mean it can't happen). >> I'd have expected `function-get` here. > I was honestly vague on the difference. Seems like `function-get' > should maybe chase aliases for you... It does. >> I think you can just push this to `master` as separate patch, thank you. > I've attached a separate patch here (I don't have commit privileges). Hmm... According to https://savannah.gnu.org/project/memberlist.php?group=3Demacs, John-David T. Smith does have commit privileges. I know "Smith" is not exactly rare, but... I'll gladly push it, if you prefer, of course. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 27 09:14:53 2025 Received: (at 78995) by debbugs.gnu.org; 27 Jul 2025 13:14:53 +0000 Received: from localhost ([127.0.0.1]:49025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ug1DI-0006Pc-Lz for submit@debbugs.gnu.org; Sun, 27 Jul 2025 09:14:53 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:18315) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ug1DF-0006P6-Aw for 78995@debbugs.gnu.org; Sun, 27 Jul 2025 09:14:50 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D5192440A96; Sun, 27 Jul 2025 09:14:43 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1753622074; bh=daRlS765sCAtmh1Iw/xG2a1LzJjGCRF6LYjzMeFndRQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=hyfR2S+apjnbYuZBf7Bq0LPBIA1auS0ZXwXpROOiw9Jjr9VDBU08/Sqm6rslnANXZ h8z4uxP6HSTz55I6Jij4szUiTFokYPQKaruL39jTf20xeECLzpqJmz+REkcN1HobVG UmwqaPxH6FlAXTgtZHW8kDi3Vk7C1nzhSnbLw6SiZVV5bm6k6vqyn6HIeugRtOagdd wXjF6I5vy6ZDDbxoWYYVmCHkD9qtC17vygcz31NnDnzsnTsOHqPM8s/ZBun42kAvIZ ul7IF+ipjeHJRbNH/GxQ7Ck7Gtck9r6Bge1/b+CFOceGKg5jxq9AXAWQacKP1Ux47f LfEiAVVF7m/rA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4CDAA44038F; Sun, 27 Jul 2025 09:14:34 -0400 (EDT) Received: from pastel (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1F4C2120807; Sun, 27 Jul 2025 09:14:34 -0400 (EDT) From: Stefan Monnier To: Michael Albinus Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <87pldm85uv.fsf@gmx.de> Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87pldm85uv.fsf@gmx.de> Date: Sun, 27 Jul 2025 09:14:33 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.268 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, "J.D. Smith" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> Ah right, my imagining above was not so misguided then. Maybe the tramp >> maintainer will want to expand that simple macro away now. > > I give this explanation to Stefan, he added this macro to Tramp years > ago (commit 07d8827946f9) :-) > > --8<---------------cut here---------------start------------->8--- > Functionally split tramp-loaddefs.el into two parts: one part run > while loading it at the very beginning of loading tramp.el (holding plain > autoloads and declarations), and another run at the very end of loading > tramp.el (holding setup code). > This should reduce infinite-recursion problems while loading. > --8<---------------cut here---------------end--------------->8--- > > See also bug#59194, which waits for me understanding what to do. [ It did look like something I'd seen before but I had no recollection of actually writing it. ] Damn! So now I'm the one who needs to figure out how to keep it working in Emacs<31 while trying to make it behave with the new "autoload-expand". Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 27 13:59:16 2025 Received: (at 78995) by debbugs.gnu.org; 27 Jul 2025 17:59:16 +0000 Received: from localhost ([127.0.0.1]:51685 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ug5eV-00084v-SO for submit@debbugs.gnu.org; Sun, 27 Jul 2025 13:59:16 -0400 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]:59693) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ug5eT-00084c-Bw for 78995@debbugs.gnu.org; Sun, 27 Jul 2025 13:59:14 -0400 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3e3cecf0b53so13543205ab.3 for <78995@debbugs.gnu.org>; Sun, 27 Jul 2025 10:59:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753639147; x=1754243947; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=EjauwJjExJIMF1t6JVfQInYhAr0brIDP8PNcfyVMOrc=; b=ajtTd0p5s44aDnsvsCK6TW6+xVX8+29qS5S4phVL6AZy4IL+mrUCzGvRw6MFX3daaH 7qqDrXfFdSY/38Icx3Tf0mhsg81rYiNnCEksJUPd62s4bC3BbIIxuMURLWntWTyXKBW9 NM9bhs9LdWE8JlLSvLgMCmnVWLFthUej02Ue0v00Zz/uXVF1SakeY67rh71TyMPTN5c/ L6oIQS1aQuSnc+z0cX107OhiGvtR0ltgnWkR4OUVk70lZGogY7PrbUiXe9dvWLPPII1P kR89ZRbINNJwQEVMdWD/mg4lga2Kn8b8hLKhqkxIZPNOUZaRBu3wMmb6Vpu6biVPM7S1 agWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753639147; x=1754243947; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EjauwJjExJIMF1t6JVfQInYhAr0brIDP8PNcfyVMOrc=; b=lzEgGv45KWGPzSfJ6usxqcw4Ro2rlLdvL62UA7lVpyFhLzCnQQwOasERm6X/cn4tpq a7e0OqkDf/7b5n6+VhEi4yokIW5sBZkhXlKk5g0DB90nvAkGTANGaZB2bE6bpKn7tiUa bEvpXIUGP7Na0E/yIfcgBsHvxBCzL0cD4pUUUcBuS+rQpyDdFhoQs9N791PPGQY5bnFi 8lGoZD8Ym58aiIDJ9GvJDHfAsDhG0PqLHV6S4f/6R2Ido3k0M0St6hSchR+c1M9SVl52 D5BBOPBl41t9STJ9ytmHWOY2NdeTtrtffLOhK0vDvsEb0DgWRtylqtaTgYxDTcJXhvyF aPxw== X-Forwarded-Encrypted: i=1; AJvYcCUmpFB2fcvJRR9nGmDTMBnEujZZijbbdriKhGXgUlIpvdpI/yh75VdQR55PH4aHhkckUpC78A==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyAmZ4cQduYsoFE3sgHHt4WtmApB/8tgz/54EFejb3xaNHDFT2m 90iXFbYHUBO84CHNsnnu1DTeDxT9DE4KWzSbbgtdBQ/xYIqLnGrrt8HSTwPUug== X-Gm-Gg: ASbGncskcEO07N+dQP73ZUkL97xmf5rjuZIegBe85c0FWIc5ehydElNG/4YVbAredPL aPJl9umpcOSEJgQJ1PLDrctb7BHnEu7QN6yF43ibi2fPfgAgFK229fjHzacDufdVEojCbaof4Ds nZQKjxHPKFmomUs53QtOxjxvNZfKDVaNlK5eWz2yYEjRbHBcFybh/aZmDnF+jY27e5YR7N+RndC YReDHLIq9VPpgYe/qHkByw+YhXfqdMJIOX129Mi8H63B7HwjiX9Y6bShDs+dtSXI4c4jtjPvo8v NJCokTjVwsyDdTBCT3HXRk1/HsCTIentdCemOW6TaOp09lKoAEuChrLvRcbqManKZSTop+QF68i SUCxtZxnqVx+2Fv/BcVXHgIdHL7q2qkpuzT2oKQ+M1/ycoMS1MsMBceTX X-Google-Smtp-Source: AGHT+IGC41mYVpMsHi/7OoZ5XyXjgUFC4aIpG6NWtMGgfqSCSInW3G5D4DRzaf5ScKyOUAHgmpvjgA== X-Received: by 2002:a05:6e02:1543:b0:3e3:a35f:a1b2 with SMTP id e9e14a558f8ab-3e3c527f044mr191775795ab.8.1753639146793; Sun, 27 Jul 2025 10:59:06 -0700 (PDT) Received: from moss-3 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3e3cacf7b1csm16754555ab.60.2025.07.27.10.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 10:59:06 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Sun, 27 Jul 2025 09:14:33 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87pldm85uv.fsf@gmx.de> Date: Sun, 27 Jul 2025 13:59:05 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Michael Albinus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >>> Ah right, my imagining above was not so misguided then. Maybe the tramp >>> maintainer will want to expand that simple macro away now. >> >> I give this explanation to Stefan, he added this macro to Tramp years >> ago (commit 07d8827946f9) :-) >> >> --8<---------------cut here---------------start------------->8--- >> Functionally split tramp-loaddefs.el into two parts: one part run >> while loading it at the very beginning of loading tramp.el (holding plain >> autoloads and declarations), and another run at the very end of loading >> tramp.el (holding setup code). >> This should reduce infinite-recursion problems while loading. >> --8<---------------cut here---------------end--------------->8--- >> >> See also bug#59194, which waits for me understanding what to do. > > [ It did look like something I'd seen before but I had no recollection > of actually writing it. ] > > Damn! So now I'm the one who needs to figure out how to keep it working > in Emacs<31 while trying to make it behave with the new > "autoload-expand". Maybe it is as simple as requiring a (new?) file that defines the macro directly, and whenever you require tramp-loaddefs, using NOERROR=t? Then in Emacs 31, the first file with an ;;;###autoload followed by usage of TRAMP's macro will be loaded, causing the macro to be defined. If you want, you can declare `(autoload-macro expand)' when you define the macro (I think old Emacs version will just ignore it?). This will mean: - In Emacs 31: the macro itself is never mentioned, but the add-hook and any other forms are instead copied into tramp-loaddefs. - In earlier Emacs, the macro and then calls to it are both included in tramp-loaddefs, just as they are now. I think either setup works (though on-demand expansion may be "safer", since it doesn't depend on load order any more.) From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 27 15:14:34 2025 Received: (at 78995) by debbugs.gnu.org; 27 Jul 2025 19:14:34 +0000 Received: from localhost ([127.0.0.1]:51819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ug6pM-00046t-Lh for submit@debbugs.gnu.org; Sun, 27 Jul 2025 15:14:33 -0400 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]:56391) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ug6pI-00046T-R8 for 78995@debbugs.gnu.org; Sun, 27 Jul 2025 15:14:30 -0400 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-879c737bc03so101332539f.0 for <78995@debbugs.gnu.org>; Sun, 27 Jul 2025 12:14:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753643663; x=1754248463; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=uhDFxqhW6+2xTGkhGWkrtMpO99Z6vx8mi2f7jYWX3w0=; b=NJnm6ZtzasS3DiVDEO+rFPH6PCb1G9WFV+m9GiVSKY3PyzGr8CnQSG28feWtd2kgB7 1TLrAljhMILNs5jsnTOm91G424PuuxgGbMH4tLFF35lfXt0wOYlM+7NmcLYoZfUkQpEJ fXKh8Jao8dOcqyu55yfCTTwFLWjxJ861zW+2rXxMVp5lue02nWU08nc24daaKbiIFkKT QzhVzXp3NG/U6BvFwbaxoMTYpDqLGvHgmNB17C+wmo87pMkYbctBYxGgBbQDD7y7dA+y MRthVQXmgsLbIjS74IoC14D49ffO2w2x8GhAZkKJ7UHNieVVyBTmg5ukOw9FABvvCs0g ZLWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753643663; x=1754248463; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uhDFxqhW6+2xTGkhGWkrtMpO99Z6vx8mi2f7jYWX3w0=; b=F2eK4T9i1UWPtL+9TzvaVM68aCVwPXUSJhnx3CaQKkLTIp0Qzq7m0lIFHZ8GwULebM 88SOF2uYHzGV7OSJyIT9fk/ZtTh2j95K3cXMjrI89rYqHg1RNVQGv+mNEyiVl874coad 2qsUu4gFOPWfB6tp06a8ZN1B+x4Iq8N9hXJWrbwy7nwY7Eilfbj+ICBWNTLdFuRIVCcX 2W+qE5NhTXNcVXPQXoHG6iL3RTMKLQXwvrjspYatNTrMvInQYNJfkXCm0VopEev/q7eB hy6kF8I6XKFkE1erY5nLlcEKtwWfKv/xCR6DPZp1gNQbwRGwttjPWJuleKBjxUfMOEWs 7xKA== X-Gm-Message-State: AOJu0Yz96pExM/dmJoFJnpyQnaoz1AeKL6uLhx1FPr9tFfMgmO7InM2W keZSXwusMMqYB2VhaTeEZ5DBOX7MO5qLKTMlsjh+iPjViZA/Liz+aQlH X-Gm-Gg: ASbGncukjX/9k2W6LsPfOveTvMj0KHbKyAv1K9hkkOU2WQXdE+TXs2i4HklCtI4tlVl b6i8jqD9LDBUWcAFZJHU4eMmS0EBnyDWuSHOqFKWDQ/uIR7kRPIk2gR0W36MaTFnXtxfzwhTQO5 NPAEzep243BrGISjKKH/QppKg87uwGiRaDhuHvY9bua9cg2WVpVuZ9y5JNd3O3lhLgMaQUS6WVz I9w8bBA65nJmsQhy9XtLBUplwQWsP59P5I0lVqRSEZMiFvjLynfV0S4PzXlrTzac1GIUVyI+c1/ 4lfo3DW9X46qkg8lLlpRzG3aiPljVTm6t6uiM8wNvxQF5Lhl67iTx4Y+lBPnbXOph9O3FQmraBs AV95f1IDUeW0iiqT5dAiA66/Ho4HVKcOHJZTUB0qFnQJ6rNM99Lsv9AaS X-Google-Smtp-Source: AGHT+IF5mnW6rdVkMig0PH7PH374ohQKlgB68SOpW8NWreBsb/zvvfdKeYSQAk7BMiTb4s+sLkcw0w== X-Received: by 2002:a05:6602:26ce:b0:86c:cf7e:d85d with SMTP id ca18e2360f4ac-88022991232mr1644172939f.12.1753643662447; Sun, 27 Jul 2025 12:14:22 -0700 (PDT) Received: from moss-3 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-880f79b3631sm120326439f.14.2025.07.27.12.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jul 2025 12:14:21 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Sun, 27 Jul 2025 09:11:47 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sun, 27 Jul 2025 15:14:21 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Michael Albinus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Stefan Monnier writes: >> For whatever reason, I get lots of nil cars. > > Hmm... then there's something I'm missing. > I wonder in which case(s) `car` is nil here. One big category of nil car's resulted from all the :autoload-end's around. Because only the tail /after/ that keyword is trimmed (a classic singly linked list issue), the keyword itself remains in the form, and was still being (pointlessly) recursed on. Easy fix. That leaves a number with explicit nil cars in their expansion, for whatever reason: Got nil car: nil "display-line-numbers" expansion Got nil car: nil "elec-pair" expansion Got nil car: nil "emacs-lock" expansion Got nil car: nil "hi-lock" expansion Got nil car: nil "hilit-chg" expansion Got nil car: nil "ruler-mode" expansion Got nil car: nil "saveplace" expansion Got nil car: nil "tab-line" expansion INFO Scraping 1566 files for loaddefs...17%=20 Got nil car: nil "visual-wrap" expansion Got nil car: nil "whitespace" expansion Got nil car: nil "window-tool-bar" expansion INFO Scraping 1566 files for loaddefs...39%=20 INFO Scraping 1566 files for loaddefs...64%=20 Got nil car: nil "goto-addr" expansion loaddefs-gen: loading file tramp-adb (for tramp--with-startup) Loading tramp-adb... Source file =E2=80=98code/emacs/emacs-mac/lisp/net/tramp-loaddefs.el=E2= =80=99 newer than byte-compiled file; using older file Source file =E2=80=98code/emacs/emacs-mac/lisp/emacs-lisp/cl-loaddefs.el= =E2=80=99 newer than byte-compiled file; using older file INFO Scraping 1566 files for loaddefs...80%=20 Got nil car: nil "cwarn" expansion Got nil car: nil "subword" expansion Got nil car: nil "subword" expansion INFO Scraping 1566 files for loaddefs...92%=20 Got nil car: nil "word-wrap-mode" expansion Probably define-minor-mode includes some bare symbols in the expansion? Are there good reasons for including non-forms in an autoload file? Bare strings or symbols? BTW, I also realized there actually /was/ a small reason to put the `autoload-macro' cond form first, before the special cases: all presence on that list does is avoid /loading/ the file, if any symbol-car's happen to be undefined (which is of course unlikely for such a hard-coded list of special macros). The recursing on expansion still happens, if requested. Putting ours first is a form of eating our own dog food. If all the defining-macros are cleaned up so that expansions are sensible, the special case can be entirely omitted in favor of direct expansion. Letting the macros advertise their own interactive forms =3D fewer bugs (of the nthcdr sort I had to correct). Right now, autoloads proceed through the special case for: - define-derived-mode - cl-defun (I guess because cl-macs.el is not loaded?) - define-overloadable-function - define-skeleton - define-compilation-mode >>> I'd have expected `function-get` here. >> I was honestly vague on the difference. Seems like `function-get' >> should maybe chase aliases for you... > > It does. Oh nice. Not obvious from its code. I've simplified accordingly.=20 >>> I think you can just push this to `master` as separate patch, thank yo= u. >> I've attached a separate patch here (I don't have commit privileges). > > Hmm... According to > https://savannah.gnu.org/project/memberlist.php?group=3Demacs, > John-David T. Smith does have commit privileges. I know "Smith" is not > exactly rare, but... Huh, maybe I've just never exercised them. Or maybe I assumed there would be a ceremony of some kind :). > I'll gladly push it, if you prefer, of course. No, it's a good chance to learn. Will want to iterate on docs first, if you think its ready (I think it is). I took the chance to clean up the declare forms to simplify the diff as well. Have you had a chance to test it "in the wild" with a custom macro? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=autoload-expand_5.patch Content-Description: autoload-expand patch diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 366423904db..3e521e18567 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -271,6 +271,11 @@ 'byte-run--set-debug (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload-macro + #'(lambda (name _args spec) + (list 'function-put (list 'quote name) + ''autoload-macro (list 'quote spec)))) + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -350,8 +355,10 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + (list 'autoload-macro #'byte-run--set-autoload-macro) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -397,6 +404,7 @@ 'defmacro (if declarations (cons 'prog1 (cons def (car declarations))) def)))))) +(function-put 'defmacro 'autoload-macro 'expand) ; Since we cannot `declare' it ;; Now that we defined defmacro we can use it! (defmacro defun (name arglist &rest body) @@ -409,7 +417,7 @@ defun The return value is undefined. \(fn NAME ARGLIST [DOCSTRING] [DECL] [INTERACTIVE] BODY...)" - (declare (doc-string 3) (indent 2)) + (declare (doc-string 3) (indent 2) (autoload-macro expand)) (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 3aa26fba3c3..4a85d89d5fa 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -258,7 +258,8 @@ cl-defgeneric cl--generic-edebug-make-name in:method] lambda-doc def-body)]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((doc (if (stringp (car-safe options-and-methods)) (pop options-and-methods))) (declarations nil) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2a0a9e5c6de..1b64f106a1b 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -398,7 +398,8 @@ cl-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defun ,name ,@(cl--transform-lambda (cons args body) name))) ;;;###autoload @@ -416,7 +417,8 @@ cl-iter-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) (require 'generator) `(iter-defun ,name ,@(cl--transform-lambda (cons args body) name))) @@ -475,7 +477,8 @@ cl-defmacro (declare (debug (&define name cl-macro-list cl-declarations-or-string def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defmacro ,name ,@(cl--transform-lambda (cons args body) name))) (def-edebug-elem-spec 'cl-lambda-expr @@ -3011,7 +3014,8 @@ cl-defstruct sexp])] [&optional stringp] ;; All the above is for the following def-form. - &rest &or symbolp (symbolp &optional def-form &rest sexp)))) + &rest &or symbolp (symbolp &optional def-form &rest sexp))) + (autoload-macro expand)) (let* ((name (if (consp struct) (car struct) struct)) (warning nil) (opts (cdr-safe struct)) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index f53db48f0b7..0e428abd0b7 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -222,10 +222,11 @@ define-minor-mode (indent defun) (debug (&define name string-or-null-p [&optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp] + &optional [¬ keywordp] sexp + &optional [¬ keywordp] sexp] [&rest [keywordp sexp]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((last-message (make-symbol "last-message")) (mode-name (symbol-name mode)) @@ -487,7 +488,7 @@ define-globalized-minor-mode on if the hook has explicitly disabled it. \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" - (declare (doc-string 2) (indent defun)) + (declare (doc-string 2) (indent defun) (autoload-macro expand)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 344e11e245e..59784ff51e8 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -675,7 +675,8 @@ iter-defun of values. Callers can retrieve each value using `iter-next'." (declare (indent defun) (debug (&define name lambda-list lambda-doc &rest sexp)) - (doc-string 3)) + (doc-string 3) + (autoload-macro expand)) (cl-assert lexical-binding) (let* ((parsed-body (macroexp-parse-body body)) (declarations (car parsed-body)) diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index c015e2b57d0..5acd6f17ee2 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -135,7 +135,7 @@ define-inline This is like `defmacro', but has several advantages. See Info node `(elisp)Defining Functions' for more details." ;; FIXME: How can this work with CL arglists? - (declare (indent defun) (debug defun) (doc-string 3)) + (declare (indent defun) (debug defun) (doc-string 3) (autoload-macro expand)) (let ((doc (if (stringp (car-safe body)) (list (pop body)))) (declares (if (eq (car-safe (car-safe body)) 'declare) (pop body))) (cm-name (intern (format "%s--inliner" name))) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..f9c6f82c31f 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -142,12 +142,29 @@ loaddefs-generate--shorten-autoload 3) form)) +;; TODO: some macros can be removed from this list once they +;; (declare ((autoload-macro expand) ...) +(defconst loaddefs--defining-macros + '(define-skeleton define-derived-mode + define-compilation-mode define-generic-mode + easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode + easy-mmode-define-minor-mode define-minor-mode + cl-defun defun* cl-defmacro defmacro* + define-overloadable-function + transient-define-prefix transient-define-suffix + transient-define-infix transient-define-argument)) + +(defvar loaddefs--load-error-files nil) (defun loaddefs-generate--make-autoload (form file &optional expansion) "Turn FORM into an autoload or defvar for source file FILE. Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. + +Note that macros can request expansion by including `(autoload-macro +expand)' among their `declare' forms." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -191,35 +208,40 @@ loaddefs-generate--make-autoload (setq form (copy-sequence form)) (setcdr (memq :autoload-end form) nil)) (let ((exps (delq nil (mapcar (lambda (form) - (loaddefs-generate--make-autoload - form file expansion)) + (unless (eq form :autoload-end) + (loaddefs-generate--make-autoload + form file expansion))) (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) - (macrop car) - (setq expand (let ((load-true-file-name file) - (load-file-name file)) - (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) + ;; For macros which request it, try again on their expansion. + ((progn + ;; If the car is an unknown symbol, we load the file first to + ;; give packages a chance to define their macros. + (unless (or (not (symbolp car)) (fboundp car) + ;; Special cases handled below + (memq car loaddefs--defining-macros) + (memq car '(defclass defcustom deftheme defgroup nil)) + (assoc file load-history) + (member file loaddefs--load-error-files)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s (for %s)" file car) + (condition-case e (load file) + (error + (push file loaddefs--load-error-files) ; do not attempt again + (warn "loaddefs-gen: load error\n\t%s" e))))) + (and (macrop car) + (eq 'expand (function-get car 'autoload-macro)) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) + (not (eq car (car expand))))) ;; Recurse on the expansion. (loaddefs-generate--make-autoload expand file 'expansion)) - ;; For special function-like operators, use the `autoload' function. - ((memq car '(define-skeleton define-derived-mode - define-compilation-mode define-generic-mode - easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode - easy-mmode-define-minor-mode define-minor-mode - cl-defun defun* cl-defmacro defmacro* - define-overloadable-function - transient-define-prefix transient-define-suffix - transient-define-infix transient-define-argument)) + ;; For known special macros which define functions, use `autoload' + ;; directly. + ((memq car loaddefs--defining-macros) (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) (name (nth 1 form)) (args (pcase car diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 73554fd66fd..ab8edf1f569 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -537,7 +537,7 @@ pcase-defmacro By convention, DOC should use \"EXPVAL\" to stand for the result of evaluating EXP (first arg to `pcase'). \n(fn NAME ARGS [DOC] &rest BODY...)" - (declare (indent 2) (debug defun) (doc-string 3)) + (declare (indent 2) (debug defun) (doc-string 3) (autoload-macro expand)) ;; Add the function via `fsym', so that an autoload cookie placed ;; on a pcase-defmacro will cause the macro to be loaded on demand. (let ((fsym (intern (format "%s--pcase-macroexpander" name))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 29 17:18:52 2025 Received: (at 78995) by debbugs.gnu.org; 29 Jul 2025 21:18:52 +0000 Received: from localhost ([127.0.0.1]:36683 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugril-0006E8-86 for submit@debbugs.gnu.org; Tue, 29 Jul 2025 17:18:51 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:26220) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ugrii-0006Db-WC for 78995@debbugs.gnu.org; Tue, 29 Jul 2025 17:18:49 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id BA36180A05; Tue, 29 Jul 2025 17:18:41 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1753823920; bh=rsmRh9rMctu8OE0meXx1oqxWSKMInYBeoA/uU6cGfA4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=awQRPP/ES2XlFjpVr5IXODq+l3EMdP7HiQ6R/WGmYjHo0Y1GPKpNGJ1qjeuRGW95E oIdxZHWCielHtNStxMYUykuIT0VFM3SW4NyQlytfbm+WgOl++DWyQdXbYPsqmyNgvJ 9tParQGW06f09rWemOeeYE/HH92qfJ9L97kGX+i4vAjn4cOR9xUnSH3mWq6zgn/U2f HnLF/ESh60UQhGJ1Rf93FHGKfqNSPrK5U1FMVprsqdkft5XWHXKuZtLFejOoVHjZkJ fIjjPZSqQmr+f0ACTDFJ5zKp8ZYoPGWc6h6F0QMdS+RDMZPiLL6KSqqlYG+SXsm3Yb SEHQhhidOKyfQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id BA6DE805B1; Tue, 29 Jul 2025 17:18:40 -0400 (EDT) Received: from alfajor (unknown [23.233.149.155]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9807A120B28; Tue, 29 Jul 2025 17:18:40 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87pldm85uv.fsf@gmx.de> Date: Tue, 29 Jul 2025 17:18:33 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.192 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Michael Albinus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> Damn! So now I'm the one who needs to figure out how to keep it working >> in Emacs<31 while trying to make it behave with the new >> "autoload-expand". > Maybe it is as simple as requiring a (new?) file that defines the macro > directly, and whenever you require tramp-loaddefs, using NOERROR=t? I *think* it's simpler than that: just add the `declare` thingy and the NOERROR=t. Stefan diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 9787e3a6553..f003bbebf31 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -29,7 +29,7 @@ ;;; Code: -(require 'tramp-loaddefs) +(require 'tramp-loaddefs nil t) ;; Don't error while building the autoloads. (require 'ansi-color) (require 'auth-source) (require 'format-spec) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 2208ce880d7..485c18fc4a2 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -105,6 +105,7 @@ tramp-completion-file-name-regexp (defmacro tramp--with-startup (&rest body) "Schedule BODY to be executed at the end of tramp.el." + (declare (autoload macro-expand)) `(add-hook 'tramp--startup-hook (lambda () ,@body))) (eval-and-compile From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 29 17:30:05 2025 Received: (at 78995) by debbugs.gnu.org; 29 Jul 2025 21:30:05 +0000 Received: from localhost ([127.0.0.1]:36723 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugrtc-0006uR-Pi for submit@debbugs.gnu.org; Tue, 29 Jul 2025 17:30:05 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40826) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ugrtZ-0006sU-Ut for 78995@debbugs.gnu.org; Tue, 29 Jul 2025 17:30:02 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id EA9E34415A4; Tue, 29 Jul 2025 17:29:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1753824590; bh=7UZq2wJD1nWfvNIiJy+5xBM189MIqAYi/S+3xqF5m9g=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=poT5sVfvi7XsHX4KM67d44YRVBMfEU2UFtmELIoompUu2Y0ts/NcVOnS3ikvwMasj bitG6ApQirg4lgx9EPzPoLe9er6q9emgaTeGCpeRCkChwtXEsxm1P05RReZoYbFBPB mJG8Aup4e5QaO4DMtMJq79ggc0lKAWy27yQw+zGiEDtUg1t7YT2qD3JW9krAjTcrji 7yqmuB2ih8FwUb1U3Xb7dfEZVUeSH3a+kDBDI3yLgEtYaMNHgwWewj2ph7AmvfSEdt PVaW7J+ZIpQuiMB3itNOR62Z2g7XyjxowTVGXEwUtnZuHwDbV+VR8TMkoiNLNtw9/Z sIMJEienV69Lw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 950964415A2; Tue, 29 Jul 2025 17:29:50 -0400 (EDT) Received: from alfajor (unknown [23.233.149.155]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 755DB1204BC; Tue, 29 Jul 2025 17:29:50 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Tue, 29 Jul 2025 17:29:49 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.178 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Michael Albinus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > One big category of nil car's resulted from all the :autoload-end's around. Oh, what you mean is that nil is when the element is not a cons cell? Indeed that makes sense. [ Cons cells with a nil element would be surprising, OTOH. ] > That leaves a number with explicit nil cars in their expansion, for > whatever reason: I think these have `nil` in the list of forms (that follows a `progn`), but not in the `car` of one of the forms, right? So again, it's when `form` is not a cons-cell. In any case, indeed those non-cons situations justify the "not nil" check. > Probably define-minor-mode includes some bare symbols in the expansion? > Are there good reasons for including non-forms in an autoload file? > Bare strings or symbols? No, they can be removed, but if we compile the `.el`, then the compiler takes care of it for us. >> I'll gladly push it, if you prefer, of course. > No, it's a good chance to learn. Will want to iterate on docs first, if > you think its ready (I think it is). I was thinking to do it in the single-hunk bug fix, which I do think is ready (it just needs a commit message). > Have you had a chance to test it "in the wild" with a custom macro? No, not yet. But I think the transient macros are a good test case. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 29 20:36:23 2025 Received: (at 78995) by debbugs.gnu.org; 30 Jul 2025 00:36:23 +0000 Received: from localhost ([127.0.0.1]:37272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugunu-0001cO-Q5 for submit@debbugs.gnu.org; Tue, 29 Jul 2025 20:36:23 -0400 Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]:61870) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ugunr-0001c2-66 for 78995@debbugs.gnu.org; Tue, 29 Jul 2025 20:36:20 -0400 Received: by mail-yb1-xb30.google.com with SMTP id 3f1490d57ef6-e8e1ef181bcso2106172276.3 for <78995@debbugs.gnu.org>; Tue, 29 Jul 2025 17:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753835773; x=1754440573; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=TeNL85vyK6nRf1cLyItMb8/Lk+i5+EFL72PLnOLKKZk=; b=JpCjsDc2wOJvjbRXAhSPk1qt0OzrtkXVM1lBD274OyyUMbCEePclEaNfhUwCz6LXbR jfmd0r38EmU/FJVLRM8UWzH9hy8B2byEHcU/Tlwo0PA9j9r5TCUfyLTuOypmb1svbxf+ w3xgqojrt8h3jh+UwDaKJ4M6Ais5u+vBuPE4wt4FxfDTbfoB/EtFtrdQEIGuMHAn3spc HMn8b0sgXZTuD4olnD6Zrfq+fZNrqAFjNrkC/E7xhgVsFfOFUzW+Yt/TgvVahOCn0Rnl PaVg4kpMDjuMXVMYTFZQFD8G2p30932xrde0K64K4Y3uIsqJgW5VVBqKl9JSuIidfrA5 so/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753835773; x=1754440573; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TeNL85vyK6nRf1cLyItMb8/Lk+i5+EFL72PLnOLKKZk=; b=DdmEFAJ9EpqqxnCli24gaBqNGvoVynu8Nn4CAYCKU+Q2pZwqM6DWyZC4FHgWi4YYvL RP/71q9KWZkfBr9dWuYR5CZxb0CxYYeZ+txOgwDVTpSxHbM+reg6vYEVR3GuuYXHjWa8 M6xA1Dm3QBBjg3Me15DTWnvwIiKThtwEZCdNFYL0VUQQfewNIj8r9HRCRQrYua/pLqDi k4FJZND3TOco3OwdMP+kGm/iLr2hfNhGVnoJTgJqsnOrcKYcLL9ShsHDsn1eQF6qAQ9q d5D1S/UVDTVS76p0hRWBbnWZlBNgxK+SEnkz+Y2pWXZyebmTFI1SivfC+9H6ZaDGFDj4 JNhA== X-Gm-Message-State: AOJu0YwDsrHzFfk+ATukghgz0+jO48GcXxDaR6ZqjaHOLz53gWIKhtQP sV/YpUxdwZ65mUydKckibxqIw4/9jySSYjZMmfx1JJJ/9ns1eQm5stjQ X-Gm-Gg: ASbGncsIQwwqPR9Erm4r3EDQ+fkwPtoMgg6aweQLB6VsbvBInJsCEO+no5tNjEieSxN brvw5SFPM24y3g+cDnzNoH7E/ZO5MvejkKC2nthl93Fy2iSsUbgXbQwsduTdUfiZwRDoEOdZWel H0wOzO7SeU9XxP7ywodMxHYq1bau0Z8JN9Rk7rPScMhUBiWj3A8DKtOxF04H0v9JSBfAkg2J8yW 5r7YCcNCnf6f0u733SO85fJkcgOjPB1v67lwNHPWqvGqrtRgzO5vxnEwLw2Qhj78kXCBqrr7Iqu 5zcGYXXOmm0d0ATEjjSk540ck2PeQmw3fCeDVdOvw1BkA/Jlj8QAW08A/2qjlyMFU4Wi1ZKc0KW gX0W+w1Laocf8iIJu7zr+CzznLJAoCEqvo3IhyJww2QWFnyZMaMcUEWcA X-Google-Smtp-Source: AGHT+IH4fMOgU5Fw7jaYWWvaXsh8Fwv0HkyWSI86spr9n7jKR6zQd1rGtV+n8/dTURi0o214TH6c3Q== X-Received: by 2002:a05:6902:1b0d:b0:e8d:dc99:30a0 with SMTP id 3f1490d57ef6-e8e3156676fmr1872453276.24.1753835773383; Tue, 29 Jul 2025 17:36:13 -0700 (PDT) Received: from moss-4 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e8df86c5899sm3150243276.26.2025.07.29.17.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jul 2025 17:36:12 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Tue, 29 Jul 2025 17:18:33 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87pldm85uv.fsf@gmx.de> Date: Tue, 29 Jul 2025 20:36:11 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Michael Albinus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >>> Damn! So now I'm the one who needs to figure out how to keep it working >>> in Emacs<31 while trying to make it behave with the new >>> "autoload-expand". >> Maybe it is as simple as requiring a (new?) file that defines the macro >> directly, and whenever you require tramp-loaddefs, using NOERROR=t? > > I *think* it's simpler than that: just add the `declare` thingy and the > NOERROR=t. Ahah, I see that tramp-compat is required, so this should work. It's `(autoload-macro expand)' btw. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 29 21:41:25 2025 Received: (at 78995) by debbugs.gnu.org; 30 Jul 2025 01:41:25 +0000 Received: from localhost ([127.0.0.1]:37571 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugvop-0006lY-QB for submit@debbugs.gnu.org; Tue, 29 Jul 2025 21:41:25 -0400 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]:57390) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ugvom-0006l3-0t for 78995@debbugs.gnu.org; Tue, 29 Jul 2025 21:41:22 -0400 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-710e344bbf9so60954697b3.2 for <78995@debbugs.gnu.org>; Tue, 29 Jul 2025 18:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753839674; x=1754444474; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=3kWwQtrCWfEf5BgGX+JL79pF2GUbneGuu6/Ufu/QR58=; b=lBsCQpv22M1EjZoc5LpIgIwmrDwSP2F06rSZboGJmHvhDOm7+NTw9Wk5pfLvm19y5A 0bQUuYNCWlMOsfqP/gl5Nszs8i13BT0AmfDCx9wQPZFPJyyHLC9ZEF32YZ+xMPiUD/zW 1aEE5ap449ZR3wwxZl93mwoJ02tAAgVE/wKlzSqV+6i2ozxi1YyQhrqzSI0wFAb0dbnU dYyhVowllEL5ZGdGEnNSfXTe4X98xUz+9Z7subLRuX1bpT/76ZIO9ZzD1n5wPeNQq6p4 dyDTNAhcH9c+u/F8llBWn4gEQm1wYttyQA4jMYaMm5ui8CAAQ9pOIkAXtpe1tjUpyJgi flhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753839674; x=1754444474; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3kWwQtrCWfEf5BgGX+JL79pF2GUbneGuu6/Ufu/QR58=; b=nrRCpU9nREqi0WpD3THzZp5Usl8o75XusIP/C6g/ihm9gv3Y3OSEb7XdW9QuuHFwI6 8Gd6JNophqz+phgMGulkA4T9yBrNss9p3IqorFmqRn/93t/8LA5cUjfX8jc9OHce7tWi 6OcCIN+6bX88J7MW+xM0wfSo6stpFA8bmpz7kKY1WrzaBMG4gammWNFsyMWgyfUubkeW LkaHBrv+Yfvp3FnHnSwqa/69KOHhmq0M2lDzBgVZT7woQZS1WHhhe/Qvjbi2d69nBfoH oStqRpzp1+UZfF0OUbaphJJowXn5VjeLctqNS13vUcB46leEi77KDHsLwIK3yyqXjDH8 ma9Q== X-Gm-Message-State: AOJu0Yw763JWlw5d1wsTzp/fJ+OQp+NMoeyiQe/wA7xndUYUo8EzdS9T YSXKwgeJIZhcei62Udt+13DuAhatJqxmiN4HpjkdkUyIybgnSqEm4QIc X-Gm-Gg: ASbGncvGV1Coh/H8YT60DfVHmONcrfydxVRdwNUZ7HgbszPrtgorHjdOptGeLbtCAwi QAxyRF+1l02ge7GIWnzzNBBb+x2qFhm1CED07vIQpkN+o2RVBS51G7YV4vZT4QjSbLAD4InRGHC UGNi4pDBtBf9UnMyH6TsDhzxUYfOKBeXohjoxquptJXkC14tTqbi8fJrqbf/3EfmVoAKr4jcnIk zqXUXXgvi+HwDf25ZLIBKdXIDqyCuQFiR8Q5GkR5U7he7zYzGBQ57umu3s7EUfOr7B8lyYaYUHO VYA/4KwA9l0FyD36sR6vtk+oy59momEowuRMJ9k2YpOXmVrjX22Wzq+gqk/TVL+tJt4mhNRRIJ7 R3Nzvsy/a83w8AR5soQE+0/GIyFMvjXoDnx8Fr2hlxK5D+cdYkz/IDHYV/tAEjjKQzKk= X-Google-Smtp-Source: AGHT+IEWC7LpRENh76jWFz1LHRKE+js077DDXjN88hBgdHxIIo1DWLPF2x2+fcWCP6bUw9QIdjKYGA== X-Received: by 2002:a05:690c:7401:b0:719:ff33:9265 with SMTP id 00721157ae682-71a468f7a84mr23933947b3.19.1753839673911; Tue, 29 Jul 2025 18:41:13 -0700 (PDT) Received: from moss-4 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 00721157ae682-719f23b23e6sm21483497b3.65.2025.07.29.18.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jul 2025 18:41:12 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Tue, 29 Jul 2025 17:29:49 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Tue, 29 Jul 2025 21:41:12 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Michael Albinus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Stefan Monnier writes: >> One big category of nil car's resulted from all the :autoload-end's around. > > Oh, what you mean is that nil is when the element is not a cons cell? > Indeed that makes sense. > [ Cons cells with a nil element would be surprising, OTOH. ] Yep, like :autoload-end :). >> That leaves a number with explicit nil cars in their expansion, for >> whatever reason: > > I think these have `nil` in the list of forms (that follows a `progn`), > but not in the `car` of one of the forms, right? So again, it's when > `form` is not a cons-cell. > In any case, indeed those non-cons situations justify the "not nil" check. Yes, but I just wonder what such non-conses are doing in the expansion. Maybe just doc strings or some such. >> No, it's a good chance to learn. Will want to iterate on docs first, if >> you think its ready (I think it is). > > I was thinking to do it in the single-hunk bug fix, which I do think is > ready (it just needs a commit message). Is the commit message in need of expansion? I worked up some quick docs and included in the patch; see attached. >> Have you had a chance to test it "in the wild" with a custom macro? > > No, not yet. But I think the transient macros are a good test case. Good idea. Michael, if you can try this along with a patch like the one Stefan proposed for tramp (correcting the declare form name) that would be useful. Assuming it all works as expected, you'll notice `tramp-loaddefs.el' no longer contains the macro and the calls to it, but rather only the expanded forms it generates. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=autoload-expand_6.patch Content-Description: autoload-expand patch with documentation diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index be3c1e78889..25a01d942b6 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2633,6 +2633,11 @@ Declare Form This is typically used for macros, though it works for functions too. @xref{Indenting Macros}. +@item (autoload-macro @var{value}) +This is used when defining a macro. If @var{value} is @samp{expand}, +any calls to the macro which follow an autoload comment will first be +expanded during generation of the autoloads. @xref{Autoload}. + @item (interactive-only @var{value}) Set the function's @code{interactive-only} property to @var{value}. @xref{The interactive-only property}. diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 750f6e76eff..65a55547a9f 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi @@ -710,8 +710,31 @@ Autoload If you write a function definition with an unusual macro that is not one of the known and recognized function definition methods, use of an ordinary magic autoload comment would copy the whole definition into -@code{loaddefs.el}. That is not desirable. You can put the desired -@code{autoload} call into @code{loaddefs.el} instead by writing this: +@code{loaddefs.el}. That is often not desirable. In this case, you can +use the special declare form @code{(autoload-macro expand)} in your +macro definition (@pxref{Declare Form}). This indicates to the autoload +system that calls to your macro following @samp{;;;###autoload} should +be expanded, similar to how the special functions listed above are +handled. For example, a macro which wraps @code{define-minor-mode} can +request expansion, so that proper @code{autoload} calls for the function +it defines are generated. + +The symbol @code{:autoload-end} can be used in the expansion to prevent +including unwanted forms in the autoload output. Its presence causes +any further elements within the list where it appears to be silently +skipped. + +Note that, if a symbol in the car of an autoloaded form is not defined +during autoload generation, the file in which the associated +@samp{;;;###autoload} appears will itself be loaded, to give the macro a +chance to be defined. Packages which use special loading mechanisms, +including requiring their own @samp{foo-autoload.el} file, should +therefore gracefully handle load errors, since these files may not yet +exist during autoload generation. This can be done, e.g., by setting +the @var{no-error} argument of @code{require} non-@code{nil}). + +Alternatively, instead of expansion, you can put the desired +@code{autoload} call into @code{loaddefs.el} by writing this: @example ;;;###autoload (autoload 'foo "myfile") diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 366423904db..3e521e18567 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -271,6 +271,11 @@ 'byte-run--set-debug (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload-macro + #'(lambda (name _args spec) + (list 'function-put (list 'quote name) + ''autoload-macro (list 'quote spec)))) + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -350,8 +355,10 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + (list 'autoload-macro #'byte-run--set-autoload-macro) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -397,6 +404,7 @@ 'defmacro (if declarations (cons 'prog1 (cons def (car declarations))) def)))))) +(function-put 'defmacro 'autoload-macro 'expand) ; Since we cannot `declare' it ;; Now that we defined defmacro we can use it! (defmacro defun (name arglist &rest body) @@ -409,7 +417,7 @@ defun The return value is undefined. \(fn NAME ARGLIST [DOCSTRING] [DECL] [INTERACTIVE] BODY...)" - (declare (doc-string 3) (indent 2)) + (declare (doc-string 3) (indent 2) (autoload-macro expand)) (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 3aa26fba3c3..4a85d89d5fa 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -258,7 +258,8 @@ cl-defgeneric cl--generic-edebug-make-name in:method] lambda-doc def-body)]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((doc (if (stringp (car-safe options-and-methods)) (pop options-and-methods))) (declarations nil) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2a0a9e5c6de..1b64f106a1b 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -398,7 +398,8 @@ cl-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defun ,name ,@(cl--transform-lambda (cons args body) name))) ;;;###autoload @@ -416,7 +417,8 @@ cl-iter-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) (require 'generator) `(iter-defun ,name ,@(cl--transform-lambda (cons args body) name))) @@ -475,7 +477,8 @@ cl-defmacro (declare (debug (&define name cl-macro-list cl-declarations-or-string def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defmacro ,name ,@(cl--transform-lambda (cons args body) name))) (def-edebug-elem-spec 'cl-lambda-expr @@ -3011,7 +3014,8 @@ cl-defstruct sexp])] [&optional stringp] ;; All the above is for the following def-form. - &rest &or symbolp (symbolp &optional def-form &rest sexp)))) + &rest &or symbolp (symbolp &optional def-form &rest sexp))) + (autoload-macro expand)) (let* ((name (if (consp struct) (car struct) struct)) (warning nil) (opts (cdr-safe struct)) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index f53db48f0b7..0e428abd0b7 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -222,10 +222,11 @@ define-minor-mode (indent defun) (debug (&define name string-or-null-p [&optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp] + &optional [¬ keywordp] sexp + &optional [¬ keywordp] sexp] [&rest [keywordp sexp]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((last-message (make-symbol "last-message")) (mode-name (symbol-name mode)) @@ -487,7 +488,7 @@ define-globalized-minor-mode on if the hook has explicitly disabled it. \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" - (declare (doc-string 2) (indent defun)) + (declare (doc-string 2) (indent defun) (autoload-macro expand)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 344e11e245e..59784ff51e8 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -675,7 +675,8 @@ iter-defun of values. Callers can retrieve each value using `iter-next'." (declare (indent defun) (debug (&define name lambda-list lambda-doc &rest sexp)) - (doc-string 3)) + (doc-string 3) + (autoload-macro expand)) (cl-assert lexical-binding) (let* ((parsed-body (macroexp-parse-body body)) (declarations (car parsed-body)) diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index c015e2b57d0..5acd6f17ee2 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -135,7 +135,7 @@ define-inline This is like `defmacro', but has several advantages. See Info node `(elisp)Defining Functions' for more details." ;; FIXME: How can this work with CL arglists? - (declare (indent defun) (debug defun) (doc-string 3)) + (declare (indent defun) (debug defun) (doc-string 3) (autoload-macro expand)) (let ((doc (if (stringp (car-safe body)) (list (pop body)))) (declares (if (eq (car-safe (car-safe body)) 'declare) (pop body))) (cm-name (intern (format "%s--inliner" name))) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..f9c6f82c31f 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -142,12 +142,29 @@ loaddefs-generate--shorten-autoload 3) form)) +;; TODO: some macros can be removed from this list once they +;; (declare ((autoload-macro expand) ...) +(defconst loaddefs--defining-macros + '(define-skeleton define-derived-mode + define-compilation-mode define-generic-mode + easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode + easy-mmode-define-minor-mode define-minor-mode + cl-defun defun* cl-defmacro defmacro* + define-overloadable-function + transient-define-prefix transient-define-suffix + transient-define-infix transient-define-argument)) + +(defvar loaddefs--load-error-files nil) (defun loaddefs-generate--make-autoload (form file &optional expansion) "Turn FORM into an autoload or defvar for source file FILE. Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. + +Note that macros can request expansion by including `(autoload-macro +expand)' among their `declare' forms." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -191,35 +208,40 @@ loaddefs-generate--make-autoload (setq form (copy-sequence form)) (setcdr (memq :autoload-end form) nil)) (let ((exps (delq nil (mapcar (lambda (form) - (loaddefs-generate--make-autoload - form file expansion)) + (unless (eq form :autoload-end) + (loaddefs-generate--make-autoload + form file expansion))) (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) - (macrop car) - (setq expand (let ((load-true-file-name file) - (load-file-name file)) - (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) + ;; For macros which request it, try again on their expansion. + ((progn + ;; If the car is an unknown symbol, we load the file first to + ;; give packages a chance to define their macros. + (unless (or (not (symbolp car)) (fboundp car) + ;; Special cases handled below + (memq car loaddefs--defining-macros) + (memq car '(defclass defcustom deftheme defgroup nil)) + (assoc file load-history) + (member file loaddefs--load-error-files)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s (for %s)" file car) + (condition-case e (load file) + (error + (push file loaddefs--load-error-files) ; do not attempt again + (warn "loaddefs-gen: load error\n\t%s" e))))) + (and (macrop car) + (eq 'expand (function-get car 'autoload-macro)) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) + (not (eq car (car expand))))) ;; Recurse on the expansion. (loaddefs-generate--make-autoload expand file 'expansion)) - ;; For special function-like operators, use the `autoload' function. - ((memq car '(define-skeleton define-derived-mode - define-compilation-mode define-generic-mode - easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode - easy-mmode-define-minor-mode define-minor-mode - cl-defun defun* cl-defmacro defmacro* - define-overloadable-function - transient-define-prefix transient-define-suffix - transient-define-infix transient-define-argument)) + ;; For known special macros which define functions, use `autoload' + ;; directly. + ((memq car loaddefs--defining-macros) (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) (name (nth 1 form)) (args (pcase car diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 73554fd66fd..ab8edf1f569 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -537,7 +537,7 @@ pcase-defmacro By convention, DOC should use \"EXPVAL\" to stand for the result of evaluating EXP (first arg to `pcase'). \n(fn NAME ARGS [DOC] &rest BODY...)" - (declare (indent 2) (debug defun) (doc-string 3)) + (declare (indent 2) (debug defun) (doc-string 3) (autoload-macro expand)) ;; Add the function via `fsym', so that an autoload cookie placed ;; on a pcase-defmacro will cause the macro to be loaded on demand. (let ((fsym (intern (format "%s--pcase-macroexpander" name))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 04:00:12 2025 Received: (at 78995) by debbugs.gnu.org; 30 Jul 2025 08:00:12 +0000 Received: from localhost ([127.0.0.1]:39028 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh1jP-00025y-L6 for submit@debbugs.gnu.org; Wed, 30 Jul 2025 04:00:12 -0400 Received: from mout.gmx.net ([212.227.15.19]:47279) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uh1jM-00023y-IW for 78995@debbugs.gnu.org; Wed, 30 Jul 2025 04:00:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1753862402; x=1754467202; i=michael.albinus@gmx.de; bh=zMmsjgERUytdpmhPaABNDDs7Yc843St8xkSmwvehGxc=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=ExKa01jt7BQ8TXBhazebH2CKHjqTfjSWlcJHVzOKOz45EJZGsK0MmXs0CWIx2VcP dYCbr058Mi9ZtOSG8NY+kSJ8w4+Bz1ylEy4imob2mddvLeL0NsdgRKIFhS6wztF7q rCismGQr03f9sry3Ofz2ieF+oOeo/sPHlI3H/WyMQ7krSiXpQuHr4/h4lfNxcnzbj gbbGW/0/qVWdo12mt3s9IO2ueE7NO77Mr012PHVYbrN4/OKiUH9G7U3frLzs3j9hw gfiWrp8g99n4YBDhJSB2mNI8WPLXZ4iELLjkYRNetPjTh/ldrSwxEb0ibuzfYWbSw sTKiSwqdZVbni7i4IA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.61]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mo6qv-1uIzf82hbf-00a99v; Wed, 30 Jul 2025 10:00:01 +0200 From: Michael Albinus To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Wed, 30 Jul 2025 10:00:00 +0200 Message-ID: <87ecty5csf.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:Zpk8ag3phwOY4emneBw6IBqpBn5RyJk9knuq0STS45WGo71gEJ1 3zHCT9ReWTg2HVk4Dd1pU65CmEhi8gv3v3+ICxP1Ce78qec0D39HHIVke0ZXP045J/V4kU1 L5uWmIQoxnitS7dVf7Rzkf3YCST07+vslwx51aTbv6/rX891EONWtCPGoLPMAJU8JH8kkdZ ZIQeipq13VYcS+2+mvKnQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:TgA/vyfHxWc=;5xW5ZDMtYzuDmB4ZEDT7UK8cIb9 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 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) "J.D. Smith" writes: Hi, > Good idea. Michael, if you can try this along with a patch like the one > Stefan proposed for tramp (correcting the declare form name) that would > be useful. Assuming it all works as expected, you'll notice > `tramp-loaddefs.el' no longer contains the macro and the calls to it, > but rather only the expanded forms it generates. Before doing so, I've tried Stefan's patch with Emacs 28. There are compilation warnings. =2D-8<---------------cut here---------------start------------->8--- # gmake -C lisp distclean ; gmake -C lisp EMACS=3D/usr/local/src/emacs-28/= src/emacs gmake: Entering directory '/home/albinus/src/tramp/lisp' rm -f .\#* \#* .*~ *~ *.aux *.cp *.cps *.diff *.dvi *.elc *.fn *.fns *.htm= l *.info *.ky *.kys *.log *.pdf *.pg *.tmp *.toc *.tp *.vr *.vrs rm -f tramp-loaddefs.el gmake: Leaving directory '/home/albinus/src/tramp/lisp' gmake: Entering directory '/home/albinus/src/tramp/lisp' /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l autoload \ --eval "(setq generate-autoload-cookie \";;;###tramp-autoload\")" \ --eval "(setq generated-autoload-file \ (expand-file-name \"tramp-loaddefs.el\"))" \ --eval "(setq make-backup-files nil)" \ -f batch-update-autoloads . SCRAPE . INFO Scraping files for tramp-loaddefs.el...=20 INFO Scraping files for tramp-loaddefs.el...done /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-loaddefs.el /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile trampver.el /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-compat.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup In toplevel form: tramp.el:109:50: Warning: Unknown macro property autoload-macro in tramp--with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-adb.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-androidsu.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-cache.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-cmds.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-container.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-crypt.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-ftp.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-fuse.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-integration.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-message.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-rclone.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-sh.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-smb.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-sshfs.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-sudoedit.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-uu.el /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-archive.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup /usr/local/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/lis= p -l bytecomp -f batch-byte-compile tramp-gvfs.el tramp-loaddefs.el: Warning: Unknown macro property autoload-macro in tramp= =2D-with-startup gmake: Leaving directory '/home/albinus/src/tramp/lisp' =2D-8<---------------cut here---------------end--------------->8--- And also at runtime. =2D-8<---------------cut here---------------start------------->8--- # /usr/local/src/emacs-28/src/emacs -Q -L /home/albinus/src/tramp/lisp /ss= h:: For information about GNU Emacs and the GNU system, type C-h C-a. ../home/albinus/src/tramp/lisp/tramp-loaddefs.el: Warning: Unknown macro p= roperty autoload-macro in tramp--with-startup Waiting for git... [2 times] Tramp: Opening connection for gandalf using ssh...done Tramp: Setup connection for gandalf using ssh...done =2D-8<---------------cut here---------------end--------------->8--- Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 08:34:25 2025 Received: (at 78995) by debbugs.gnu.org; 30 Jul 2025 12:34:25 +0000 Received: from localhost ([127.0.0.1]:40224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh60n-00060u-Bg for submit@debbugs.gnu.org; Wed, 30 Jul 2025 08:34:25 -0400 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]:49581) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uh60j-00060V-Sj for 78995@debbugs.gnu.org; Wed, 30 Jul 2025 08:34:22 -0400 Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-88105a23088so170465739f.3 for <78995@debbugs.gnu.org>; Wed, 30 Jul 2025 05:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753878855; x=1754483655; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=qE7Ix5BTJmCAM8qO2HpDP5SNBolZXStQMda0pktXamY=; b=gE6jtgcWrt3W9NAc/1wcFLKeLScC7/v7gs5awx9YykdnkZXvu7QlhfNQizpmcNQV8x GedS9AcvqwQmY6+CLhQ3k8uhlpbfvZLZs42FDf4LTs3VGAFR5k6L4hLGhc5iC+93aI2K qLFnjeOg/btNA4lYmbi0e6p+PCosUrs+42k+LqUcM2IFrYsipu/lyIbO9mD1YlOspL+h yUnuCICdBmpbu4m97NCU3CktWsR/wMxEYnV7glrh/F9DKicC+NqsLEbhskdVqpT5Es/9 PgnXo4F+2VT0tDFWIv1U1oznTGJ5qfv7MgN0fo+RZQpdZXiZmM6DYdRGVx+22Xcb1Rtf 7d4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753878855; x=1754483655; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qE7Ix5BTJmCAM8qO2HpDP5SNBolZXStQMda0pktXamY=; b=rHvl6XTAKqC/9u4BBVbpbSRDweFZEJO3Q/jHDAY3gOfQc9E9zknPeyVulUWVOBH72X D1DHTGU2EwPOX5qjxIyXYkxuQ8WSGu2u0EX1gq5YU+vC6simxFpWzy+V7O/jVq5iGuxt hbO8tHbpOdRnX2kfRmeg7ijX4OPv9Z0SQKQuEqh2qPV7hQ0wEWWgHuqaTuHZMw0VObCr 2U1PJK0BzMh0FnLvdRpAtKZ3gqmmEgUbGBtcs5NPKUj3PV15XNWH8fRcBNL1yL/Oc4+N 85zIyjZNc5zRtsdKnL+wl1kPcYmBbiFqViF0NNrcBjd8BxL59uPK50QfPQNwUPRoxxXm HnVw== X-Gm-Message-State: AOJu0YzHo1Eh9P/1sCFOMrAidXrRpNWXhhml+hN70Jru2iYpce5H+NHy 2TVFD/MnkMur9Ysyssq1Sm5V8Saa41YPGtDMCuyVj1Kk4YTQmNZoimQi X-Gm-Gg: ASbGncvIxsw8uT6Ns7wAVqiV7cP1KA0pKSrl9ZLy4DgosAXLMuW5fCebc1OQwPDZTjO SUd2rDFGi3k8TDp0UT3OR8pMzWTjBzJs2q7B/ExAYAlOgoaOloS7P910GDexhrjHQo4Z+S65F5b MHjO8HZ3dHFxliNiAHLVKhFkuXfEtRm+TQRJ5UuaR4hGuMGUq7xhVR9PWWTsSSExBad3XLEl0Eq l2wmWVmMLavRsFpuJlYbkmnJIK2j2Wstkh6OrCgNW23bLlMWAbMjl01qB4CPwTbo4smfiUQ+jcU mu/oOZuwoJOCiU0P8QAQ7w+Tzf0VeW2y12Gql2awq1pG80xEW4lHzpPKFW8Br6xD2ldg8/fCO8v EO2M/haP6nVfqqZ2WK6hNNFnl5ej4LS5CSrLwrPjJe7khrzLgVrYgBpjM X-Google-Smtp-Source: AGHT+IGbeejKgzSJC97LyL7eTyUUFbEVi7uhhBLGFNgFT77OANNWJIii2v2YWE/O6D1tXNY8f5t6Jw== X-Received: by 2002:a05:6602:6d14:b0:87c:bf5:c242 with SMTP id ca18e2360f4ac-88137486629mr555694039f.3.1753878855338; Wed, 30 Jul 2025 05:34:15 -0700 (PDT) Received: from moss-4 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-880f7a29956sm264399139f.25.2025.07.30.05.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 05:34:14 -0700 (PDT) From: "J.D. Smith" To: Michael Albinus Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <87ecty5csf.fsf@gmx.de> (Michael Albinus's message of "Wed, 30 Jul 2025 10:00:00 +0200") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> Date: Wed, 30 Jul 2025 08:34:13 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael Albinus writes: > "J.D. Smith" writes: > > Hi, > >> Good idea. Michael, if you can try this along with a patch like the one >> Stefan proposed for tramp (correcting the declare form name) that would >> be useful. Assuming it all works as expected, you'll notice >> `tramp-loaddefs.el' no longer contains the macro and the calls to it, >> but rather only the expanded forms it generates. > > Before doing so, I've tried Stefan's patch with Emacs 28. There are > compilation warnings. > ... > And also at runtime. That would seem to make it difficult to add new declare forms and simultaneously support older versions of Emacs. How have such issues been dealt with in the past? Do you have a version or branch of TRAMP that is only deployed on master? From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 11:39:08 2025 Received: (at 78995) by debbugs.gnu.org; 30 Jul 2025 15:39:08 +0000 Received: from localhost ([127.0.0.1]:42057 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh8tY-0001Ml-A7 for submit@debbugs.gnu.org; Wed, 30 Jul 2025 11:39:08 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:41298) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uh8tV-0001MD-E9 for 78995@debbugs.gnu.org; Wed, 30 Jul 2025 11:39:06 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 6C9798166A; Wed, 30 Jul 2025 11:38:59 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1753889938; bh=MtsCcrKO9Yejk7ZW1z4H8c3yqLiwdfnJdgEsROkbeEo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=JxvaR0IrWhcSE+f9RbgOtYmve26SjM4a0jnBZauTwjw3zpDnbFpnYvVgzyXghcft0 IchVd9l2Y20w2rapOUlI8UceC2qzaAgRdwF5uv4Pj8h+3swypuh6/3YrvQdhcpWmnS LXc2foFX69w75XcVYUkOmRjv1xdI+msDKdoisQEGX8ELj6YfpJXZ9dCWy4yhGjUVj7 5GdqEmBeKDNzQXFveyQVc/Zoq/xaLiXREaXJYQpeslPB/18O6rl/K1Go8hhOjXew+P 6m01YorJCKgklNIfeu8Bc4N+YdCU+5ElcQI9/CsC1qJNVJ+znolTxwCbQn4wYiWNx2 YwMkUb7x64cag== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 8A27A809D3; Wed, 30 Jul 2025 11:38:58 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 7B2FD120B56; Wed, 30 Jul 2025 11:38:58 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> Date: Wed, 30 Jul 2025 11:38:55 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.152 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Michael Albinus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >>> Good idea. Michael, if you can try this along with a patch like the one >>> Stefan proposed for tramp (correcting the declare form name) that would >>> be useful. Assuming it all works as expected, you'll notice >>> `tramp-loaddefs.el' no longer contains the macro and the calls to it, >>> but rather only the expanded forms it generates. >> >> Before doing so, I've tried Stefan's patch with Emacs 28. There are >> compilation warnings. >> ... >> And also at runtime. > > That would seem to make it difficult to add new declare forms and > simultaneously support older versions of Emacs. How have such issues > been dealt with in the past? Do you have a version or branch of TRAMP > that is only deployed on master? I think it's not that bad: just adding the ERROR=t is sufficient. The `autoload-macro` declaration can be kept for later, once Tramp drops support for Emacs<31. I suspect the same will apply for Transient: we'll want to make sure the new functionality works well for it, but we'll have to keep the old ad-hoc solution until it drops support for Emacs<31. Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 11:44:29 2025 Received: (at 78995) by debbugs.gnu.org; 30 Jul 2025 15:44:29 +0000 Received: from localhost ([127.0.0.1]:42076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh8yj-0001gJ-DU for submit@debbugs.gnu.org; Wed, 30 Jul 2025 11:44:29 -0400 Received: from mout.gmx.net ([212.227.17.20]:59833) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uh8yg-0001fw-J2 for 78995@debbugs.gnu.org; Wed, 30 Jul 2025 11:44:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1753890257; x=1754495057; i=michael.albinus@gmx.de; bh=h0wCU0q//CpKr+T1C0UJyJ7ElquA2ugoEmBaSeZdbjE=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=BkDOd2z1wwr4/TnpBB9+oiswjIcMDbpFPojFHvw5a+XJX9IRQVTB/AgL3mLWrhXK tBmi1NuHpbCExrfDL3rVldjJ4lQWiEmFe6Gk8uAAjBokSeWAOP4tNnDHU8NpWS/b9 tH+psi7X0LKHmteTqrehFQtHZ5XfV8WMq+A59smOMpU3CHnZM/XQMLFXy8zuoTRLI MbVtJBXR/VJZXNKEMf65bsxrU3xZXd3v1rUkkI0SP8lOkwurED5PDuE1vgsGteoZp 6ZQ439pbglxYUUpdy66o8VEixUOIliZ8SLfB8w0im+BQkEZL8jbqZaCgR9gdJnXTB pgUU2Kc06Cbl/UaRzw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.61]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M6DWi-1ujJlY44PQ-002eiU; Wed, 30 Jul 2025 17:44:17 +0200 From: Michael Albinus To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> Date: Wed, 30 Jul 2025 17:44:15 +0200 Message-ID: <87fredsmy8.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:R4lgnMv7SASX2jAV9iPQ4XVp1GWjmUPDmGzbM74cUo1wnwDoKL6 yoUCWK8+3xXGgbAdE0d/9OhzMFOe6w63RhCQwLxON3b2r+WJgJxGVBKZeYYEHyNdsQxkgaU l8lFTsahH/RmZimFELxVXPZ3fAFoxaWdgqLWHtvbAEzOiml/ud9bDrQW40YYp8eSOrzVlBR rEcTaBWKnhibf8sUbtMYw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:oFaCFBeOawc=;ohKDxUgf+tpJANiPGxUNa5wb5Jd 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 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) "J.D. Smith" writes: Hi, >> Before doing so, I've tried Stefan's patch with Emacs 28. There are >> compilation warnings. >> ... >> And also at runtime. > > That would seem to make it difficult to add new declare forms and > simultaneously support older versions of Emacs. How have such issues > been dealt with in the past? Do you have a version or branch of TRAMP > that is only deployed on master? No, there's only one Tramp branch, which is deployed on master and on GNU ELPA. Tramp uses an own declare form `tramp-suppress-trace'. In order to make it happen, there's the code --8<---------------cut here---------------start------------->8--- (eval-and-compile (defalias 'tramp-byte-run--set-suppress-trace #'(lambda (f _args val) (list 'function-put (list 'quote f) ''tramp-suppress-trace val))) (add-to-list 'defun-declarations-alist (list 'tramp-suppress-trace #'tramp-byte-run--set-suppress-trace)))) --8<---------------cut here---------------end--------------->8--- Perhaps this trick could be used? Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 11:54:38 2025 Received: (at 78995) by debbugs.gnu.org; 30 Jul 2025 15:54:38 +0000 Received: from localhost ([127.0.0.1]:42110 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh98X-0002It-Ea for submit@debbugs.gnu.org; Wed, 30 Jul 2025 11:54:38 -0400 Received: from mail-yw1-x112f.google.com ([2607:f8b0:4864:20::112f]:48284) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uh98L-0002I2-LE for 78995@debbugs.gnu.org; Wed, 30 Jul 2025 11:54:32 -0400 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-71b4b36cf83so5687677b3.0 for <78995@debbugs.gnu.org>; Wed, 30 Jul 2025 08:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753890859; x=1754495659; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=45V8uC8yfsJIW1act+NUHBd5cPFlQRtNmSSkuqH2sLk=; b=gKrhu9cO1udcaXvQTx3oNL9h/Oo6ZUZejkFYBhS1NLNJ5oh60faMaEdTw1W3T6zcVo iOKJ9BEMX7woU46MlFJOtJmtbjlwcotIIiJvD+e8c1BmkPpBFS8MAXM9gNX9hHIX8ec+ 9/LOrzktq188JviMGzORRGWuYt9YFeIBcw3nYqHHcL7ArrOhZ/V4nXvhSWqppgop/mbo uJqFgBl0cr2hLVRHHVyLJm3kq43fkH215XDxI0ajNxglXeRHXp4hNeo4GJTR2R/df+O0 IRrfhyyrYAyTTfSzUHeFAMni+7lmAdg50tiDWGToykl0whzTv58nO8TGNiP9LlNnjVG9 3uOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753890859; x=1754495659; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=45V8uC8yfsJIW1act+NUHBd5cPFlQRtNmSSkuqH2sLk=; b=KC8iSuPGFvYQdeiWLEPTJxbQdjfLRafoR89qrgEcnDmOrArk85fCcceXNcVsW7oTOp gFIaD6z8sQkk4SduX0nkFHFxjK9yrUm+c4GGYAiH4lT3Ffk7//5Q65Gscm+uf/0C1XYV wLefNf7FCqMeWCdzivxGYuwILRfIPpVjxRfGnmmatrjnWjlB2T0KkPPABe2x64OkqTZZ YvUFWEJpv5XIUnOsS6MTxK6JJ2QYONDWqHlvGfeoxmg0469/FmRCg0aU2FOMvxA+d/uj Oo69n2GKvbC5RwpZkMEClVZqUheDNz5En8pk/M4tkGb92xepPQQ3I3cR/J5CidzdDOPY 1sMw== X-Gm-Message-State: AOJu0Yw/D1PTL/SlmhYaoqRq0bMiGfjjg57Ye5YeuyIYvGQhmoOmRtV7 EraY7EemEGz1S2ymj2BsSHPprROR3QdhyRf8ShJiKv7fZ4cJZNdHAw72 X-Gm-Gg: ASbGncvKUJwAbdDiSK1y/hakEPgODvI6aHnFaT5GLs4exGgV51imrBV5R2/wQR6ISIO 3Rb3+wvlD3zF+BQpEf19etlpPvsvyswGpJ0Cd+pEHJxWwcX2rExdluS433VijCfDu5xQCQIv+gy PTmh5N6k9YrSJ1je18Oy8Y5UlzrmOPt8du3R3XEQODKImwTtU2POKIJk6rkt3sZAVnThCMML+tN cNhNq6PGCAMBgDv4Tx8+6YxHFIVkNz3+5O0dZGWV/9WHSAtsOH3gVgnHkZfL20vfWEao21Dcb+N jzDg0octjX5Oiru/Mmfg0NGdnyDhrqqypaGvjwAA6IHKSSdZa7GqoMc6pjtsKEaoNOZ4fQCRK8u 9t4GD1sBlfI0rwMat+9KdyBdcj4RNcA== X-Google-Smtp-Source: AGHT+IEXKLm35heymDM/IYypwUTRmB1nOIRyNFh28jGGppDIA8pGGG5yY11T//ihKaTgOyYAeVvvEw== X-Received: by 2002:a05:690c:d96:b0:70d:f420:7ab4 with SMTP id 00721157ae682-71a466bf17dmr59879097b3.29.1753890859348; Wed, 30 Jul 2025 08:54:19 -0700 (PDT) Received: from moss-4 ([131.183.131.33]) by smtp.gmail.com with ESMTPSA id 00721157ae682-719f21e6082sm24936317b3.38.2025.07.30.08.54.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 08:54:18 -0700 (PDT) From: "J.D. Smith" To: Michael Albinus Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <87fredsmy8.fsf@gmx.de> (Michael Albinus's message of "Wed, 30 Jul 2025 17:44:15 +0200") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> Date: Wed, 30 Jul 2025 11:54:18 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael Albinus writes: > > Tramp uses an own declare form `tramp-suppress-trace'. In order to make > it happen, there's the code > We are already adding the new declare form to `macro-declarations-alist', but the problem is, this code will not exist in Emacs <31. I guess we could recommend: (add-to-list macro-declarations-alist (list autoload-macro ignore)) in the meantime. But just skipping the declare (for now) as Stefan suggests is I guess the simpler approach. People who want to use it will need to require v>=31. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 13:51:17 2025 Received: (at 78995) by debbugs.gnu.org; 30 Jul 2025 17:51:17 +0000 Received: from localhost ([127.0.0.1]:42560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uhAxR-000142-53 for submit@debbugs.gnu.org; Wed, 30 Jul 2025 13:51:17 -0400 Received: from mout.gmx.net ([212.227.15.19]:43679) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uhAxO-00013j-TU for 78995@debbugs.gnu.org; Wed, 30 Jul 2025 13:51:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1753897864; x=1754502664; i=michael.albinus@gmx.de; bh=/A4eT7iMyJ+8t4o2AyQap9JVcBa3ryj0aGWx3b7xgMI=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=k06XfILaH034pgJK42jtf3OQV4UqJNJhH81g3Py4y8AwlgatYd3PUVIz8eS23Erd 5ARIJLOnjU51Kcyg8ykDzX/KJ6mDu43RxOpD+ReUaRTw5ePHllsE8LtTuD75pPoZe 1yClZrhKkC6Dgqk5XZSr3xZRQoKv3tn9D/d7gIS0HzkUMAYKMVUfFmnnSExvk74Sr eQsmtNcZkn4+Nv9an7TH/r66WgUzK0WRWs5kGGuPJMhrCuQJQmxwEd9OG8WsAkg5f LpkePhmNV/YTi2EryBpYCdeWMlICMFHlQeiT7csP1dyZJj6cQw6eeiljYjKW0TVxq dh3Gq+KwtPq5hbWVzw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.61]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MxlzI-1uSN6613r4-013FWi; Wed, 30 Jul 2025 19:51:04 +0200 From: Michael Albinus To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> Date: Wed, 30 Jul 2025 19:51:02 +0200 Message-ID: <87bjp1sh2x.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:WPLAUSQGZedmx4R8sZI4kAJfV5o4dzPhCYwxLGNSh+cE/wZ+rM7 LdyThDFWlvtXDqsP7HF56IizRMtDEFo89cUT0N70IwtO4VxHYY0Qi7m2uu/v9RHiruVr8FZ ViORnCm9vpvP0ekTbO4+TmzCPXfK25JSgVDu4CgQzvR7GY5B3iMuBVASiw+qVIO2McVHvvD su4SsL6gU67No6re7cjsg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:D606YzcYHrc=;nZJ9SOo6yBeHQrTwWrxQYOhRw2F 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 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) "J.D. Smith" writes: Hi, >> Tramp uses an own declare form `tramp-suppress-trace'. In order to make >> it happen, there's the code > > We are already adding the new declare form to > `macro-declarations-alist', but the problem is, this code will not > exist in Emacs <31. I meant to do this in tramp.el or tramp-compat.el Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 30 14:25:46 2025 Received: (at 78995) by debbugs.gnu.org; 30 Jul 2025 18:25:46 +0000 Received: from localhost ([127.0.0.1]:42715 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uhBUo-0003Kk-7V for submit@debbugs.gnu.org; Wed, 30 Jul 2025 14:25:46 -0400 Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]:54312) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uhBUl-0003KG-Dn for 78995@debbugs.gnu.org; Wed, 30 Jul 2025 14:25:44 -0400 Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-e8e14cf9e2aso175034276.0 for <78995@debbugs.gnu.org>; Wed, 30 Jul 2025 11:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753899937; x=1754504737; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=ttpLKSnZqsMlCrCAzWdzEG2WWJlwYA39GgYrKHfSaLA=; b=EfuYyOpj3SFx2N5ZiMAHAV8R210a9BQElFP0Gl23iZx7/nEQA3MZgTj5cww6xaYikQ 0T9lcg9ZaxeFBBzs0yKik/wEElMSZgrfEde9g4DcULGWxEwNy1KmfxCzn4lTrT2Ti/tv zwouhKlsUetxfQEKqcJX1Skvuqw9Nbt2SINAKQ/ePHODk0sTF3up/gGChbax5RE76F0p PA55df/GCeFqkc6wiXRvXB7T8raEwid9064uB7YjsTxcGGok2bhL9fw+JeGCaOiAzH9b ZXhn4+ogWBFRf99cI9PTYEZA2vhkThtChwcQCVvT9VnR+1RUlgNGJAgcZd44PpvPHlID P4hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753899937; x=1754504737; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ttpLKSnZqsMlCrCAzWdzEG2WWJlwYA39GgYrKHfSaLA=; b=NaAKesiT/kbia+kUghI6mfiihz2N5QiZnPU29X5B3I1i8MEWePCf2ighhCjBI5gyXE gYtFimkQHqXOyEujCO4/GMJ/Yg+HQeWVVS920b52EMICt7WbZAxUsQq3q9aUu2L7zDub 750RZQHuXn4DCyJct/1BWeEoSSldXTnPBuOmPevJ5IPHGMf+tmABpasxO3YNakdNhTXO 2CSg8Kn1TjWCCaFvfwjxTNvTevuuESbcxyuDdgH9kYDz3ITJmX4mrmrSx6dNw7XfdS+I dm3+D9ihS2fWRtodyNtn2nRJfdGQ/iMA3CGzGsIvvmYsflFibvrlFoPwzA8BVsCEfdzp oxnQ== X-Gm-Message-State: AOJu0YwzdPqNmfFraWOm97sj1nr1jI9L+Nq8HkC9LErvuwYBd7yihH+V 9L7fwUU7pK3dRMxsnl27jzVUa10IBc3rNgfIKvBgFFwAi6axORBLbZAnKaGB2A== X-Gm-Gg: ASbGncuXAnHriTMGCuxBxA6pbagLd3v4wpOC7VihvnxmDidR9BBBYKM0JeP4GvTje6p dF+pj+VbW5GZLmo8OzTOP9VLPjePUPgvP0uRu7TqICkUQOomRQNy7+rFas7hx1SWNLOrLHAC9f9 hNytvYFqJU7R1gnKop2J5vslQMKppxe+6nb8JKuSmO5csMK8WN3k7Cyvkfk5yWzCT7glRA7e/Rb dSVjtEP7noAC2gLDtEl7yQ8BmzEYhgg57SQLF6Czmb9nfdugFQxM/LbgSKmQ2xHREA3K0Sz84Cd aubSQqkJyZrP/FkRXqjje1Cs3rzoyIm4e/tnC5RAQwrRgNcscpNgFPkIsUy/gxp/uMidCBRB0GE og4PJCWnJACg8vlNCSOC54Zr1n2XMkQ== X-Google-Smtp-Source: AGHT+IETu5P5T+YDL3Mah/NbYL7VG7YXosVQA8uxr7Azcy3gf/R+xnKC8oGcx7zzSFgFCX0iQiz+cw== X-Received: by 2002:a05:6902:841:b0:e8d:d07a:ec4 with SMTP id 3f1490d57ef6-e8e3149ce1fmr5072743276.13.1753899937156; Wed, 30 Jul 2025 11:25:37 -0700 (PDT) Received: from moss-4 ([131.183.131.33]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e8df85d7b27sm3778770276.18.2025.07.30.11.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jul 2025 11:25:36 -0700 (PDT) From: "J.D. Smith" To: Michael Albinus Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <87bjp1sh2x.fsf@gmx.de> (Michael Albinus's message of "Wed, 30 Jul 2025 19:51:02 +0200") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> <87bjp1sh2x.fsf@gmx.de> Date: Wed, 30 Jul 2025 14:25:35 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael Albinus writes: > "J.D. Smith" writes: > > Hi, > >>> Tramp uses an own declare form `tramp-suppress-trace'. In order to make >>> it happen, there's the code >> >> We are already adding the new declare form to >> `macro-declarations-alist', but the problem is, this code will not >> exist in Emacs <31. > > I meant to do this in tramp.el or tramp-compat.el Aha. One idea would be for tramp-compat to including something like: ;; Remove when Emacs >=31 is required (require 'loaddefs-gen) (cl-symbol-macrolet ((amac (alist-get 'autoload-macro macro-declarations-alist))) (unless amac (setq amac #'ignore))) to silence the warning, yet remain harmless once Emacs 31 is in the wild. From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 31 01:24:06 2025 Received: (at 78995) by debbugs.gnu.org; 31 Jul 2025 05:24:07 +0000 Received: from localhost ([127.0.0.1]:45320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uhLlu-00066Y-HL for submit@debbugs.gnu.org; Thu, 31 Jul 2025 01:24:06 -0400 Received: from mout.gmx.net ([212.227.17.22]:44659) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uhLlq-00065Z-SU for 78995@debbugs.gnu.org; Thu, 31 Jul 2025 01:24:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1753939433; x=1754544233; i=michael.albinus@gmx.de; bh=WTnm9fj0K4l7Mh4upGAnppp9pnkT4XQSL70/5DLyDyE=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=VMQsL7rJ23ImtJIggc7LFt1qjebmbffnFM+U4XOeyOwLjBULGU0K54hSBqsNMtrg TfDyFgK99VKKh4sylgQTD3mGYjRDSbduoWDvSILSp4yrxs9UTJElVb34bAJ5JqJnO xvq6NxGxvPGwE3R/PKWtI9CCZXvAsNCWBy1/QTtZC8Uz+IOWIYeWqGZzdhG1Rgzww ai6/Tqdy0f9ONzzOmLYhv8/6tY42gxCbnrx0Ka9b+xjCgS953fgo/t1ao7FV9nRrN 9n+aoOrIumsi7hxS7waDKZMMzl4JCr5z/Am2EzZ0+8EmA1Pc9/fVgjyq/oYQULDRM 8juWMsEfAFIKaUVn/w== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.61]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MiJZO-1uCwda3TDK-00cJT3; Thu, 31 Jul 2025 07:23:52 +0200 From: Michael Albinus To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> <87bjp1sh2x.fsf@gmx.de> Date: Thu, 31 Jul 2025 07:23:51 +0200 Message-ID: <875xf9rl08.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:jTAqA1QiGqR78eqLdJiK0r5HeRPNpnSec+2t0UMzc2ckBl666/v bVQ5CRExere+/L9o695skyOt7wDU4DdVzTwROnFeRC+GZ2UiSdzj2Ss1UPERMY9nXKm5g4a xnFSk9jkXKghXKyP0eAZeW1o2w/0rRVMDD7A4EpaW816QAzRFMVEPNYtNiTKgLlDnQgDwnq dLoCUbdR95d/USEMQuZlw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:w+Ltm15g/Rc=;lMnFTZvZimHFiuxMwJD8P0Pjj+M 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 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) "J.D. Smith" writes: Hi, > Aha. One idea would be for tramp-compat to including something like: > > ;; Remove when Emacs >=3D31 is required > (require 'loaddefs-gen) > (cl-symbol-macrolet > ((amac (alist-get 'autoload-macro macro-declarations-alist))) > (unless amac (setq amac #'ignore))) =20 > > to silence the warning, yet remain harmless once Emacs 31 is in the > wild. Feel free to add this to Tramp in master. I'm busy these days; will check over the weekend. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 01 10:39:57 2025 Received: (at 78995) by debbugs.gnu.org; 1 Aug 2025 14:39:57 +0000 Received: from localhost ([127.0.0.1]:56493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uhqvM-00044C-Np for submit@debbugs.gnu.org; Fri, 01 Aug 2025 10:39:57 -0400 Received: from mout.gmx.net ([212.227.15.15]:47143) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uhqvH-00043d-A2 for 78995@debbugs.gnu.org; Fri, 01 Aug 2025 10:39:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1754059179; x=1754663979; i=michael.albinus@gmx.de; bh=uKUXLIQD12kYXF/SWnu2lvjUT1MAE8eB7yijUDNIXFo=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=JGo8wTEFM5cSO+luU5+FCpYsLoGV3uCHiTAFrZ6tq7GBOZpZvbTEncWMSTPrfPWs Ik+vyQE1EEgkhTqJzn8nsqaRgQFUi2v5PqvWUkovqJzGumDX2wN+OMpS5TtQLa3oM lT6JftrEnAE+KkUdiFWiViZHuQo5SXXZEVBRObEBtueZZ1zI+aAa8dn2uFReSMC8Y tD/BUttRFj17YT2Jd5nB60US4GPpO9HDx5FL6GkNSTlS4tHbzP8/bB8c6d3QZLugK dq+Mbno62VWwcgilgPkxKa0zVmkuX0q43Bvmrt6Nw5wUhXAagzIhOQKIZZTGoSKmb mgSEkM0VfoRBMZmQaA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.61]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MsYqv-1uOgL21u3v-014qbG; Fri, 01 Aug 2025 16:39:39 +0200 From: Michael Albinus To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> <87bjp1sh2x.fsf@gmx.de> Date: Fri, 01 Aug 2025 16:39:37 +0200 Message-ID: <87a54jgl7a.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:1d2Js4ss205GxjByCehI26VvWExM1Eh2oXO6CDiBaHKsx5QJN/V UZCx1JB4KNXb64hSkNB7OOBDKTqaEqNH7NF43KjC0Zx1j9hay9TeLLDyM1nCdboRigY7d03 YsUt/g6NvlWiH+uN8/kKmFQ+JQD61xqB/y31bsiDp/Hs9d8ujns2YgrxP0KY5jHD9OXkaDK ELMFwTmC5M/9EalRwEIIg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:AsXsEjQH6o8=;CvKkR98n/7AIPCSqYeAs4ZBlSer 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 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) "J.D. Smith" writes: Hi, >>>> Tramp uses an own declare form `tramp-suppress-trace'. In order to ma= ke >>>> it happen, there's the code >>> >>> We are already adding the new declare form to >>> `macro-declarations-alist', but the problem is, this code will not >>> exist in Emacs <31. >> >> I meant to do this in tramp.el or tramp-compat.el > > Aha. One idea would be for tramp-compat to including something like: > > ;; Remove when Emacs >=3D31 is required > (require 'loaddefs-gen) > (cl-symbol-macrolet > ((amac (alist-get 'autoload-macro macro-declarations-alist))) > (unless amac (setq amac #'ignore))) =20 > > to silence the warning, yet remain harmless once Emacs 31 is in the > wild. That doesn't work with Emacs 28: =2D-8<---------------cut here---------------start------------->8--- # make -C lisp EMACS=3D/home/albinus/src/emacs-28/src/emacs make: Entering directory '/home/albinus/src/tramp/lisp' /home/albinus/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/= lisp -l autoload \ --eval "(setq generate-autoload-cookie \";;;###tramp-autoload\")" \ --eval "(setq generated-autoload-file \ (expand-file-name \"tramp-loaddefs.el\"))" \ --eval "(setq make-backup-files nil)" \ -f batch-update-autoloads . SCRAPE . INFO Scraping files for tramp-loaddefs.el...=20 INFO Scraping files for tramp-loaddefs.el...done /home/albinus/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/= lisp -l bytecomp -f batch-byte-compile tramp-loaddefs.el /home/albinus/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/= lisp -l bytecomp -f batch-byte-compile trampver.el /home/albinus/src/emacs-28/src/emacs -Q -batch -L /home/albinus/src/tramp/= lisp -l bytecomp -f batch-byte-compile tramp-compat.el In toplevel form: tramp-compat.el:33:1: Error: Cannot open load file: No such file or direct= ory, loaddefs-gen make: *** [Makefile:77: tramp-compat.elc] Error 1 make: Leaving directory '/home/albinus/src/tramp/lisp' =2D-8<---------------cut here---------------end--------------->8--- Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 01 14:48:16 2025 Received: (at 78995) by debbugs.gnu.org; 1 Aug 2025 18:48:16 +0000 Received: from localhost ([127.0.0.1]:57368 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uhunf-0002WK-Qi for submit@debbugs.gnu.org; Fri, 01 Aug 2025 14:48:16 -0400 Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]:61921) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uhund-0002Vo-Ft for 78995@debbugs.gnu.org; Fri, 01 Aug 2025 14:48:14 -0400 Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-71b71a8d5f0so11167237b3.3 for <78995@debbugs.gnu.org>; Fri, 01 Aug 2025 11:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754074088; x=1754678888; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=vms966nkO9kI9HSKgKjO/NdppS9rwpeJFiZUBXbMLbA=; b=fQyGFn1NGBAKyA+CzP8wtmHpTJ8BM3Jp9K60H2vmd65xPFNaHvvWT/HZOVv6AGzflL iJOs8l1z4UvIe7Y1DfVFD0EdrytMvyZu8/QVHYTBh+sgjHULwGq/7wIP6Zy6OoCEHmWf 9y0HCmcC3aPeBpDQu9WthJN0bjkCJD4pU/XCWOE1HPCwvb/pA/9IFK7NVKICB8Ep+b8y bKbaLCuKF6Exk2A/qUoXs+furRo46pWH6n04Q/xy7i1KM6jK6+u7RuvGdTwNnEmHuYGJ U7G2rnirCx8Ml33Lsx40ybUayXJjTq6LNEPXZ6lkZTz1OESCOjJ+lCa/jhS6a0H3CMKg h2jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754074088; x=1754678888; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vms966nkO9kI9HSKgKjO/NdppS9rwpeJFiZUBXbMLbA=; b=CUptIRLglSEDxgMNacvRjFcPgu6S8c4khcfi1AUZ5Tkrsly5QfthBQ1mzYfSmXgTcv NLP6xB16rCltAEmqjR3EZKv8qvRpXe1DkeEbn48z/+e7DQRyzc/6xHKhrDnHsem2UTko h/G5G0+mFigRfF1LVgBCtYno8+PV9ONvRyf32O/VVTcF3/ruHNasuUZ/iumi4vT9kfHD PODy5P0rB3i/Cpzgh5yJoye64z9hAe5cnp3BUQevxvHVspqCbffn7soLPYBKnUxnmWmO 3hBYdEUsZdvzqNTeZSEBoLJvwvfobO4aw5pWbaFR9hr8ZfOYXGoAFMg24ZOHNdU1XhYk hFbw== X-Gm-Message-State: AOJu0YxWKXhccA8W23NdaPH2lcqBHDODvf7UPiCyVgtm9XgzN99nr5G6 cDbD+nov5JQhVXWxU4pOEK/YS+8n68SLvK5N2GDMg1Fef7Y03hK1wQU3 X-Gm-Gg: ASbGncs/lA/IXomiGUSItnVzHqyYZiQrvYvnjs9Ff9BaKD0PAFsOixFZzxWsMWqurfP sRUnYGAjxYEfq2p7rlpGSwveMArylk0ltJ3ozCQ/5ND+hi4pr/ysb+VVpYGBxMNOe9/yHd9ZsNi QQL+oP5InrQtpwXFJz8SYQAsLaJV5YZk+gsOZ8mch+cTjo2SzUAGzvXu51rUpDx4DAByrplmbX1 cT5hMfU38mVl22lQnwwxjI/RaacRfyd8G3MKBiDshYpVgzB0Oy7h+ODIP6FmNUq7DoDswgE+DAY 7MsGpS9Ac+eA9oSNnpegskIFnhhsFy+kSvGYZ0E6FC5KNnPfzQMikQl8mZj2LvpFBSC/gfqkdHf 1NiM6bKjmnNjF9uOj+FqecNmqNUuV2eo8dKL3+FvF X-Google-Smtp-Source: AGHT+IF/J4VKHwoJ9Z/NJeSRRD3stx+rBeERLvN1xKDn/3mvHEW84lpZeYBfmsC0X8w+S7Wx07ECyQ== X-Received: by 2002:a05:690c:778a:20b0:708:f6d:b79f with SMTP id 00721157ae682-71b7f4323f1mr6607037b3.29.1754074087660; Fri, 01 Aug 2025 11:48:07 -0700 (PDT) Received: from moss-4 ([131.183.131.33]) by smtp.gmail.com with ESMTPSA id 00721157ae682-71b5a5c62efsm11643247b3.63.2025.08.01.11.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Aug 2025 11:48:07 -0700 (PDT) From: "J.D. Smith" To: Michael Albinus Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <87a54jgl7a.fsf@gmx.de> (Michael Albinus's message of "Fri, 01 Aug 2025 16:39:37 +0200") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> <87bjp1sh2x.fsf@gmx.de> <87a54jgl7a.fsf@gmx.de> Date: Fri, 01 Aug 2025 14:48:06 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael Albinus writes: > "J.D. Smith" writes: > > Hi, > >>>>> Tramp uses an own declare form `tramp-suppress-trace'. In order to make >>>>> it happen, there's the code >>>> >>>> We are already adding the new declare form to >>>> `macro-declarations-alist', but the problem is, this code will not >>>> exist in Emacs <31. >>> >>> I meant to do this in tramp.el or tramp-compat.el >> >> Aha. One idea would be for tramp-compat to including something like: >> >> ;; Remove when Emacs >=31 is required >> (require 'loaddefs-gen) >> (cl-symbol-macrolet >> ((amac (alist-get 'autoload-macro macro-declarations-alist))) >> (unless amac (setq amac #'ignore))) >> >> to silence the warning, yet remain harmless once Emacs 31 is in the >> wild. > > That doesn't work with Emacs 28: > Hmm, I guess `loaddefs-gen' was introduced in emacs 29. But I think you don't actually need that `require' at all. Maybe try a simple: (unless (alist-get 'autoload-macro macro-declarations-alist) (push '(autoload-macro ignore) macro-declarations-alist)) From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 01 18:37:39 2025 Received: (at 78995) by debbugs.gnu.org; 1 Aug 2025 22:37:39 +0000 Received: from localhost ([127.0.0.1]:58759 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uhyNe-0004Dy-K3 for submit@debbugs.gnu.org; Fri, 01 Aug 2025 18:37:39 -0400 Received: from mail-yb1-xb2f.google.com ([2607:f8b0:4864:20::b2f]:57617) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uhyNb-0004DW-Jx for 78995@debbugs.gnu.org; Fri, 01 Aug 2025 18:37:36 -0400 Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-e8e014c1d19so1140482276.3 for <78995@debbugs.gnu.org>; Fri, 01 Aug 2025 15:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754087850; x=1754692650; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=qfIyk2g8Rb5EWa1XeBaEroK6EVqgNw5KishNYh8tdYM=; b=D4nBO7hbI80tRHQJwvEOXtq8AaZylKe05q07mXa7qhLqwqnXnlkfCNoAq9HIzs0r8X kwiepRvmvVMb280PDmw3DakvZpL0GwOauJYLZJtd+PrnLpbxrk15QWXit27PUUU2AWYG IipsrYnKjWttnYdCkMg9GeNQgFIP+uvT2Z5/lOe+mxF38tijNIJVnxJ5xxDBKSvwjSxZ UOBJ/O8ITRXU8fAtDSDz+7ujw3p20avLYwjfYqegqny9CArBnerqcPid5tRmxZFz60ox FroIYKeokXTKfLYQMztIeMz79Tx33QWhqyhwp4sfXvhwbSj3h3VJ/P5cGsGppYmBWA8r ALRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754087850; x=1754692650; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qfIyk2g8Rb5EWa1XeBaEroK6EVqgNw5KishNYh8tdYM=; b=qViwviBExkaT6IFnDRc/ms2gqtk/bv8gSWDFkxTPfsf8zfVPpEhBeCFfRDvoJISg/5 d312svUdk016+jWv4u1Fqbugu+Zuv3hO7HJblDj16/khrAgJgMWGSo3b9iLpyAQAwKSe LVP/mkPPLgWURM/doQZcMMR6+PYrfRb8Gu9DpTS8F+Avoxr7FPIMq1WBW9xSolB2lJcs aA+GWra4IlyNhWLwnV0gQenTsGkx6A72fGq4sy++igSGgRyEYAew0gNMir8D/q8tRUdq uQCjpkwIiyFXTkGPeAkePhsjWyePI+lOSh3MvNeKaVtXppOSd/H7GUQXn1ZAqLaUd+M7 /IQw== X-Gm-Message-State: AOJu0Yzc/P71Yb5IyscF41ZJmKaRxhDsHhRbscSfdiB9gNFggDDnVgQp RPfTeEY+r4NbsYy9g1aMeZ6Bb1xMecZJSxJsHMl1UDjWz9ewaWAOWisV X-Gm-Gg: ASbGncuxp1tpWGz93cWXaEcxsgV4HhjyvZjGmz13HK2XPPjJ+lgeTSlPep1PnWAaUsU ITpj6NX0w2WOf+X45uAOh+CxjK9q+mXNeFE5fmPZlVrj4buSeiZMOnaiv3wYM+h084w5KNr9mCi cdiYQqCl2CGyXcDxMFKM1jY9SMiWWsetkhzTi/XFWT2O1g9W8wsb3G7GlshR0obCqE0eGuFoIS3 db+PRekzyWXW58QGeNcxwpLKpEfvshEAkkTfckh95PPTq7VMCpn8xyOLNyyGPhouqgbGoWssEVA 4FYveQ9ke7766kFPn1GESvYbmW9qnhXVwKiXf6tLHmM3rLzI7lVtg/7GibArA1+t768odwEVE2U ryc1MkT/zMsQaZV209M2O5KqvO0KxnkTdnN6/u7TrLBuQPM51pNIn8X4u X-Google-Smtp-Source: AGHT+IH4HJZiZgMEgGQ0vRq2YdIv+XYZYtrGQ2079rXlJOJ7Z12TZthTrJRPGwZnLq0jl2LtAPqQCw== X-Received: by 2002:a05:6902:709:b0:e8f:d82c:628 with SMTP id 3f1490d57ef6-e8fee0583e0mr2178354276.33.1754087849505; Fri, 01 Aug 2025 15:37:29 -0700 (PDT) Received: from moss-4 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e8fd3713e9fsm1824002276.5.2025.08.01.15.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Aug 2025 15:37:28 -0700 (PDT) From: "J.D. Smith" To: 78995@debbugs.gnu.org, Stefan Monnier , Eli Zaretskii , Philip Kaludercic Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> (JD Smith's message of "Fri, 11 Jul 2025 15:28:03 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Fri, 01 Aug 2025 18:37:28 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain JD Smith writes: Stefan, Eli, any comments on the documentation (or other) parts of this patch? Stefan, do you think the proposed TRAMP solution (add an `ignore' `macro-declarations-alist' entry for `autoload-macro' for earlier versions of emacs) makes sense? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=autoload-expand_6.patch Content-Description: autoload-macro declare patch with documentation diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index be3c1e78889..25a01d942b6 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2633,6 +2633,11 @@ Declare Form This is typically used for macros, though it works for functions too. @xref{Indenting Macros}. +@item (autoload-macro @var{value}) +This is used when defining a macro. If @var{value} is @samp{expand}, +any calls to the macro which follow an autoload comment will first be +expanded during generation of the autoloads. @xref{Autoload}. + @item (interactive-only @var{value}) Set the function's @code{interactive-only} property to @var{value}. @xref{The interactive-only property}. diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 750f6e76eff..65a55547a9f 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi @@ -710,8 +710,31 @@ Autoload If you write a function definition with an unusual macro that is not one of the known and recognized function definition methods, use of an ordinary magic autoload comment would copy the whole definition into -@code{loaddefs.el}. That is not desirable. You can put the desired -@code{autoload} call into @code{loaddefs.el} instead by writing this: +@code{loaddefs.el}. That is often not desirable. In this case, you can +use the special declare form @code{(autoload-macro expand)} in your +macro definition (@pxref{Declare Form}). This indicates to the autoload +system that calls to your macro following @samp{;;;###autoload} should +be expanded, similar to how the special functions listed above are +handled. For example, a macro which wraps @code{define-minor-mode} can +request expansion, so that proper @code{autoload} calls for the function +it defines are generated. + +The symbol @code{:autoload-end} can be used in the expansion to prevent +including unwanted forms in the autoload output. Its presence causes +any further elements within the list where it appears to be silently +skipped. + +Note that, if a symbol in the car of an autoloaded form is not defined +during autoload generation, the file in which the associated +@samp{;;;###autoload} appears will itself be loaded, to give the macro a +chance to be defined. Packages which use special loading mechanisms, +including requiring their own @samp{foo-autoload.el} file, should +therefore gracefully handle load errors, since these files may not yet +exist during autoload generation. This can be done, e.g., by setting +the @var{no-error} argument of @code{require} non-@code{nil}). + +Alternatively, instead of expansion, you can put the desired +@code{autoload} call into @code{loaddefs.el} by writing this: @example ;;;###autoload (autoload 'foo "myfile") diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 366423904db..3e521e18567 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -271,6 +271,11 @@ 'byte-run--set-debug (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload-macro + #'(lambda (name _args spec) + (list 'function-put (list 'quote name) + ''autoload-macro (list 'quote spec)))) + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -350,8 +355,10 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + (list 'autoload-macro #'byte-run--set-autoload-macro) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -397,6 +404,7 @@ 'defmacro (if declarations (cons 'prog1 (cons def (car declarations))) def)))))) +(function-put 'defmacro 'autoload-macro 'expand) ; Since we cannot `declare' it ;; Now that we defined defmacro we can use it! (defmacro defun (name arglist &rest body) @@ -409,7 +417,7 @@ defun The return value is undefined. \(fn NAME ARGLIST [DOCSTRING] [DECL] [INTERACTIVE] BODY...)" - (declare (doc-string 3) (indent 2)) + (declare (doc-string 3) (indent 2) (autoload-macro expand)) (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 3aa26fba3c3..4a85d89d5fa 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -258,7 +258,8 @@ cl-defgeneric cl--generic-edebug-make-name in:method] lambda-doc def-body)]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((doc (if (stringp (car-safe options-and-methods)) (pop options-and-methods))) (declarations nil) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2a0a9e5c6de..1b64f106a1b 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -398,7 +398,8 @@ cl-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defun ,name ,@(cl--transform-lambda (cons args body) name))) ;;;###autoload @@ -416,7 +417,8 @@ cl-iter-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) (require 'generator) `(iter-defun ,name ,@(cl--transform-lambda (cons args body) name))) @@ -475,7 +477,8 @@ cl-defmacro (declare (debug (&define name cl-macro-list cl-declarations-or-string def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defmacro ,name ,@(cl--transform-lambda (cons args body) name))) (def-edebug-elem-spec 'cl-lambda-expr @@ -3011,7 +3014,8 @@ cl-defstruct sexp])] [&optional stringp] ;; All the above is for the following def-form. - &rest &or symbolp (symbolp &optional def-form &rest sexp)))) + &rest &or symbolp (symbolp &optional def-form &rest sexp))) + (autoload-macro expand)) (let* ((name (if (consp struct) (car struct) struct)) (warning nil) (opts (cdr-safe struct)) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index f53db48f0b7..0e428abd0b7 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -222,10 +222,11 @@ define-minor-mode (indent defun) (debug (&define name string-or-null-p [&optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp] + &optional [¬ keywordp] sexp + &optional [¬ keywordp] sexp] [&rest [keywordp sexp]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((last-message (make-symbol "last-message")) (mode-name (symbol-name mode)) @@ -487,7 +488,7 @@ define-globalized-minor-mode on if the hook has explicitly disabled it. \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" - (declare (doc-string 2) (indent defun)) + (declare (doc-string 2) (indent defun) (autoload-macro expand)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 344e11e245e..59784ff51e8 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -675,7 +675,8 @@ iter-defun of values. Callers can retrieve each value using `iter-next'." (declare (indent defun) (debug (&define name lambda-list lambda-doc &rest sexp)) - (doc-string 3)) + (doc-string 3) + (autoload-macro expand)) (cl-assert lexical-binding) (let* ((parsed-body (macroexp-parse-body body)) (declarations (car parsed-body)) diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index c015e2b57d0..5acd6f17ee2 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -135,7 +135,7 @@ define-inline This is like `defmacro', but has several advantages. See Info node `(elisp)Defining Functions' for more details." ;; FIXME: How can this work with CL arglists? - (declare (indent defun) (debug defun) (doc-string 3)) + (declare (indent defun) (debug defun) (doc-string 3) (autoload-macro expand)) (let ((doc (if (stringp (car-safe body)) (list (pop body)))) (declares (if (eq (car-safe (car-safe body)) 'declare) (pop body))) (cm-name (intern (format "%s--inliner" name))) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..f9c6f82c31f 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -142,12 +142,29 @@ loaddefs-generate--shorten-autoload 3) form)) +;; TODO: some macros can be removed from this list once they +;; (declare ((autoload-macro expand) ...) +(defconst loaddefs--defining-macros + '(define-skeleton define-derived-mode + define-compilation-mode define-generic-mode + easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode + easy-mmode-define-minor-mode define-minor-mode + cl-defun defun* cl-defmacro defmacro* + define-overloadable-function + transient-define-prefix transient-define-suffix + transient-define-infix transient-define-argument)) + +(defvar loaddefs--load-error-files nil) (defun loaddefs-generate--make-autoload (form file &optional expansion) "Turn FORM into an autoload or defvar for source file FILE. Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. + +Note that macros can request expansion by including `(autoload-macro +expand)' among their `declare' forms." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -191,35 +208,40 @@ loaddefs-generate--make-autoload (setq form (copy-sequence form)) (setcdr (memq :autoload-end form) nil)) (let ((exps (delq nil (mapcar (lambda (form) - (loaddefs-generate--make-autoload - form file expansion)) + (unless (eq form :autoload-end) + (loaddefs-generate--make-autoload + form file expansion))) (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) - (macrop car) - (setq expand (let ((load-true-file-name file) - (load-file-name file)) - (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) + ;; For macros which request it, try again on their expansion. + ((progn + ;; If the car is an unknown symbol, we load the file first to + ;; give packages a chance to define their macros. + (unless (or (not (symbolp car)) (fboundp car) + ;; Special cases handled below + (memq car loaddefs--defining-macros) + (memq car '(defclass defcustom deftheme defgroup nil)) + (assoc file load-history) + (member file loaddefs--load-error-files)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s (for %s)" file car) + (condition-case e (load file) + (error + (push file loaddefs--load-error-files) ; do not attempt again + (warn "loaddefs-gen: load error\n\t%s" e))))) + (and (macrop car) + (eq 'expand (function-get car 'autoload-macro)) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) + (not (eq car (car expand))))) ;; Recurse on the expansion. (loaddefs-generate--make-autoload expand file 'expansion)) - ;; For special function-like operators, use the `autoload' function. - ((memq car '(define-skeleton define-derived-mode - define-compilation-mode define-generic-mode - easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode - easy-mmode-define-minor-mode define-minor-mode - cl-defun defun* cl-defmacro defmacro* - define-overloadable-function - transient-define-prefix transient-define-suffix - transient-define-infix transient-define-argument)) + ;; For known special macros which define functions, use `autoload' + ;; directly. + ((memq car loaddefs--defining-macros) (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) (name (nth 1 form)) (args (pcase car diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 73554fd66fd..ab8edf1f569 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -537,7 +537,7 @@ pcase-defmacro By convention, DOC should use \"EXPVAL\" to stand for the result of evaluating EXP (first arg to `pcase'). \n(fn NAME ARGS [DOC] &rest BODY...)" - (declare (indent 2) (debug defun) (doc-string 3)) + (declare (indent 2) (debug defun) (doc-string 3) (autoload-macro expand)) ;; Add the function via `fsym', so that an autoload cookie placed ;; on a pcase-defmacro will cause the macro to be loaded on demand. (let ((fsym (intern (format "%s--pcase-macroexpander" name))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 02 02:52:48 2025 Received: (at 78995) by debbugs.gnu.org; 2 Aug 2025 06:52:49 +0000 Received: from localhost ([127.0.0.1]:33409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ui66q-00024G-92 for submit@debbugs.gnu.org; Sat, 02 Aug 2025 02:52:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45014) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ui66o-00023z-6C for 78995@debbugs.gnu.org; Sat, 02 Aug 2025 02:52:46 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ui66h-0001m1-Sq; Sat, 02 Aug 2025 02:52:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=FtIiFZM6ZPBePvYcJHwz8LCTJlqGQ+omSjgEVdHicOw=; b=HpNat8hEDHd2 oyfn4yjirO3XbInMBgIlrFEwoxuqySRvhiZOwiFLONUS5JBFPbiBA2BrD0tiZc0HPXxojxLIq3fzG Jx2QlPrLfWFTrFnulvie+1szMvduIt9n7Mnp2Y69s2A1f04uJ3Q/gwi7VQXBjLWyv9i0SVTli6IeO Cy5dBehSF4JAef2NDuJCXU14hlfg9RHJyKcEBZDnY9CekSJRdWgGDnGDwRVSrnsplYbvMCjtqkvi1 JAgwz6ffOWJAYpYN5j92vM/vcm2vPCEz2vBxod42TpDBk/8JHV3DMY+qeWAnuNy2hX39xsrCjwj3S 8NI9VKH47S/gJwBILiZ5sA==; Date: Sat, 02 Aug 2025 09:52:32 +0300 Message-Id: <861pputdu7.fsf@gnu.org> From: Eli Zaretskii To: "J.D. Smith" In-Reply-To: (jdtsmith@gmail.com) Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: philipk@posteo.net, 78995@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: "J.D. Smith" > Date: Fri, 01 Aug 2025 18:37:28 -0400 > > JD Smith writes: > > Stefan, Eli, any comments on the documentation (or other) parts of this > patch? Some, see below. > --- a/doc/lispref/functions.texi > +++ b/doc/lispref/functions.texi > @@ -2633,6 +2633,11 @@ Declare Form > This is typically used for macros, though it works for functions too. > @xref{Indenting Macros}. > > +@item (autoload-macro @var{value}) > +This is used when defining a macro. If @var{value} is @samp{expand}, > +any calls to the macro which follow an autoload comment will first be > +expanded during generation of the autoloads. @xref{Autoload}. This can benefit from an index entry. > --- a/doc/lispref/loading.texi > +++ b/doc/lispref/loading.texi > @@ -710,8 +710,31 @@ Autoload > If you write a function definition with an unusual macro that is not > one of the known and recognized function definition methods, use of an > ordinary magic autoload comment would copy the whole definition into > -@code{loaddefs.el}. That is not desirable. You can put the desired > -@code{autoload} call into @code{loaddefs.el} instead by writing this: > +@code{loaddefs.el}. That is often not desirable. In this case, you can ^^^^^^^^^^^^ It is not clear what case is alluded here as "this case". Suggest instead to say something like "If you don't want the macro copied to @file{loaddefs.el}, you can ..." Or to make a simple sentence like "If this is not desirable, you can ...". Btw, please use @file{loaddefs.el}, as @code is wrong when referring to files. > +use the special declare form @code{(autoload-macro expand)} in your > +macro definition (@pxref{Declare Form}). This indicates to the autoload > +system that calls to your macro following @samp{;;;###autoload} should > +be expanded, similar to how the special functions listed above are > +handled. For example, a macro which wraps @code{define-minor-mode} can > +request expansion, so that proper @code{autoload} calls for the function > +it defines are generated. This text left me wondering how this is different from not using autoload-macro. When you describe some measure to avoid an undesirable outcome, please always be sure to say what will happen under if that measure is taken, as opposed to when it isn't. Here, you say what autoload-macro does, but saying that the macro is expanded doesn't help, because it is expanded even if autoload-macro is not used (right?). > +The symbol @code{:autoload-end} can be used in the expansion to prevent > +including unwanted forms in the autoload output. Its presence causes > +any further elements within the list where it appears to be silently > +skipped. An index entry is missing here. Also, the description is complex enough to call for an example as a means to clarify it. > +Note that, if a symbol in the car of an autoloaded form is not defined ^^^ "car" should be in @code. > +during autoload generation, the file in which the associated > +@samp{;;;###autoload} appears will itself be loaded, to give the macro a > +chance to be defined. Packages which use special loading mechanisms, > +including requiring their own @samp{foo-autoload.el} file, should > +therefore gracefully handle load errors, since these files may not yet > +exist during autoload generation. This can be done, e.g., by setting > +the @var{no-error} argument of @code{require} non-@code{nil}). Please add here a cross-reference to where 'require' is defined. > --- a/lisp/emacs-lisp/byte-run.el > +++ b/lisp/emacs-lisp/byte-run.el > @@ -271,6 +271,11 @@ 'byte-run--set-debug > (list 'put (list 'quote name) > ''edebug-form-spec (list 'quote spec))))) > > +(defalias 'byte-run--set-autoload-macro > + #'(lambda (name _args spec) > + (list 'function-put (list 'quote name) > + ''autoload-macro (list 'quote spec)))) Can we have a comment here explaining the reason for the use of autoload-macro? > (defalias 'byte-run--set-no-font-lock-keyword > #'(lambda (name _args val) > (list 'function-put (list 'quote name) > @@ -350,8 +355,10 @@ macro-declarations-alist > (cons > (list 'debug #'byte-run--set-debug) > (cons > - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) > - defun-declarations-alist)) > + (list 'autoload-macro #'byte-run--set-autoload-macro) And maybe here as well? > --- a/lisp/emacs-lisp/easy-mmode.el > +++ b/lisp/emacs-lisp/easy-mmode.el > @@ -222,10 +222,11 @@ define-minor-mode > (indent defun) > (debug (&define name string-or-null-p > [&optional [¬ keywordp] sexp > - &optional [¬ keywordp] sexp > - &optional [¬ keywordp] sexp] > + &optional [¬ keywordp] sexp > + &optional [¬ keywordp] sexp] > [&rest [keywordp sexp]] > - def-body))) > + def-body)) > + (autoload-macro expand)) And here. > @@ -487,7 +488,7 @@ define-globalized-minor-mode > on if the hook has explicitly disabled it. > > \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" > - (declare (doc-string 2) (indent defun)) > + (declare (doc-string 2) (indent defun) (autoload-macro expand)) And here. > --- a/lisp/emacs-lisp/inline.el > +++ b/lisp/emacs-lisp/inline.el > @@ -135,7 +135,7 @@ define-inline > This is like `defmacro', but has several advantages. > See Info node `(elisp)Defining Functions' for more details." > ;; FIXME: How can this work with CL arglists? > - (declare (indent defun) (debug defun) (doc-string 3)) > + (declare (indent defun) (debug defun) (doc-string 3) (autoload-macro expand)) And here. > --- a/lisp/emacs-lisp/pcase.el > +++ b/lisp/emacs-lisp/pcase.el > @@ -537,7 +537,7 @@ pcase-defmacro > By convention, DOC should use \"EXPVAL\" to stand > for the result of evaluating EXP (first arg to `pcase'). > \n(fn NAME ARGS [DOC] &rest BODY...)" > - (declare (indent 2) (debug defun) (doc-string 3)) > + (declare (indent 2) (debug defun) (doc-string 3) (autoload-macro expand)) And here. > --- a/lisp/emacs-lisp/loaddefs-gen.el > +++ b/lisp/emacs-lisp/loaddefs-gen.el > @@ -142,12 +142,29 @@ loaddefs-generate--shorten-autoload > 3) > form)) > > +;; TODO: some macros can be removed from this list once they > +;; (declare ((autoload-macro expand) ...) > +(defconst loaddefs--defining-macros > + '(define-skeleton define-derived-mode > + define-compilation-mode define-generic-mode > + easy-mmode-define-global-mode define-global-minor-mode > + define-globalized-minor-mode > + easy-mmode-define-minor-mode define-minor-mode > + cl-defun defun* cl-defmacro defmacro* > + define-overloadable-function > + transient-define-prefix transient-define-suffix > + transient-define-infix transient-define-argument)) Please explain in a comment which macros should appear the above list, and why. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 02 13:20:16 2025 Received: (at 78995) by debbugs.gnu.org; 2 Aug 2025 17:20:16 +0000 Received: from localhost ([127.0.0.1]:37510 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiFu4-0006EX-EB for submit@debbugs.gnu.org; Sat, 02 Aug 2025 13:20:16 -0400 Received: from mout.gmx.net ([212.227.15.18]:58725) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uiFu2-0006AY-Ak for 78995@debbugs.gnu.org; Sat, 02 Aug 2025 13:20:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1754155202; x=1754760002; i=michael.albinus@gmx.de; bh=zupMtPjE6lPcMFOXU9CUoijTOQFGe5hKvaknvDT5I6A=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=l/Ib77mUMuIR2TsG208nvfjy1piDj4korNMBSAxfL9YyX9QHh3xw5eoO1c3/4luq 1SHRkmV4NWq9gbPuhwuyx4As5cCkDh6W2ad8UR2/c7ft5+Se6+Fngo2/hSEz0mFCp UVs2C1UTDu/cybwvihcLkYjX9x1inJgOlpYYhaocU7w3PV5wPsqK+3ecdOiE0hOjr gpUpg1DpjLtZkK81vvnUY2gR1jCVb/t1+4oV3RCbVAucxE2IlMcwtG6w6OQ5ukbUh eugaqzZ0jkP45x97Vl4NLe2VnRa7crkL2ELn6Mxmsu3AJKJj4L2RoMxRtX2zb/N+R XtluGnmy7bk12pT8HA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.61]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N17Ye-1uWnnc09z0-00voCj; Sat, 02 Aug 2025 19:20:02 +0200 From: Michael Albinus To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> <87bjp1sh2x.fsf@gmx.de> <87a54jgl7a.fsf@gmx.de> Date: Sat, 02 Aug 2025 19:20:00 +0200 Message-ID: <87o6sxfxof.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:u3huWIUTQerv7xr4P5vHeKU28HaL8TLuvOsccweu1E41nEZqtKh qtflA09KVImnz9QIMw4i8EAo8oy/JNj/fr2/KDEXDT2YW/vKkZEjur5QG2eFwWQGk/9waRM 5UluWCjGPyUmBhZJh9Q7qFk+Z3gNGUXzTkluXQtArrbqU5ZeAut3Myhdhi5lU+Bg7gQHS+/ a9IBcN0TWJRinNeqo8jbA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:s7JpaWbPG9U=;qfDjznBUxLNmMGgWvWS2hAh65LA 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 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) "J.D. Smith" writes: Hi, > Hmm, I guess `loaddefs-gen' was introduced in emacs 29. But I think you > don't actually need that `require' at all. Maybe try a simple: > > (unless (alist-get 'autoload-macro macro-declarations-alist) > (push '(autoload-macro ignore) macro-declarations-alist)) That works with Emacs 28, if I put these lines before the tramp--with-startup macro declaration. I cannot test with the master branch, because the autoload-macro patch doesn't seem to be there yet. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 03 14:16:17 2025 Received: (at 78995) by debbugs.gnu.org; 3 Aug 2025 18:16:18 +0000 Received: from localhost ([127.0.0.1]:45673 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uidFo-0000Mn-Rv for submit@debbugs.gnu.org; Sun, 03 Aug 2025 14:16:17 -0400 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]:60733) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uidFl-0000MP-NH for 78995@debbugs.gnu.org; Sun, 03 Aug 2025 14:16:14 -0400 Received: by mail-qv1-xf34.google.com with SMTP id 6a1803df08f44-7072ed7094aso24725276d6.1 for <78995@debbugs.gnu.org>; Sun, 03 Aug 2025 11:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754244968; x=1754849768; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=MOc15I3Tqdz2k5tiMoGvO+pdfD23X1iCMZckYzIn5KE=; b=PM6hZ3nV1QD/4JMslkjaXr/sGWWJkjlnSc5eXaVSQysM1ZrseXhj1RyLpdpHBGUqiu z+/eepMsfJi08OiTJsteBL7j+8ixTRxpsLa7yl/x6ihGQEj7CV0HDzO//eMvcNgFWO9t 3G5a+NacX00ct8lrL0s0j8orLvqVmEi6GaTiqZjz2UBsDUffNXxW4LP2oIx2aO5pTKMi qq77uYfdNXSZTWobRS7KOAYq/iqo5yMxDq1XU6q0PKFy3B791RUk+W8LnrTKPXmVn4P4 wVpLT54E1qMWzbQ+DZXL6vYpWRK+a+PQu5NT5j2yznD/Yrq+qwpARguT0xJBWMsV0Yz9 RsCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754244968; x=1754849768; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MOc15I3Tqdz2k5tiMoGvO+pdfD23X1iCMZckYzIn5KE=; b=d4wDdi/lpeL+aA+QiFF7e6iK18k6hlCPKhhABJW5+/mD4rMlTDQ8eezxC0XgbeHpXf o7epIhwPzD4uqZzaABx9PN9Zp/N7WdhXBNXtySvIfZJnoluDlFWZX4ro66vxnrAohtL0 SMw+oe8cOgxkxY7FofJQPuTDfVAUjdCIVdEsMMSZICc1q2zCmZKcD+9q/XqKGU6CboPM jRwmGo/Jvze19ODJEoDosEBjajBqgVYpe8kMTLniC/nDGoQg5q0r/NRuTXUNVrY4Kn/B 7lbtAA9ODIaii9+vTXJUgrZvtXpE5irC0XApxO+uvweOn7Ez7xDE3IzMBeWyZGRPLEa9 8uFg== X-Forwarded-Encrypted: i=1; AJvYcCVCe2C3a5DBS1A/dkI3PTP7BrvXr1mnoK4sMmexBbjXvLCoVu7qb9iTSY2twK4tqbu0ekgx2A==@debbugs.gnu.org X-Gm-Message-State: AOJu0YwKlZgCu3/QgZqbdk/m8E2zYD4uF9qwQ0oCCCmCqEKg1KeDLmyB B3S6Qwf5JPziwcDLhvAZPEAPco+DY3Y9SPhdwq24HLnPECW78JjrCeo+ X-Gm-Gg: ASbGnctZ7Ytp8FwOoyYJYb9xonGNVtoGpveYOkdFrrsnSQ2nA0cOeuSyAzYG5gND7dK R08jnM0+oWa20+V91BpXmVZXS2/pqChqY6A0JcaBZFuXH0ZlLBtHAuohrQEL9Jgsb7t0Mdb7vz/ yeHotlMDxDxGFcZ2mV+m0FARbjqTP/33XEP/8I0X9WLmJLmnr2zIXDSW1xmOixZsNYsYz+cx+H4 uBsV5A2WZ1Lv+I8EHlF1yvG0z2FTrLn6gujYELwlWVZjv5gKe6jEKoZMIkiATC+04dOXZJ7D6oW ZpSPhCVCeFw7JPo8ksQyeibYdpBJ39bF99a8AgeaduvXUqs3Metw2eFgj2YRVomM6B53/JTxmtB DVQ+qKMR57Y50mjHhHOa4zPShviTxGfFLgR7VC7jRDNbNJLtyRwi9g482rw== X-Google-Smtp-Source: AGHT+IFJoFUG1a9ytCxZtlCAXgEuAObfJ4FqyPM9Arw52VfMQQX2Moli5nlMAK4OmPVnsB2yFbX9FQ== X-Received: by 2002:a05:6214:19eb:b0:707:621e:6876 with SMTP id 6a1803df08f44-70936378602mr96546316d6.50.1754244967860; Sun, 03 Aug 2025 11:16:07 -0700 (PDT) Received: from moss-4 (206-204-219-242.res.trstrm.net. [206.204.219.242]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-7077ce2944fsm48964526d6.78.2025.08.03.11.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Aug 2025 11:16:07 -0700 (PDT) From: "J.D. Smith" To: Eli Zaretskii Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <861pputdu7.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 02 Aug 2025 09:52:32 +0300") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <861pputdu7.fsf@gnu.org> Date: Sun, 03 Aug 2025 14:16:05 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: philipk@posteo.net, 78995@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: > JD Smith writes: > > Stefan, Eli, any comments on the documentation (or other) parts of this > patch? > >> Some, see below. Thanks. > Can we have a comment here explaining the reason for the use of > autoload-macro? > And maybe here as well? > And here. x 4 I'm not sure what kind of comment you mean. None of the other declare forms are commented, either on definition or on use. Are you thinking of something simple, like "request macro-expansion during autoload generation"? Current patch attached. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=autoload-expand_7.patch Content-Description: autoload-expand with documentation diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index be3c1e78889..269c0ad0026 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2633,6 +2633,12 @@ Declare Form This is typically used for macros, though it works for functions too. @xref{Indenting Macros}. +@cindex @code{autoload-macro} (@code{declare} spec) +@item (autoload-macro @var{value}) +This is used when defining a macro. If @var{value} is @samp{expand}, +any calls to the macro which follow an autoload comment will first be +expanded during generation of the autoloads. @xref{Autoload}. + @item (interactive-only @var{value}) Set the function's @code{interactive-only} property to @var{value}. @xref{The interactive-only property}. diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 750f6e76eff..038aae74caa 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi @@ -708,10 +708,47 @@ Autoload various help functions (@pxref{Help Functions}) display it. If you write a function definition with an unusual macro that is not -one of the known and recognized function definition methods, use of an -ordinary magic autoload comment would copy the whole definition into -@code{loaddefs.el}. That is not desirable. You can put the desired -@code{autoload} call into @code{loaddefs.el} instead by writing this: +one of the known and recognized function definition methods, using an +ordinary magic autoload comment with a call to the macro would require +autoloading the macro definition itself to work. Doing so copies the +whole macro definition into the autoload file. If that is not desired, +you can use the special declare form @code{(autoload-macro expand)} in +your macro definition (@pxref{Declare Form}), instead of autoloading it. +This indicates to the autoload system that calls to your macro following +@samp{;;;###autoload} should be expanded, similar to how the special +functions listed above are handled. For example, a macro which wraps +@code{define-minor-mode} can request expansion, so that proper +@code{autoload} calls for the function it defines are generated. + +@cindex @code{:autoload-end} +The keyword symbol @code{:autoload-end} can be used in the expansion of +a macro to prevent including unwanted forms in the autoload output. Its +presence causes any further elements within the form where it appears to +be silently skipped. For example, if during autoload generation, a +macro's expansion includes: + +@example +(progn + (put my-mode 'visible-prop t) + :autoload-end + (put my-mode 'hidden-prop nil))} +@end example + +the final form (@code{(put my-mode 'hidden-prop nil)}) will not be +copied into the autoload file. + +Note that, if a symbol in the @code{car} of an autoloaded form is found +to be undefined during autoload generation, the file in which the +associated @samp{;;;###autoload} appears will itself be loaded, to give +the macro a chance to be defined. Packages which use special loading +mechanisms, including loading their own @samp{foo-autoload.el} file, +should therefore gracefully handle load errors, since these files may +not yet exist during autoload generation. This can be done, e.g., by +setting the @var{no-error} argument of @code{require} non-@code{nil} +(@pxref{Named Features})). + +Alternatively, instead of expansion, you can put the desired +@code{autoload} call into @file{loaddefs.el} by writing this: @example ;;;###autoload (autoload 'foo "myfile") diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 366423904db..3e521e18567 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -271,6 +271,11 @@ 'byte-run--set-debug (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload-macro + #'(lambda (name _args spec) + (list 'function-put (list 'quote name) + ''autoload-macro (list 'quote spec)))) + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -350,8 +355,10 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + (list 'autoload-macro #'byte-run--set-autoload-macro) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -397,6 +404,7 @@ 'defmacro (if declarations (cons 'prog1 (cons def (car declarations))) def)))))) +(function-put 'defmacro 'autoload-macro 'expand) ; Since we cannot `declare' it ;; Now that we defined defmacro we can use it! (defmacro defun (name arglist &rest body) @@ -409,7 +417,7 @@ defun The return value is undefined. \(fn NAME ARGLIST [DOCSTRING] [DECL] [INTERACTIVE] BODY...)" - (declare (doc-string 3) (indent 2)) + (declare (doc-string 3) (indent 2) (autoload-macro expand)) (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 3aa26fba3c3..4a85d89d5fa 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -258,7 +258,8 @@ cl-defgeneric cl--generic-edebug-make-name in:method] lambda-doc def-body)]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((doc (if (stringp (car-safe options-and-methods)) (pop options-and-methods))) (declarations nil) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2a0a9e5c6de..1b64f106a1b 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -398,7 +398,8 @@ cl-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defun ,name ,@(cl--transform-lambda (cons args body) name))) ;;;###autoload @@ -416,7 +417,8 @@ cl-iter-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) (require 'generator) `(iter-defun ,name ,@(cl--transform-lambda (cons args body) name))) @@ -475,7 +477,8 @@ cl-defmacro (declare (debug (&define name cl-macro-list cl-declarations-or-string def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defmacro ,name ,@(cl--transform-lambda (cons args body) name))) (def-edebug-elem-spec 'cl-lambda-expr @@ -3011,7 +3014,8 @@ cl-defstruct sexp])] [&optional stringp] ;; All the above is for the following def-form. - &rest &or symbolp (symbolp &optional def-form &rest sexp)))) + &rest &or symbolp (symbolp &optional def-form &rest sexp))) + (autoload-macro expand)) (let* ((name (if (consp struct) (car struct) struct)) (warning nil) (opts (cdr-safe struct)) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index f53db48f0b7..0e428abd0b7 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -222,10 +222,11 @@ define-minor-mode (indent defun) (debug (&define name string-or-null-p [&optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp] + &optional [¬ keywordp] sexp + &optional [¬ keywordp] sexp] [&rest [keywordp sexp]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((last-message (make-symbol "last-message")) (mode-name (symbol-name mode)) @@ -487,7 +488,7 @@ define-globalized-minor-mode on if the hook has explicitly disabled it. \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" - (declare (doc-string 2) (indent defun)) + (declare (doc-string 2) (indent defun) (autoload-macro expand)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 344e11e245e..59784ff51e8 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -675,7 +675,8 @@ iter-defun of values. Callers can retrieve each value using `iter-next'." (declare (indent defun) (debug (&define name lambda-list lambda-doc &rest sexp)) - (doc-string 3)) + (doc-string 3) + (autoload-macro expand)) (cl-assert lexical-binding) (let* ((parsed-body (macroexp-parse-body body)) (declarations (car parsed-body)) diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index c015e2b57d0..5acd6f17ee2 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -135,7 +135,7 @@ define-inline This is like `defmacro', but has several advantages. See Info node `(elisp)Defining Functions' for more details." ;; FIXME: How can this work with CL arglists? - (declare (indent defun) (debug defun) (doc-string 3)) + (declare (indent defun) (debug defun) (doc-string 3) (autoload-macro expand)) (let ((doc (if (stringp (car-safe body)) (list (pop body)))) (declares (if (eq (car-safe (car-safe body)) 'declare) (pop body))) (cm-name (intern (format "%s--inliner" name))) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..6a7bbce3908 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -142,12 +142,32 @@ loaddefs-generate--shorten-autoload 3) form)) +;; The following macros are known to define functions, and are treated +;; specially when encountered during autoload generation, translating +;; calls to them into appropriate (autoload function ...) forms. +;; TODO: some macros can be removed from this list once they +;; (declare ((autoload-macro expand) ...) +(defconst loaddefs--defining-macros + '(define-skeleton define-derived-mode + define-compilation-mode define-generic-mode + easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode + easy-mmode-define-minor-mode define-minor-mode + cl-defun defun* cl-defmacro defmacro* + define-overloadable-function + transient-define-prefix transient-define-suffix + transient-define-infix transient-define-argument)) + +(defvar loaddefs--load-error-files nil) (defun loaddefs-generate--make-autoload (form file &optional expansion) "Turn FORM into an autoload or defvar for source file FILE. Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. + +Note that macros can request expansion by including `(autoload-macro +expand)' among their `declare' forms." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -191,35 +211,40 @@ loaddefs-generate--make-autoload (setq form (copy-sequence form)) (setcdr (memq :autoload-end form) nil)) (let ((exps (delq nil (mapcar (lambda (form) - (loaddefs-generate--make-autoload - form file expansion)) + (unless (eq form :autoload-end) + (loaddefs-generate--make-autoload + form file expansion))) (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) - (macrop car) - (setq expand (let ((load-true-file-name file) - (load-file-name file)) - (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) + ;; For macros which request it, try again on their expansion. + ((progn + ;; If the car is an unknown symbol, we load the file first to + ;; give packages a chance to define their macros. + (unless (or (not (symbolp car)) (fboundp car) + ;; Special cases handled below + (memq car loaddefs--defining-macros) + (memq car '(defclass defcustom deftheme defgroup nil)) + (assoc file load-history) + (member file loaddefs--load-error-files)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s (for %s)" file car) + (condition-case e (load file) + (error + (push file loaddefs--load-error-files) ; do not attempt again + (warn "loaddefs-gen: load error\n\t%s" e))))) + (and (macrop car) + (eq 'expand (function-get car 'autoload-macro)) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) + (not (eq car (car expand))))) ;; Recurse on the expansion. (loaddefs-generate--make-autoload expand file 'expansion)) - ;; For special function-like operators, use the `autoload' function. - ((memq car '(define-skeleton define-derived-mode - define-compilation-mode define-generic-mode - easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode - easy-mmode-define-minor-mode define-minor-mode - cl-defun defun* cl-defmacro defmacro* - define-overloadable-function - transient-define-prefix transient-define-suffix - transient-define-infix transient-define-argument)) + ;; For known special macros which define functions, use `autoload' + ;; directly. + ((memq car loaddefs--defining-macros) (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) (name (nth 1 form)) (args (pcase car diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 73554fd66fd..ab8edf1f569 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -537,7 +537,7 @@ pcase-defmacro By convention, DOC should use \"EXPVAL\" to stand for the result of evaluating EXP (first arg to `pcase'). \n(fn NAME ARGS [DOC] &rest BODY...)" - (declare (indent 2) (debug defun) (doc-string 3)) + (declare (indent 2) (debug defun) (doc-string 3) (autoload-macro expand)) ;; Add the function via `fsym', so that an autoload cookie placed ;; on a pcase-defmacro will cause the macro to be loaded on demand. (let ((fsym (intern (format "%s--pcase-macroexpander" name))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 03 14:18:34 2025 Received: (at 78995) by debbugs.gnu.org; 3 Aug 2025 18:18:34 +0000 Received: from localhost ([127.0.0.1]:45699 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uidI1-0000TA-AH for submit@debbugs.gnu.org; Sun, 03 Aug 2025 14:18:34 -0400 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:57522) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uidHx-0000Sr-TO for 78995@debbugs.gnu.org; Sun, 03 Aug 2025 14:18:31 -0400 Received: by mail-qv1-xf2f.google.com with SMTP id 6a1803df08f44-70749eac23dso20885816d6.2 for <78995@debbugs.gnu.org>; Sun, 03 Aug 2025 11:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754245104; x=1754849904; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Mc25jUFtcRzFlhQlMO2YDH6qOqC/4TxO970wCHMbKIg=; b=VBYhXPnK3T5mmxj8aqjdDnPpjqSB6ZCGAz2EoZtJUt69VW6RTXBN4ZsdfR6aucYPq3 wWaOQ4TNGS0tOsbUR0eLfVpb+KzYayGYlBWS8stHRtEHqAZBmOskfmc22ZkQ7GqsnLuY nlah+jQfD1jgW3KV81zo6FHsiiSzTfVr1KlSouSglYyeG0XHpCDyncAJ0mCpSah6Z2xs FdXgU4pu8i8EKAI43owqvPXw2RDjASK+VN3HShldPbDctdsytrOuJ4Vy4lwFJIeua2VE 8eLa3gwFsMNk8QkuL14QcLMrCgVcWSL4JFe+A+2covvNAZLTmAKskzL13RdvHrJjN02r aGEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754245104; x=1754849904; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Mc25jUFtcRzFlhQlMO2YDH6qOqC/4TxO970wCHMbKIg=; b=gcQYtGzfaqJlxZLK+nafVI3WBKfrjOiWe6oivxg4viZjuNpyKuhRJj1PaTZrClMHY4 6BIVKx3ExcUdSbSOBcJ4nr62+m4aPVhtddTOkN0Zwhm3YVEFRoiHXWFBpiSlJ4TQ6h2A jMYVVwJRHhG80dWgDpd5wiGVE4qpyjaJPPR9/emWYE70rENAoHySASpakapZ/u89GKMa Y+cXdINqCamrDjmwj2opKeJlZE/tgb7v+azxyqE7AWJDulPLTC8JG7qGYj8RmOCRyVzB tgiz9WXxxLrGLSMseodstgil26uqQhbp8iG7gtNfeuwBBz9rtPyMaw3JYUVxwW48ohLL 4jiA== X-Gm-Message-State: AOJu0YzPCZs5G5JyhOgzHvPF7WBDV4TDT5bb3hkSjs3Z3VGox3gkJmaF nP6A/6SV8NLBl93ByqHlbQnjJ02rJST9JxBRzy61KgTMRVTMWx/gKcwP836FCA== X-Gm-Gg: ASbGncv1xWNOlQRdWPdcjSY07oE8zX12czwaaCmk4lldwkrTCWm/OYGCcSyedUuYpH+ Mnw7Ym0m65LGcn10W31U9+3dQzEAlcws/ZTuXmU4X+KSp65COB+OQOWluhBbLJrneJtcTVNjtCX Tr5InRllM6OcE8FAX/v/rk6jLgfCZaFnfb+fb+J0t2bioRWzRAtxXUPVgbRrmekbA7Agu9abzb4 2COAbfLWbxxj3qFfAApmzRQiaj5UJFMkK99oJTKazU7pab+a2iPLl47lsCLyuNa1QVKpi3DvxWe ehrsFx8mWEOSa6RpWVXnkejSWUl4HV3kmh51uXs9L6YXHv0LWUAJKsh7sp0BbR53K3yWBVDuzpT 6ZmKW/yX/9ar/JE1jaaLeU7NhFlNti3LnThgIG/6hLX3Xl/9KCuLGXdjdvm3oWcJrUg+w X-Google-Smtp-Source: AGHT+IFRR5n6/lo7vDfbGzK1E4QFfZCcE6il8OnrIMYd8NhP/tvT+gUR4O1mbv731KUIStZSL9nsPA== X-Received: by 2002:a05:6214:e42:b0:707:2220:e077 with SMTP id 6a1803df08f44-70936232b14mr122223346d6.31.1754245104068; Sun, 03 Aug 2025 11:18:24 -0700 (PDT) Received: from moss-4 (206-204-219-242.res.trstrm.net. [206.204.219.242]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-7093dd53d58sm20634356d6.13.2025.08.03.11.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Aug 2025 11:18:23 -0700 (PDT) From: "J.D. Smith" To: Michael Albinus Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <87o6sxfxof.fsf@gmx.de> (Michael Albinus's message of "Sat, 02 Aug 2025 19:20:00 +0200") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> <87bjp1sh2x.fsf@gmx.de> <87a54jgl7a.fsf@gmx.de> <87o6sxfxof.fsf@gmx.de> Date: Sun, 03 Aug 2025 14:18:22 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Michael Albinus writes: > "J.D. Smith" writes: > > Hi, > >> Hmm, I guess `loaddefs-gen' was introduced in emacs 29. But I think you >> don't actually need that `require' at all. Maybe try a simple: >> >> (unless (alist-get 'autoload-macro macro-declarations-alist) >> (push '(autoload-macro ignore) macro-declarations-alist)) > > That works with Emacs 28, if I put these lines before the > tramp--with-startup macro declaration. > > I cannot test with the master branch, because the autoload-macro patch > doesn't seem to be there yet. Great. I will push it soon and then you can test, or feel free to try this patch in the meantime. Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=autoload-expand_7.patch Content-Description: autoload-expand with documentation diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index be3c1e78889..269c0ad0026 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2633,6 +2633,12 @@ Declare Form This is typically used for macros, though it works for functions too. @xref{Indenting Macros}. +@cindex @code{autoload-macro} (@code{declare} spec) +@item (autoload-macro @var{value}) +This is used when defining a macro. If @var{value} is @samp{expand}, +any calls to the macro which follow an autoload comment will first be +expanded during generation of the autoloads. @xref{Autoload}. + @item (interactive-only @var{value}) Set the function's @code{interactive-only} property to @var{value}. @xref{The interactive-only property}. diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 750f6e76eff..038aae74caa 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi @@ -708,10 +708,47 @@ Autoload various help functions (@pxref{Help Functions}) display it. If you write a function definition with an unusual macro that is not -one of the known and recognized function definition methods, use of an -ordinary magic autoload comment would copy the whole definition into -@code{loaddefs.el}. That is not desirable. You can put the desired -@code{autoload} call into @code{loaddefs.el} instead by writing this: +one of the known and recognized function definition methods, using an +ordinary magic autoload comment with a call to the macro would require +autoloading the macro definition itself to work. Doing so copies the +whole macro definition into the autoload file. If that is not desired, +you can use the special declare form @code{(autoload-macro expand)} in +your macro definition (@pxref{Declare Form}), instead of autoloading it. +This indicates to the autoload system that calls to your macro following +@samp{;;;###autoload} should be expanded, similar to how the special +functions listed above are handled. For example, a macro which wraps +@code{define-minor-mode} can request expansion, so that proper +@code{autoload} calls for the function it defines are generated. + +@cindex @code{:autoload-end} +The keyword symbol @code{:autoload-end} can be used in the expansion of +a macro to prevent including unwanted forms in the autoload output. Its +presence causes any further elements within the form where it appears to +be silently skipped. For example, if during autoload generation, a +macro's expansion includes: + +@example +(progn + (put my-mode 'visible-prop t) + :autoload-end + (put my-mode 'hidden-prop nil))} +@end example + +the final form (@code{(put my-mode 'hidden-prop nil)}) will not be +copied into the autoload file. + +Note that, if a symbol in the @code{car} of an autoloaded form is found +to be undefined during autoload generation, the file in which the +associated @samp{;;;###autoload} appears will itself be loaded, to give +the macro a chance to be defined. Packages which use special loading +mechanisms, including loading their own @samp{foo-autoload.el} file, +should therefore gracefully handle load errors, since these files may +not yet exist during autoload generation. This can be done, e.g., by +setting the @var{no-error} argument of @code{require} non-@code{nil} +(@pxref{Named Features})). + +Alternatively, instead of expansion, you can put the desired +@code{autoload} call into @file{loaddefs.el} by writing this: @example ;;;###autoload (autoload 'foo "myfile") diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 366423904db..3e521e18567 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -271,6 +271,11 @@ 'byte-run--set-debug (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload-macro + #'(lambda (name _args spec) + (list 'function-put (list 'quote name) + ''autoload-macro (list 'quote spec)))) + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -350,8 +355,10 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + (list 'autoload-macro #'byte-run--set-autoload-macro) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -397,6 +404,7 @@ 'defmacro (if declarations (cons 'prog1 (cons def (car declarations))) def)))))) +(function-put 'defmacro 'autoload-macro 'expand) ; Since we cannot `declare' it ;; Now that we defined defmacro we can use it! (defmacro defun (name arglist &rest body) @@ -409,7 +417,7 @@ defun The return value is undefined. \(fn NAME ARGLIST [DOCSTRING] [DECL] [INTERACTIVE] BODY...)" - (declare (doc-string 3) (indent 2)) + (declare (doc-string 3) (indent 2) (autoload-macro expand)) (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 3aa26fba3c3..4a85d89d5fa 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -258,7 +258,8 @@ cl-defgeneric cl--generic-edebug-make-name in:method] lambda-doc def-body)]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((doc (if (stringp (car-safe options-and-methods)) (pop options-and-methods))) (declarations nil) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2a0a9e5c6de..1b64f106a1b 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -398,7 +398,8 @@ cl-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defun ,name ,@(cl--transform-lambda (cons args body) name))) ;;;###autoload @@ -416,7 +417,8 @@ cl-iter-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) (require 'generator) `(iter-defun ,name ,@(cl--transform-lambda (cons args body) name))) @@ -475,7 +477,8 @@ cl-defmacro (declare (debug (&define name cl-macro-list cl-declarations-or-string def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) `(defmacro ,name ,@(cl--transform-lambda (cons args body) name))) (def-edebug-elem-spec 'cl-lambda-expr @@ -3011,7 +3014,8 @@ cl-defstruct sexp])] [&optional stringp] ;; All the above is for the following def-form. - &rest &or symbolp (symbolp &optional def-form &rest sexp)))) + &rest &or symbolp (symbolp &optional def-form &rest sexp))) + (autoload-macro expand)) (let* ((name (if (consp struct) (car struct) struct)) (warning nil) (opts (cdr-safe struct)) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index f53db48f0b7..0e428abd0b7 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -222,10 +222,11 @@ define-minor-mode (indent defun) (debug (&define name string-or-null-p [&optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp] + &optional [¬ keywordp] sexp + &optional [¬ keywordp] sexp] [&rest [keywordp sexp]] - def-body))) + def-body)) + (autoload-macro expand)) (let* ((last-message (make-symbol "last-message")) (mode-name (symbol-name mode)) @@ -487,7 +488,7 @@ define-globalized-minor-mode on if the hook has explicitly disabled it. \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" - (declare (doc-string 2) (indent defun)) + (declare (doc-string 2) (indent defun) (autoload-macro expand)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 344e11e245e..59784ff51e8 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -675,7 +675,8 @@ iter-defun of values. Callers can retrieve each value using `iter-next'." (declare (indent defun) (debug (&define name lambda-list lambda-doc &rest sexp)) - (doc-string 3)) + (doc-string 3) + (autoload-macro expand)) (cl-assert lexical-binding) (let* ((parsed-body (macroexp-parse-body body)) (declarations (car parsed-body)) diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index c015e2b57d0..5acd6f17ee2 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -135,7 +135,7 @@ define-inline This is like `defmacro', but has several advantages. See Info node `(elisp)Defining Functions' for more details." ;; FIXME: How can this work with CL arglists? - (declare (indent defun) (debug defun) (doc-string 3)) + (declare (indent defun) (debug defun) (doc-string 3) (autoload-macro expand)) (let ((doc (if (stringp (car-safe body)) (list (pop body)))) (declares (if (eq (car-safe (car-safe body)) 'declare) (pop body))) (cm-name (intern (format "%s--inliner" name))) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..6a7bbce3908 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -142,12 +142,32 @@ loaddefs-generate--shorten-autoload 3) form)) +;; The following macros are known to define functions, and are treated +;; specially when encountered during autoload generation, translating +;; calls to them into appropriate (autoload function ...) forms. +;; TODO: some macros can be removed from this list once they +;; (declare ((autoload-macro expand) ...) +(defconst loaddefs--defining-macros + '(define-skeleton define-derived-mode + define-compilation-mode define-generic-mode + easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode + easy-mmode-define-minor-mode define-minor-mode + cl-defun defun* cl-defmacro defmacro* + define-overloadable-function + transient-define-prefix transient-define-suffix + transient-define-infix transient-define-argument)) + +(defvar loaddefs--load-error-files nil) (defun loaddefs-generate--make-autoload (form file &optional expansion) "Turn FORM into an autoload or defvar for source file FILE. Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. + +Note that macros can request expansion by including `(autoload-macro +expand)' among their `declare' forms." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -191,35 +211,40 @@ loaddefs-generate--make-autoload (setq form (copy-sequence form)) (setcdr (memq :autoload-end form) nil)) (let ((exps (delq nil (mapcar (lambda (form) - (loaddefs-generate--make-autoload - form file expansion)) + (unless (eq form :autoload-end) + (loaddefs-generate--make-autoload + form file expansion))) (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) - (macrop car) - (setq expand (let ((load-true-file-name file) - (load-file-name file)) - (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) + ;; For macros which request it, try again on their expansion. + ((progn + ;; If the car is an unknown symbol, we load the file first to + ;; give packages a chance to define their macros. + (unless (or (not (symbolp car)) (fboundp car) + ;; Special cases handled below + (memq car loaddefs--defining-macros) + (memq car '(defclass defcustom deftheme defgroup nil)) + (assoc file load-history) + (member file loaddefs--load-error-files)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s (for %s)" file car) + (condition-case e (load file) + (error + (push file loaddefs--load-error-files) ; do not attempt again + (warn "loaddefs-gen: load error\n\t%s" e))))) + (and (macrop car) + (eq 'expand (function-get car 'autoload-macro)) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) + (not (eq car (car expand))))) ;; Recurse on the expansion. (loaddefs-generate--make-autoload expand file 'expansion)) - ;; For special function-like operators, use the `autoload' function. - ((memq car '(define-skeleton define-derived-mode - define-compilation-mode define-generic-mode - easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode - easy-mmode-define-minor-mode define-minor-mode - cl-defun defun* cl-defmacro defmacro* - define-overloadable-function - transient-define-prefix transient-define-suffix - transient-define-infix transient-define-argument)) + ;; For known special macros which define functions, use `autoload' + ;; directly. + ((memq car loaddefs--defining-macros) (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) (name (nth 1 form)) (args (pcase car diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 73554fd66fd..ab8edf1f569 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -537,7 +537,7 @@ pcase-defmacro By convention, DOC should use \"EXPVAL\" to stand for the result of evaluating EXP (first arg to `pcase'). \n(fn NAME ARGS [DOC] &rest BODY...)" - (declare (indent 2) (debug defun) (doc-string 3)) + (declare (indent 2) (debug defun) (doc-string 3) (autoload-macro expand)) ;; Add the function via `fsym', so that an autoload cookie placed ;; on a pcase-defmacro will cause the macro to be loaded on demand. (let ((fsym (intern (format "%s--pcase-macroexpander" name))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 03 15:03:12 2025 Received: (at 78995) by debbugs.gnu.org; 3 Aug 2025 19:03:12 +0000 Received: from localhost ([127.0.0.1]:45766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uidzE-0002v2-CR for submit@debbugs.gnu.org; Sun, 03 Aug 2025 15:03:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60178) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uidzC-0002ul-DV for 78995@debbugs.gnu.org; Sun, 03 Aug 2025 15:03:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uidz5-0007hr-VI; Sun, 03 Aug 2025 15:03:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=AYifYRNKQKJdHEOOCi0uqEUw17p246rnI5iSMG5byC8=; b=WLwlP7feyr8J ITvnJKyURaNKHmQsdjWkIAy9VSkPyfgGTb/I38Jb3QHF236vaYT7t1o6PLyRJuEnO0c9xX3+gm7Zu LkfonbBzGdpu1ntGcu68aw//YfmNI2gr6uldWfnc1/PGr/xFoo8UWG5H5CQ5Ylje/5i4H2ExmFDmW UHOa+2YiPvgAsj6E5NLOAJVL5tsyOF7KTvaHPOEHItsVEm7pEUoXHLTXT3qHLymAiNa3+CE6RJ/iS tueWYpQ/h8a/qtfZqumtcQdaCRPO7e6a3ohkbIzFf4ilHMP/vOJ9CttRsD8NhtP1dwsVWrxQD9ff+ b65pCUwT3JoK+b+Meb6ZEQ==; Date: Sun, 03 Aug 2025 22:03:00 +0300 Message-Id: <861ppsxm6z.fsf@gnu.org> From: Eli Zaretskii To: "J.D. Smith" In-Reply-To: (jdtsmith@gmail.com) Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <861pputdu7.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: philipk@posteo.net, 78995@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: "J.D. Smith" > Cc: philipk@posteo.net, 78995@debbugs.gnu.org, monnier@iro.umontreal.ca > Date: Sun, 03 Aug 2025 14:16:05 -0400 > > > Can we have a comment here explaining the reason for the use of > > autoload-macro? > > And maybe here as well? > > And here. x 4 > > I'm not sure what kind of comment you mean. To explain why do we use this declaration there. > None of the other declare > forms are commented, either on definition or on use. This one is much more subtle than the others. > Are you thinking of something simple, like "request macro-expansion > during autoload generation"? No, I mean _why_ we want to request that in those places and not the others. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 03 18:53:47 2025 Received: (at 78995) by debbugs.gnu.org; 3 Aug 2025 22:53:47 +0000 Received: from localhost ([127.0.0.1]:46407 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uihaM-0007ue-Eb for submit@debbugs.gnu.org; Sun, 03 Aug 2025 18:53:47 -0400 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:44118) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uihaJ-0007uQ-90 for 78995@debbugs.gnu.org; Sun, 03 Aug 2025 18:53:44 -0400 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-4aedd1b006bso38293211cf.0 for <78995@debbugs.gnu.org>; Sun, 03 Aug 2025 15:53:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754261617; x=1754866417; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=AmQN+Wou5epCq+XxG8Y1H2V8DI44tSWD/SjV2wnmHgI=; b=UhlY+ycVoHh9sMouA53EbE9VS3JjJc2TDdprlpRfPowrzW4OZ6MqydaNsLDNAV+gYd dUUh7qpFdfJypO97wyNePMF04DdVQfSx3MyeOPhpyYcu49wF5s8+O4WlneCxCU7Nih2E /cZ6HWKVoVF4Y/Cv35m1Jp6ay7M1kzMzrXL6hlXsmxpuBV1ACmZAMyEsxS6ZTOlLIGMk CuHOezJQPA2CnpTuYu1+VITtmSjVX3R7G05Bj0uIqNhcLhYk2upjznpkKj7gxIQocBzi L37X73qr7h17D8Zk3mx1uZUrqeSfnWdr5/MDZU4kLj/PbquzVihyP4S8iQnDqaJjlgkv m1mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754261617; x=1754866417; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AmQN+Wou5epCq+XxG8Y1H2V8DI44tSWD/SjV2wnmHgI=; b=KRQPKop5emdfE7GaKgYG3hBsjk8sHgdt72HA29oC51PzlvWZkseOsAO7xMQCq/qZo5 PrT1rojHRO12CX9gObB6ldSS0kKZr5WdwOy7b05WLYiMbPldGEdqKwJp2qr/9lbKVJEl mhUDeKtxqDiYn+7hzc1CSrRGvU9sKseXXQ2lGnWum8TuKg9o9fmiQ/QREXIY+LNtr0vC gd9vNeftTKLvvymM4gkXsMZIBnMwK8o5zS9mk5Xm4czFm54lIR6l+5lxIh+0a1nQ7TLs T3X/7ZEnW3SInZHXQHGYbdFdv7kOFO3nnVOpQrkHBzzQWnCKvK/B3udaApGeZmIX9Pad 5XDg== X-Forwarded-Encrypted: i=1; AJvYcCXPHjDnLEh4DF1UbnsXlZQtjqUDATtZ7qF1OU+Z51IZhwxGgiAbHuPy9BRQOmneCbCBcywigA==@debbugs.gnu.org X-Gm-Message-State: AOJu0YygMdUNGTBxenR5tsPLjGpEbfGHnZwvRavKSj7II1j4Fak2AMbo 2vyLRdpQdCCHtScIKHIHSiKFWjcw5F9YqG8bJtJnASVeKZEhKEXlL/AB X-Gm-Gg: ASbGncshvwbOVh+EQj6MFhooBReNziUsiwLNjSUIuoGIJx2GlGZ2nbpq5Dit53BNZRC hDoEjZcesNaCd81p21KxlQhPjeEj5omujxFmY54wIYEY+zIDEJYQTNWh+VOGu7tJZLHZ8FiLzsv 7zOIniolg/qRgUQOV934DO0InIq8eRnzc/Oa7SyXoAHkAKPd8ViZVPtqroBghbKTgHIu9oS7pHj TpFyaCPBWSQ9PKpuU/mytX4Yov1ir9CIKOpzuTMG5GvQm/2YwYZ1cgJy/UflMi/k3yrWsp8INrg aotzIDnoN4sVY7Ps3VMTbPL9xHhfcTExOKpfDQqp0YLZpTt3jwB3jELd3hqhAoKhNssgoRqHxDa TWynzGhoqfqLczV+arqZT32Cd3V6d/rMMICAz6fWwgSr1/nVgLjB9UsPpVA== X-Google-Smtp-Source: AGHT+IFHRQVGllVdlP19aDO4oz5TppIdjO/DV/PHPyruL+TN3J+M081m5a+k67kRC7/rCrhdLPCT3Q== X-Received: by 2002:ae9:f716:0:b0:7e3:52f6:66e5 with SMTP id af79cd13be357-7e69636b143mr671531885a.35.1754261617273; Sun, 03 Aug 2025 15:53:37 -0700 (PDT) Received: from moss-4 (206-204-219-242.res.trstrm.net. [206.204.219.242]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e69e15f5e0sm160771985a.69.2025.08.03.15.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Aug 2025 15:53:36 -0700 (PDT) From: "J.D. Smith" To: Eli Zaretskii Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <861ppsxm6z.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 03 Aug 2025 22:03:00 +0300") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <861pputdu7.fsf@gnu.org> <861ppsxm6z.fsf@gnu.org> Date: Sun, 03 Aug 2025 18:53:34 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: philipk@posteo.net, 78995@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: "J.D. Smith" >> Cc: philipk@posteo.net, 78995@debbugs.gnu.org, monnier@iro.umontreal.ca >> Date: Sun, 03 Aug 2025 14:16:05 -0400 >>=20 >> > Can we have a comment here explaining the reason for the use of >> > autoload-macro? >> > And maybe here as well? >> > And here. x 4 >>=20 >> I'm not sure what kind of comment you mean. > > To explain why do we use this declaration there. > >> Are you thinking of something simple, like "request macro-expansion >> during autoload generation"? > > No, I mean _why_ we want to request that in those places and not the > others. The short but unsatisfying answer is to preserve the hard-coded list of macros to expand, which this functionality replaces and extends. The former explanation in `loaddefs-generate--make-autoload' was quite terse: ;; For complex cases, try again on the macro-expansion. I've tried to inject a short explanation everywhere this declaration is used. I left the `byte-run--set-autoload-macro' alone, since that's just a generic property setter, and values other than `expand' may be used in the future. Latest patch below. Meta-comments: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Though outside of the scope of this patch, a few mildly bothersome attributes remain, which I leave here for posterity. 1. It's somewhat arbitrary which macros request expansion Eventually, I think for all builtin macros, the question should be asked: "Will calls to this macro likely be marked ;;;###autoload"? If the answer is yes, the macro should declare `autoload-macro=3Dexpand', so that these calls get recursively expanded down to their most basic forms =E2=80=94 `defalias', `put', and so on. 2. Some autoloaded macro expansions are not "autoload-hygienic". Some macros currently /rely/ on skipping directly to `(autoload name ...)' generation via the hard-coded "short-cut" list (see `loaddefs--defining-macros'). I.e. they do not expect to be expanded, and are therefore not autoload-hygenic in their expansion (e.g. neglecting to use `:autoload-end' to elide unwanted forms, for example). This is confusing and prone to bugs (e.g. the bug discovered in this thread related to the MODES arg). 3. Some macros' autoload treatment depend on whether they are defined at autoload-generation time. Such macros are both on the short-cut list /and/ request expansion. So they are expanded, but only if they are defined at the time autoload generation occurs. Most are, but some, e.g. cl-macs, are not. So they go through the "short-cut" instead. IMO, these macros should either have their expansion cleaned up for autoload hygiene (if necessary) and be pre-loaded during autoload generation, or they should just not request expansion at all. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=autoload-expand_8.patch Content-Description: autoload-expand with documentation diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index be3c1e78889..269c0ad0026 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2633,6 +2633,12 @@ Declare Form This is typically used for macros, though it works for functions too. @xref{Indenting Macros}. +@cindex @code{autoload-macro} (@code{declare} spec) +@item (autoload-macro @var{value}) +This is used when defining a macro. If @var{value} is @samp{expand}, +any calls to the macro which follow an autoload comment will first be +expanded during generation of the autoloads. @xref{Autoload}. + @item (interactive-only @var{value}) Set the function's @code{interactive-only} property to @var{value}. @xref{The interactive-only property}. diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 750f6e76eff..038aae74caa 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi @@ -708,10 +708,47 @@ Autoload various help functions (@pxref{Help Functions}) display it. If you write a function definition with an unusual macro that is not -one of the known and recognized function definition methods, use of an -ordinary magic autoload comment would copy the whole definition into -@code{loaddefs.el}. That is not desirable. You can put the desired -@code{autoload} call into @code{loaddefs.el} instead by writing this: +one of the known and recognized function definition methods, using an +ordinary magic autoload comment with a call to the macro would require +autoloading the macro definition itself to work. Doing so copies the +whole macro definition into the autoload file. If that is not desired, +you can use the special declare form @code{(autoload-macro expand)} in +your macro definition (@pxref{Declare Form}), instead of autoloading it. +This indicates to the autoload system that calls to your macro following +@samp{;;;###autoload} should be expanded, similar to how the special +functions listed above are handled. For example, a macro which wraps +@code{define-minor-mode} can request expansion, so that proper +@code{autoload} calls for the function it defines are generated. + +@cindex @code{:autoload-end} +The keyword symbol @code{:autoload-end} can be used in the expansion of +a macro to prevent including unwanted forms in the autoload output. Its +presence causes any further elements within the form where it appears to +be silently skipped. For example, if during autoload generation, a +macro's expansion includes: + +@example +(progn + (put my-mode 'visible-prop t) + :autoload-end + (put my-mode 'hidden-prop nil))} +@end example + +the final form (@code{(put my-mode 'hidden-prop nil)}) will not be +copied into the autoload file. + +Note that, if a symbol in the @code{car} of an autoloaded form is found +to be undefined during autoload generation, the file in which the +associated @samp{;;;###autoload} appears will itself be loaded, to give +the macro a chance to be defined. Packages which use special loading +mechanisms, including loading their own @samp{foo-autoload.el} file, +should therefore gracefully handle load errors, since these files may +not yet exist during autoload generation. This can be done, e.g., by +setting the @var{no-error} argument of @code{require} non-@code{nil} +(@pxref{Named Features})). + +Alternatively, instead of expansion, you can put the desired +@code{autoload} call into @file{loaddefs.el} by writing this: @example ;;;###autoload (autoload 'foo "myfile") diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 366423904db..48562b8a36b 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -271,6 +271,12 @@ 'byte-run--set-debug (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload-macro + #'(lambda (name _args spec) + (list 'function-put (list 'quote name) + ''autoload-macro (list 'quote spec))) + "Handle autoload-macro declarations") + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -350,8 +356,13 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + ;; macros can declare (autoload-macro expand) to request expansion + ;; during autoload generation of forms calling them. See + ;; `loaddefs-generate--make-autoload'. + (list 'autoload-macro #'byte-run--set-autoload-macro) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -397,6 +408,8 @@ 'defmacro (if declarations (cons 'prog1 (cons def (car declarations))) def)))))) +;; Expand to defalias and related forms on autoload gen +(function-put 'defmacro 'autoload-macro 'expand) ; Since we cannot `declare' it ;; Now that we defined defmacro we can use it! (defmacro defun (name arglist &rest body) @@ -409,7 +422,9 @@ defun The return value is undefined. \(fn NAME ARGLIST [DOCSTRING] [DECL] [INTERACTIVE] BODY...)" - (declare (doc-string 3) (indent 2)) + (declare (doc-string 3) (indent 2) + ;; Expand to defalias on autoload gen + (autoload-macro expand)) (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 3aa26fba3c3..b5da24be2fe 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -258,7 +258,9 @@ cl-defgeneric cl--generic-edebug-make-name in:method] lambda-doc def-body)]] - def-body))) + def-body)) + ;; Expand to defun and related forms on autoload definition + (autoload-macro expand)) (let* ((doc (if (stringp (car-safe options-and-methods)) (pop options-and-methods))) (declarations nil) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2a0a9e5c6de..617991308b6 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -398,7 +398,9 @@ cl-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + ;; expand to function definition on autoload gen + (autoload-macro expand)) `(defun ,name ,@(cl--transform-lambda (cons args body) name))) ;;;###autoload @@ -416,7 +418,9 @@ cl-iter-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + ;; expand (eventually) to function definition on autoload gen + (autoload-macro expand)) (require 'generator) `(iter-defun ,name ,@(cl--transform-lambda (cons args body) name))) @@ -475,7 +479,8 @@ cl-defmacro (declare (debug (&define name cl-macro-list cl-declarations-or-string def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) ; expand to defmacro on autoload gen `(defmacro ,name ,@(cl--transform-lambda (cons args body) name))) (def-edebug-elem-spec 'cl-lambda-expr @@ -3011,7 +3016,9 @@ cl-defstruct sexp])] [&optional stringp] ;; All the above is for the following def-form. - &rest &or symbolp (symbolp &optional def-form &rest sexp)))) + &rest &or symbolp (symbolp &optional def-form &rest sexp))) + ;; expand to function definitions and related forms on autoload gen + (autoload-macro expand)) (let* ((name (if (consp struct) (car struct) struct)) (warning nil) (opts (cdr-safe struct)) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index f53db48f0b7..ff96a7afac6 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -222,10 +222,12 @@ define-minor-mode (indent defun) (debug (&define name string-or-null-p [&optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp] + &optional [¬ keywordp] sexp + &optional [¬ keywordp] sexp] [&rest [keywordp sexp]] - def-body))) + def-body)) + ;; expand to the command definition on autoload gen + (autoload-macro expand)) (let* ((last-message (make-symbol "last-message")) (mode-name (symbol-name mode)) @@ -487,7 +489,9 @@ define-globalized-minor-mode on if the hook has explicitly disabled it. \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" - (declare (doc-string 2) (indent defun)) + (declare (doc-string 2) (indent defun) + ;; expand to the minor-mode definition on autoload gen + (autoload-macro expand)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 344e11e245e..c01e559fd5c 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -675,7 +675,8 @@ iter-defun of values. Callers can retrieve each value using `iter-next'." (declare (indent defun) (debug (&define name lambda-list lambda-doc &rest sexp)) - (doc-string 3)) + (doc-string 3) + (autoload-macro expand)) ; expand to the defun on autoload gen (cl-assert lexical-binding) (let* ((parsed-body (macroexp-parse-body body)) (declarations (car parsed-body)) diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index c015e2b57d0..027c24c465b 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -135,7 +135,8 @@ define-inline This is like `defmacro', but has several advantages. See Info node `(elisp)Defining Functions' for more details." ;; FIXME: How can this work with CL arglists? - (declare (indent defun) (debug defun) (doc-string 3)) + (declare (indent defun) (debug defun) (doc-string 3) + (autoload-macro expand)) ; expand to the defun on autoload gen (let ((doc (if (stringp (car-safe body)) (list (pop body)))) (declares (if (eq (car-safe (car-safe body)) 'declare) (pop body))) (cm-name (intern (format "%s--inliner" name))) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..6a7bbce3908 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -142,12 +142,32 @@ loaddefs-generate--shorten-autoload 3) form)) +;; The following macros are known to define functions, and are treated +;; specially when encountered during autoload generation, translating +;; calls to them into appropriate (autoload function ...) forms. +;; TODO: some macros can be removed from this list once they +;; (declare ((autoload-macro expand) ...) +(defconst loaddefs--defining-macros + '(define-skeleton define-derived-mode + define-compilation-mode define-generic-mode + easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode + easy-mmode-define-minor-mode define-minor-mode + cl-defun defun* cl-defmacro defmacro* + define-overloadable-function + transient-define-prefix transient-define-suffix + transient-define-infix transient-define-argument)) + +(defvar loaddefs--load-error-files nil) (defun loaddefs-generate--make-autoload (form file &optional expansion) "Turn FORM into an autoload or defvar for source file FILE. Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. + +Note that macros can request expansion by including `(autoload-macro +expand)' among their `declare' forms." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -191,35 +211,40 @@ loaddefs-generate--make-autoload (setq form (copy-sequence form)) (setcdr (memq :autoload-end form) nil)) (let ((exps (delq nil (mapcar (lambda (form) - (loaddefs-generate--make-autoload - form file expansion)) + (unless (eq form :autoload-end) + (loaddefs-generate--make-autoload + form file expansion))) (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) - (macrop car) - (setq expand (let ((load-true-file-name file) - (load-file-name file)) - (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) + ;; For macros which request it, try again on their expansion. + ((progn + ;; If the car is an unknown symbol, we load the file first to + ;; give packages a chance to define their macros. + (unless (or (not (symbolp car)) (fboundp car) + ;; Special cases handled below + (memq car loaddefs--defining-macros) + (memq car '(defclass defcustom deftheme defgroup nil)) + (assoc file load-history) + (member file loaddefs--load-error-files)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s (for %s)" file car) + (condition-case e (load file) + (error + (push file loaddefs--load-error-files) ; do not attempt again + (warn "loaddefs-gen: load error\n\t%s" e))))) + (and (macrop car) + (eq 'expand (function-get car 'autoload-macro)) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) + (not (eq car (car expand))))) ;; Recurse on the expansion. (loaddefs-generate--make-autoload expand file 'expansion)) - ;; For special function-like operators, use the `autoload' function. - ((memq car '(define-skeleton define-derived-mode - define-compilation-mode define-generic-mode - easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode - easy-mmode-define-minor-mode define-minor-mode - cl-defun defun* cl-defmacro defmacro* - define-overloadable-function - transient-define-prefix transient-define-suffix - transient-define-infix transient-define-argument)) + ;; For known special macros which define functions, use `autoload' + ;; directly. + ((memq car loaddefs--defining-macros) (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) (name (nth 1 form)) (args (pcase car diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 73554fd66fd..5e85ab4f075 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -537,7 +537,9 @@ pcase-defmacro By convention, DOC should use \"EXPVAL\" to stand for the result of evaluating EXP (first arg to `pcase'). \n(fn NAME ARGS [DOC] &rest BODY...)" - (declare (indent 2) (debug defun) (doc-string 3)) + (declare (indent 2) (debug defun) (doc-string 3) + ;; Expand to defun and related forms on autoload gen + (autoload-macro expand)) ;; Add the function via `fsym', so that an autoload cookie placed ;; on a pcase-defmacro will cause the macro to be loaded on demand. (let ((fsym (intern (format "%s--pcase-macroexpander" name))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 03 19:17:25 2025 Received: (at 78995) by debbugs.gnu.org; 3 Aug 2025 23:17:25 +0000 Received: from localhost ([127.0.0.1]:46473 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uihxF-0000vc-2N for submit@debbugs.gnu.org; Sun, 03 Aug 2025 19:17:25 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:57595) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uihxC-0000vE-EF for 78995@debbugs.gnu.org; Sun, 03 Aug 2025 19:17:24 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 43E1680AEB; Sun, 3 Aug 2025 19:17:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1754263034; bh=TEo6XM8GpLWZ0JyaccR9U0HIV050bjn9yZNwUlE6DQs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=SD5cHeBDjcW55NrpNeBIW4hzn5XYP38VfHnsCmSp7XW/68tuk+OCN8JtyKe0SqtR4 emlvtcmzmVaS7+UvIy8GJFdSl9a6NEFHxDNOIqk9FpqALqGKbgvrRh/7+fgi6Ycrze dkuDJulYUvCo0U106jiuR/3QDDs+A6VcTw7acVTyrmmZNnZwgD+3wfHDTwIvGKKDLE sAMjAKELT4MY5WCuIDyVVPvW+sK1u1bMogVe4BOdzEjyWTWKtzwMxy9qWgE+Hwe2zE sKo47s/GhS8CNMzCfgo5G1OrXtB944iAEUEDe4U0jZ3POu8+3qmwhSdX9FVDUqP0HE BJgf6oQvw47ig== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C873C805DC; Sun, 3 Aug 2025 19:17:14 -0400 (EDT) Received: from pastel (unknown [108.175.226.132]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9477B12067A; Sun, 3 Aug 2025 19:17:14 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <861pputdu7.fsf@gnu.org> <861ppsxm6z.fsf@gnu.org> Date: Sun, 03 Aug 2025 19:17:12 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.225 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: Eli Zaretskii , 78995@debbugs.gnu.org, philipk@posteo.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > The short but unsatisfying answer is to preserve the hard-coded list > of macros to expand, which this functionality replaces and extends. > The former explanation in `loaddefs-generate--make-autoload' was quite > terse: > > ;; For complex cases, try again on the macro-expansion. The reason is always that calls to these macros don't want to be *preloaded* but only to be *autoloaded*. By expanding the macro, `autoload.el` (aka `loaddefs-gen.el`) gets to see the underlying `defalias` and friends necessary to figure out *how* to autoload it. In practice this means it's used for macros which define functions (or macros). > I've tried to inject a short explanation everywhere this declaration > is used. I left the `byte-run--set-autoload-macro' alone, since > that's just a generic property setter, and values other than `expand' > may be used in the future. Latest patch below. > > Meta-comments: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > Though outside of the scope of this patch, a few mildly bothersome > attributes remain, which I leave here for posterity. > > 1. It's somewhat arbitrary which macros request expansion > > Eventually, I think for all builtin macros, the question should be > asked: "Will calls to this macro likely be marked ;;;###autoload"? > If the answer is yes, the macro should declare > `autoload-macro=3Dexpand', so that these calls get recursively expanded > down to their most basic forms =E2=80=94 `defalias', `put', and so on. It's a judgment call: will it be more common to *preload* or to *autoload*? > 2. Some autoloaded macro expansions are not "autoload-hygienic". > 3. Some macros' autoload treatment depend on whether they are defined > at autoload-generation time. I hope your patch will help us fix those issues. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 04 08:52:26 2025 Received: (at 78995) by debbugs.gnu.org; 4 Aug 2025 12:52:26 +0000 Received: from localhost ([127.0.0.1]:49669 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiufy-0003F5-52 for submit@debbugs.gnu.org; Mon, 04 Aug 2025 08:52:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47104) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uiufu-0003Eh-Bt for 78995@debbugs.gnu.org; Mon, 04 Aug 2025 08:52:23 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uiufd-0007nJ-8G; Mon, 04 Aug 2025 08:52:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Vstm1d2EBi3W5yQbNalNh/m9MAuNOqOUzBkk0ViyVK0=; b=THb+9fr3RCt8 JdA82DgoyUhHdnG7YZwG8erxn+0IMlopnyfnm+9nvcJcg4gEf1DHG5YLaQBDyOMtF5Q3tZ0frdgkp A/9WHgxr83K6tktsrRmo0bWGwxVd11xxBBfjQ2sqhq0z8SWO1ku2t9gYcK3SLwPdQwtXrWNwLVVX6 8v7agt8409FrORdGaEbLIcpjNAIeQ1YcimBnHiQURj30rc2Tyy0TY9O6bF5Dv5ThZrgAvcYz/ay6I TdO7OY5lOgvYzz1RCwrTpPRnPUG4py3ky3b4noMgJqZLh5/8AzL6WwVBJeYrZIREKVzT9U9JuAuzG /nLRJxmmQ+HlBRvC4dgLog==; Date: Mon, 04 Aug 2025 15:51:47 +0300 Message-Id: <86ms8fw8po.fsf@gnu.org> From: Eli Zaretskii To: "J.D. Smith" In-Reply-To: (jdtsmith@gmail.com) Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <861pputdu7.fsf@gnu.org> <861ppsxm6z.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: philipk@posteo.net, 78995@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: "J.D. Smith" > Cc: philipk@posteo.net, 78995@debbugs.gnu.org, monnier@iro.umontreal.ca > Date: Sun, 03 Aug 2025 18:53:34 -0400 > > > No, I mean _why_ we want to request that in those places and not the > > others. > > The short but unsatisfying answer is to preserve the hard-coded list of > macros to expand, which this functionality replaces and extends. The > former explanation in `loaddefs-generate--make-autoload' was quite > terse: > > ;; For complex cases, try again on the macro-expansion. > > I've tried to inject a short explanation everywhere this declaration is > used. I left the `byte-run--set-autoload-macro' alone, since that's > just a generic property setter, and values other than `expand' may be > used in the future. Latest patch below. This is much better (thanks!), but I think we need to improve it some more by saying in the manual that this declaration is an alternative to hard-coding macros in loaddefs--defining-macros in loaddefs-gen.el. > +the final form (@code{(put my-mode 'hidden-prop nil)}) will not be Long forms like the above should be wrapped in @w{..}, to prevent them from being broken between two lines. > +copied into the autoload file. "autoloads file", I guess? > +Note that, if a symbol in the @code{car} of an autoloaded form is found > +to be undefined during autoload generation, the file in which the > +associated @samp{;;;###autoload} appears will itself be loaded, to give > +the macro a chance to be defined. Packages which use special loading > +mechanisms, including loading their own @samp{foo-autoload.el} file, "foo" should be in @var, since it isn't a literal "foo". I'd even use @file{@var{package}-loaddefs.el} instead (note the use of @file). > +;; The following macros are known to define functions, and are treated > +;; specially when encountered during autoload generation, translating > +;; calls to them into appropriate (autoload function ...) forms. > +;; TODO: some macros can be removed from this list once they > +;; (declare ((autoload-macro expand) ...) I'd prefer to say explicitly that autoload-macro is the alternative used so as to keep this list as short as possible. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 04 11:21:52 2025 Received: (at 78995) by debbugs.gnu.org; 4 Aug 2025 15:21:53 +0000 Received: from localhost ([127.0.0.1]:52419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uix0Z-0003VM-Kl for submit@debbugs.gnu.org; Mon, 04 Aug 2025 11:21:52 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:56424) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uix0V-0003Uz-KJ for 78995@debbugs.gnu.org; Mon, 04 Aug 2025 11:21:49 -0400 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-7e809baeef7so19717585a.0 for <78995@debbugs.gnu.org>; Mon, 04 Aug 2025 08:21:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754320902; x=1754925702; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=2z09LxHhdmXB+EQ6W0vl78Wq9uJLkTtSs0+qyPqJvtA=; b=hqiw6rAQCHDO2UgVTCfn77O8Y2jeFYwY55zw/ViAeHpua3iQRZplQlVUP179X/zMpM DMWs3dUjUjl0mlog7BYjKefFC6sD1jYAt1LQAUeEPWW5YpdN+41sXW7H5wXOxY4l/QIG EfmLadIbqG8YhhV+REcJKoVHNoo3QfYcNOMn5CuimeamBGet6uXvm62dp506u0cgsyhT rN/nSezCMApI3qTKJKdeRXSSyjHkT0VJ+SiUL51VeDfEpzKSwPdRoMHnLB8xUTIvee+X QKxEsYfZ9iWaJhDOo4k32kvR3ywYlUYbQIn4zRX3Emy7ki60UohLdWP9qq8m8guDnudx 3wzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754320902; x=1754925702; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2z09LxHhdmXB+EQ6W0vl78Wq9uJLkTtSs0+qyPqJvtA=; b=aHRTA7okT3J92Fm2dCSqq7aFh96/LIyVs8mxQufy+aztecOIFPFOBjEiAnJs6jJ79I adk+t8Rf512tfyu/KuSK/Wk0szslBuD4o8gaKixWzRNsH2j3xfeqYQNzwaw+POPsj0ra cy2zVVA1J2ayWjHU+htuRnfVsCt4Wfy5L80TaB/02uDwmQRcQCyqJvVpXQkzHotcexaC ZXTJ6ySlRKQJmaKDnaiY70t6yG09ypJQ5d2bQc3XiymsHujbpeoPvnEKY5cyNM2U2rjH AmY27zxLSxlQB9wksA1QhoZEl4YEJucK+ZioX59vhiwC1Vbm2ajdXorXQZkzx70f3xrz LCPw== X-Forwarded-Encrypted: i=1; AJvYcCXUzQX1JMJrIIeNI60tNBR75U15obbeMHdXFDHdzlhp+xLVnGRzXkxSxmMZdPgJvdWAV9F7uQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yyn4dwNnawetwxTzV4b3a1d5NptdeIGUEWF/cf29gbV9giA1f32 qVyLjF5+MAYBVhtl/Y12Z5pbts/1KiV+Zy3Ju5zYILy3Q5BUmzVuLxYT X-Gm-Gg: ASbGncvo6eEzZ12xoY1Mql16aX8whXC85gvDRLKCzwyD1UHih8f2OOybhSIG11oKmoW QOJIK3GlXKReinuBkdKwom4ETTkWuOo/FdgLp10M6XQY5fE6S+4aXVRwSb82VWUodyajEhjzcwG J0Y4hpDtg76fu5OZIR2F2Wv+Wh6v8hU0sSkZYR4OUa4mglkPRzj8Org4ZCsBy00QNHvJdnD+Q3D bPhoE9pD4aM0CE9KktaJiAuYc4DHEDD887ukHdBVIIqPOwP2H29bmPbNSONDhbfCTFd6stAaCTr Pmc0anWE0NJ5SE4Z7qmvvS3UxFZ2fYEEPdpT2YAM+0ZHEqRFkGihbzCZ+idEE4xQl+Af3GBSv0g QRaKNFltLXL3MmC9UeXWE5JlTJ1i2IKnZGfetQxnDjffXV4GdNtH+T0lfI8ft1MbbxhxW X-Google-Smtp-Source: AGHT+IHLbapLJin7tv4GcNu9qyR7ZI9Jbiu8NGIbQyAUmER/zXuv8Us337E6mNc8uWo/fojVOPUpng== X-Received: by 2002:a05:6214:e42:b0:707:2220:e077 with SMTP id 6a1803df08f44-70936232b14mr169460896d6.31.1754320901539; Mon, 04 Aug 2025 08:21:41 -0700 (PDT) Received: from moss-4 (206-204-219-242.res.trstrm.net. [206.204.219.242]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-7077c9d8affsm59044336d6.5.2025.08.04.08.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Aug 2025 08:21:40 -0700 (PDT) From: "J.D. Smith" To: Eli Zaretskii Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <86ms8fw8po.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 04 Aug 2025 15:51:47 +0300") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <861pputdu7.fsf@gnu.org> <861ppsxm6z.fsf@gnu.org> <86ms8fw8po.fsf@gnu.org> Date: Mon, 04 Aug 2025 11:21:39 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: philipk@posteo.net, 78995@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: "J.D. Smith" >> Cc: philipk@posteo.net, 78995@debbugs.gnu.org, monnier@iro.umontreal.ca >> Date: Sun, 03 Aug 2025 18:53:34 -0400 >> >> > No, I mean _why_ we want to request that in those places and not the >> > others. >> >> The short but unsatisfying answer is to preserve the hard-coded list of >> macros to expand, which this functionality replaces and extends. The >> former explanation in `loaddefs-generate--make-autoload' was quite >> terse: >> >> ;; For complex cases, try again on the macro-expansion. >> >> I've tried to inject a short explanation everywhere this declaration is >> used. I left the `byte-run--set-autoload-macro' alone, since that's >> just a generic property setter, and values other than `expand' may be >> used in the future. Latest patch below. > > This is much better (thanks!), but I think we need to improve it some > more by saying in the manual that this declaration is an alternative > to hard-coding macros in loaddefs--defining-macros in loaddefs-gen.el. OK, I have implemented these doc suggestions and a few other minor improvements in the attached. I've also tried to make a somewhat unclear situation w.r.t. the hard-coded macro lists more clear in the comments. `loaddefs--defining-macros' is the "shortcut" list for turning a function-defining macro directly into an (autoload ..) form, whereas (autoload-macro expand) replaced a /different/ list of macros: those to be expanded. So there where 2 main hard-coded lists, and now there is 1. The lists are closely related, because usually a macro expands into one or more of the shortcut forms. I conjecture (but have not verified), that ALL hard-coded lists of macros can eventually be removed, save some very basic primitives like defalias (and defmacro?). Whether that's desirable is less clear. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=autoload-expand_9.patch Content-Description: autoload-expand with documentation diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index be3c1e78889..be6f9507dbe 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -2633,6 +2633,14 @@ Declare Form This is typically used for macros, though it works for functions too. @xref{Indenting Macros}. +@cindex @code{autoload-macro} (@code{declare} spec) +@item (autoload-macro @var{value}) +This is used when defining a macro. If @var{value} is @samp{expand}, +any calls to the macro which follow an autoload comment will first be +expanded during generation of the autoloads. This declaration is used +as an alternative to hard-coding lists of macros to expand in +@code{loaddefs-generate--make-autoload}. @xref{Autoload}. + @item (interactive-only @var{value}) Set the function's @code{interactive-only} property to @var{value}. @xref{The interactive-only property}. diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi index 750f6e76eff..a6e1c4385d1 100644 --- a/doc/lispref/loading.texi +++ b/doc/lispref/loading.texi @@ -645,10 +645,12 @@ Autoload The same magic comment can copy any kind of form into @file{loaddefs.el}. The form following the magic comment is copied -verbatim, @emph{except} if it is one of the forms which the autoload -facility handles specially (e.g., by conversion into an -@code{autoload} call). The forms which are not copied verbatim are -the following: +verbatim, unless it is a form which the autoload facility handles +specially, by conversion directly into an @code{autoload} call, or by +recursively expanding the macro. Any macro can request expansion of +autoloads which call it during generation; @xref{autoload-macro expand}. + +The following forms are handled specially: @table @asis @item Definitions for function or function-like objects: @@ -664,8 +666,11 @@ Autoload @item Other definition types: @code{defcustom}, @code{defgroup}, @code{deftheme}, @code{defclass} -(@pxref{Top,EIEIO,,eieio,EIEIO}), and @code{define-skeleton} -(@pxref{Top,Autotyping,,autotype,Autotyping}). +(@pxref{Top,EIEIO,,eieio,EIEIO}), @code{define-skeleton} +(@pxref{Top,Autotyping,,autotype,Autotyping}), +@code{transient-define-prefix}, @code{transient-define-suffix}, +@code{transient-define-infix}, and @code{transient-define-argument} +(@pxref{TOP,Transient,,transient,Transient User and Developer Manual}). @end table You can also use a magic comment to execute a form at build time @@ -707,11 +712,50 @@ Autoload documentation string is replaced with the function's name when the various help functions (@pxref{Help Functions}) display it. +@anchor{autoload-macro expand} If you write a function definition with an unusual macro that is not -one of the known and recognized function definition methods, use of an -ordinary magic autoload comment would copy the whole definition into -@code{loaddefs.el}. That is not desirable. You can put the desired -@code{autoload} call into @code{loaddefs.el} instead by writing this: +one of the known and recognized function definition methods, using an +ordinary magic autoload comment with a call to the macro would require +autoloading the macro definition itself to work. Doing so copies the +whole macro definition into the autoload file. If that is not desired, +you can use the special declare form @code{(autoload-macro expand)} in +your macro definition (@pxref{Declare Form}), instead of autoloading it. +This indicates to the autoload system that calls to your macro following +@samp{;;;###autoload} should be expanded, similar to how the special +functions listed above are handled. For example, a macro which wraps +@code{define-minor-mode} can request expansion, so that proper +@code{autoload} calls for the function it defines are generated. + +@cindex @code{:autoload-end} +The keyword symbol @code{:autoload-end} can be used in the expansion of +a macro to prevent including unwanted forms in the autoload output. Its +presence causes any further elements within the form where it appears to +be silently skipped. For example, if during autoload generation, a +macro's expansion includes: + +@example +(progn + (put my-mode 'visible-prop t) + :autoload-end + (put my-mode 'hidden-prop nil)) +@end example + +@noindent +the final form (@w{@code{(put my-mode 'hidden-prop nil)}}) will not be +copied into the autoload file. + +Note that, if a symbol in the @code{car} of an autoloaded form is found +to be undefined during autoload generation, the file in which the +associated @samp{;;;###autoload} appears will itself be loaded, to give +the macro a chance to be defined. Packages which use special loading +mechanisms, including loading their own @file{@var{package}-loaddefs.el} +file, should therefore gracefully handle load errors, since these files +may not yet exist during autoload generation. This can be done, e.g., +by setting the @var{no-error} argument of @code{require} non-@code{nil} +(@pxref{Named Features})). + +Alternatively, instead of expansion, you can put the desired +@code{autoload} call into @file{loaddefs.el} by writing this: @example ;;;###autoload (autoload 'foo "myfile") diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 366423904db..48562b8a36b 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -271,6 +271,12 @@ 'byte-run--set-debug (list 'put (list 'quote name) ''edebug-form-spec (list 'quote spec))))) +(defalias 'byte-run--set-autoload-macro + #'(lambda (name _args spec) + (list 'function-put (list 'quote name) + ''autoload-macro (list 'quote spec))) + "Handle autoload-macro declarations") + (defalias 'byte-run--set-no-font-lock-keyword #'(lambda (name _args val) (list 'function-put (list 'quote name) @@ -350,8 +356,13 @@ macro-declarations-alist (cons (list 'debug #'byte-run--set-debug) (cons - (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) - defun-declarations-alist)) + ;; macros can declare (autoload-macro expand) to request expansion + ;; during autoload generation of forms calling them. See + ;; `loaddefs-generate--make-autoload'. + (list 'autoload-macro #'byte-run--set-autoload-macro) + (cons + (list 'no-font-lock-keyword #'byte-run--set-no-font-lock-keyword) + defun-declarations-alist))) "List associating properties of macros to their macro expansion. Each element of the list takes the form (PROP FUN) where FUN is a function. For each (PROP . VALUES) in a macro's declaration, the FUN corresponding @@ -397,6 +408,8 @@ 'defmacro (if declarations (cons 'prog1 (cons def (car declarations))) def)))))) +;; Expand to defalias and related forms on autoload gen +(function-put 'defmacro 'autoload-macro 'expand) ; Since we cannot `declare' it ;; Now that we defined defmacro we can use it! (defmacro defun (name arglist &rest body) @@ -409,7 +422,9 @@ defun The return value is undefined. \(fn NAME ARGLIST [DOCSTRING] [DECL] [INTERACTIVE] BODY...)" - (declare (doc-string 3) (indent 2)) + (declare (doc-string 3) (indent 2) + ;; Expand to defalias on autoload gen + (autoload-macro expand)) (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 3aa26fba3c3..b5da24be2fe 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -258,7 +258,9 @@ cl-defgeneric cl--generic-edebug-make-name in:method] lambda-doc def-body)]] - def-body))) + def-body)) + ;; Expand to defun and related forms on autoload definition + (autoload-macro expand)) (let* ((doc (if (stringp (car-safe options-and-methods)) (pop options-and-methods))) (declarations nil) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2a0a9e5c6de..617991308b6 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -398,7 +398,9 @@ cl-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + ;; expand to function definition on autoload gen + (autoload-macro expand)) `(defun ,name ,@(cl--transform-lambda (cons args body) name))) ;;;###autoload @@ -416,7 +418,9 @@ cl-iter-defun [&optional ("interactive" interactive)] def-body)) (doc-string 3) - (indent 2)) + (indent 2) + ;; expand (eventually) to function definition on autoload gen + (autoload-macro expand)) (require 'generator) `(iter-defun ,name ,@(cl--transform-lambda (cons args body) name))) @@ -475,7 +479,8 @@ cl-defmacro (declare (debug (&define name cl-macro-list cl-declarations-or-string def-body)) (doc-string 3) - (indent 2)) + (indent 2) + (autoload-macro expand)) ; expand to defmacro on autoload gen `(defmacro ,name ,@(cl--transform-lambda (cons args body) name))) (def-edebug-elem-spec 'cl-lambda-expr @@ -3011,7 +3016,9 @@ cl-defstruct sexp])] [&optional stringp] ;; All the above is for the following def-form. - &rest &or symbolp (symbolp &optional def-form &rest sexp)))) + &rest &or symbolp (symbolp &optional def-form &rest sexp))) + ;; expand to function definitions and related forms on autoload gen + (autoload-macro expand)) (let* ((name (if (consp struct) (car struct) struct)) (warning nil) (opts (cdr-safe struct)) diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index f53db48f0b7..ff96a7afac6 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -222,10 +222,12 @@ define-minor-mode (indent defun) (debug (&define name string-or-null-p [&optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp - &optional [¬ keywordp] sexp] + &optional [¬ keywordp] sexp + &optional [¬ keywordp] sexp] [&rest [keywordp sexp]] - def-body))) + def-body)) + ;; expand to the command definition on autoload gen + (autoload-macro expand)) (let* ((last-message (make-symbol "last-message")) (mode-name (symbol-name mode)) @@ -487,7 +489,9 @@ define-globalized-minor-mode on if the hook has explicitly disabled it. \(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)" - (declare (doc-string 2) (indent defun)) + (declare (doc-string 2) (indent defun) + ;; expand to the minor-mode definition on autoload gen + (autoload-macro expand)) (let* ((global-mode-name (symbol-name global-mode)) (mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode)) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index 344e11e245e..c01e559fd5c 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -675,7 +675,8 @@ iter-defun of values. Callers can retrieve each value using `iter-next'." (declare (indent defun) (debug (&define name lambda-list lambda-doc &rest sexp)) - (doc-string 3)) + (doc-string 3) + (autoload-macro expand)) ; expand to the defun on autoload gen (cl-assert lexical-binding) (let* ((parsed-body (macroexp-parse-body body)) (declarations (car parsed-body)) diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el index c015e2b57d0..027c24c465b 100644 --- a/lisp/emacs-lisp/inline.el +++ b/lisp/emacs-lisp/inline.el @@ -135,7 +135,8 @@ define-inline This is like `defmacro', but has several advantages. See Info node `(elisp)Defining Functions' for more details." ;; FIXME: How can this work with CL arglists? - (declare (indent defun) (debug defun) (doc-string 3)) + (declare (indent defun) (debug defun) (doc-string 3) + (autoload-macro expand)) ; expand to the defun on autoload gen (let ((doc (if (stringp (car-safe body)) (list (pop body)))) (declares (if (eq (car-safe (car-safe body)) 'declare) (pop body))) (cm-name (intern (format "%s--inliner" name))) diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 0f136df1fe2..6ec600fea91 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -142,12 +142,37 @@ loaddefs-generate--shorten-autoload 3) form)) +;; The following macros are known to define functions, and are treated +;; specially when encountered during autoload generation, translating +;; calls to them directly into appropriate (autoload function ...) +;; forms. +;; +;; An alternative to appearing on this list is for a macro to declare +;; (autoload-macro expand), so calls to it get expanded into more basic +;; forms during generation. Macros may be removed from this list once +;; they request such expansion and produce suitable output (e.g. by +;; employing :autoload-end to omit unneeded forms). +(defconst loaddefs--defining-macros + '(define-skeleton define-derived-mode + define-compilation-mode define-generic-mode + easy-mmode-define-global-mode define-global-minor-mode + define-globalized-minor-mode + easy-mmode-define-minor-mode define-minor-mode + cl-defun defun* cl-defmacro defmacro* + define-overloadable-function + transient-define-prefix transient-define-suffix + transient-define-infix transient-define-argument)) + +(defvar loaddefs--load-error-files nil) (defun loaddefs-generate--make-autoload (form file &optional expansion) "Turn FORM into an autoload or defvar for source file FILE. Returns nil if FORM is not a special autoload form (i.e. a function definition or macro definition or a defcustom). If EXPANSION is non-nil, we're processing the macro expansion of an -expression, in which case we want to handle forms differently." +expression, in which case we want to handle forms differently. + +Note that macros can request expansion by including `(autoload-macro +expand)' among their `declare' forms." (let ((car (car-safe form)) expand) (cond ((and expansion (eq car 'defalias)) @@ -191,35 +216,40 @@ loaddefs-generate--make-autoload (setq form (copy-sequence form)) (setcdr (memq :autoload-end form) nil)) (let ((exps (delq nil (mapcar (lambda (form) - (loaddefs-generate--make-autoload - form file expansion)) + (unless (eq form :autoload-end) + (loaddefs-generate--make-autoload + form file expansion))) (cdr form))))) (when exps (cons 'progn exps))))) - ;; For complex cases, try again on the macro-expansion. - ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode defun defmacro - easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric - cl-defstruct pcase-defmacro iter-defun cl-iter-defun)) - (macrop car) - (setq expand (let ((load-true-file-name file) - (load-file-name file)) - (macroexpand form))) - (memq (car expand) '(progn prog1 defalias))) + ;; For macros which request it, try again on their expansion. + ((progn + ;; If the car is an unknown symbol, we load the file first to + ;; give packages a chance to define their macros. + (unless (or (not (symbolp car)) (fboundp car) + ;; Special cases handled below + (memq car loaddefs--defining-macros) + (memq car '(defclass defcustom deftheme defgroup nil)) + (assoc file load-history) + (member file loaddefs--load-error-files)) + (let ((load-path (cons (file-name-directory file) load-path))) + (message "loaddefs-gen: loading file %s (for %s)" file car) + (condition-case e (load file) + (error + (push file loaddefs--load-error-files) ; do not attempt again + (warn "loaddefs-gen: load error\n\t%s" e))))) + (and (macrop car) + (eq 'expand (function-get car 'autoload-macro)) + (setq expand (let ((load-true-file-name file) + (load-file-name file)) + (macroexpand form))) + (not (eq car (car expand))))) ;; Recurse on the expansion. (loaddefs-generate--make-autoload expand file 'expansion)) - ;; For special function-like operators, use the `autoload' function. - ((memq car '(define-skeleton define-derived-mode - define-compilation-mode define-generic-mode - easy-mmode-define-global-mode define-global-minor-mode - define-globalized-minor-mode - easy-mmode-define-minor-mode define-minor-mode - cl-defun defun* cl-defmacro defmacro* - define-overloadable-function - transient-define-prefix transient-define-suffix - transient-define-infix transient-define-argument)) + ;; For known special macros which define functions, use `autoload' + ;; directly. + ((memq car loaddefs--defining-macros) (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*))) (name (nth 1 form)) (args (pcase car diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index 73554fd66fd..5e85ab4f075 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -537,7 +537,9 @@ pcase-defmacro By convention, DOC should use \"EXPVAL\" to stand for the result of evaluating EXP (first arg to `pcase'). \n(fn NAME ARGS [DOC] &rest BODY...)" - (declare (indent 2) (debug defun) (doc-string 3)) + (declare (indent 2) (debug defun) (doc-string 3) + ;; Expand to defun and related forms on autoload gen + (autoload-macro expand)) ;; Add the function via `fsym', so that an autoload cookie placed ;; on a pcase-defmacro will cause the macro to be loaded on demand. (let ((fsym (intern (format "%s--pcase-macroexpander" name))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 05 03:12:56 2025 Received: (at 78995) by debbugs.gnu.org; 5 Aug 2025 07:12:56 +0000 Received: from localhost ([127.0.0.1]:53506 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujBqy-0001or-Fa for submit@debbugs.gnu.org; Tue, 05 Aug 2025 03:12:56 -0400 Received: from mout.gmx.net ([212.227.17.22]:40327) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujBqt-0001oa-Jw for 78995@debbugs.gnu.org; Tue, 05 Aug 2025 03:12:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1754377964; x=1754982764; i=michael.albinus@gmx.de; bh=whJpw3aoRo3jaC2CwEVtG77P4GdMtp6vhP/+IHzeW0s=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=ZvZCbGFfKg3WjLcXjaY/vjNAXB5BzIz3o5DbMurVtAyjoPuL6u0GqahThfeWY6S5 MKFyPcKF4tmRwy3vy22/arW7HwQBh/Y8rp/Udv8tTng32FO+0FrHiDvU++lKWRvnh FNAy6I9co7Pdxc5Vb92UTslhHI63O0zB4Qg4fat8j2JYCe8r7Ty7a6sEoIcBw6Xfq f1KBYki5MRApswx+HfMblsAR1zUQSyc9Yu0wfuS3CwZ+V1/OnSp6kNALKFQmu3CbP PgcqtFvylbykOzTy5ZJXty9AofWTfxmBpWqOeEgh0iv3fxdV5nUkaBQrwz61ujIqK 8XetaNE+6erfTJ6L5Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.61]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mt757-1uTRHZ0cPZ-00wJIi; Tue, 05 Aug 2025 09:12:44 +0200 From: Michael Albinus To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <861pputdu7.fsf@gnu.org> <861ppsxm6z.fsf@gnu.org> <86ms8fw8po.fsf@gnu.org> Date: Tue, 05 Aug 2025 09:12:42 +0200 Message-ID: <874iumdyxh.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:KcHnUUDopoX656g53Byl6RzPPwpfevoIgXA8cBxCjH3CFffTbja uStBmUUj7+AIlx9wpn4oikiIgFDuL5m80q3gLA7wPt9r9ayYn+MvnUsEa3M9xC/2V2QPSjr ODVPGtpVNz2sDspqGgEMH3dsy7Rrbz+H5jbvsczrKWeQhYX0oYVHeVBwlEMu1XgsVgb4l0u lMWrqI2pvOeqauWD2+Q7w== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:3TGClhsMatU=;Caydl2G4dv8w5G1hzAQJYnlja81 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 EOUxw/msFJRCYkwnkm4ont9awuJtXbb0= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78995 Cc: Eli Zaretskii , 78995@debbugs.gnu.org, philipk@posteo.net, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) "J.D. Smith" writes: Hi, > OK, I have implemented these doc suggestions and a few other minor > improvements in the attached. I've also tried to make a somewhat > unclear situation w.r.t. the hard-coded macro lists more clear in the > comments. Pls don't forget the Tramp change in your patch. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 05 09:13:47 2025 Received: (at 78995) by debbugs.gnu.org; 5 Aug 2025 13:13:48 +0000 Received: from localhost ([127.0.0.1]:54093 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujHUB-0007xx-Ie for submit@debbugs.gnu.org; Tue, 05 Aug 2025 09:13:47 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:53296) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ujHU9-0007xY-K5 for 78995@debbugs.gnu.org; Tue, 05 Aug 2025 09:13:46 -0400 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-7dfc604107eso453691285a.2 for <78995@debbugs.gnu.org>; Tue, 05 Aug 2025 06:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754399620; x=1755004420; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=8ZTvedS7awItle5lAauv+Rn2ubK5PmUiyXPE+lywf3w=; b=ZhRC9JesdIf3tv34GaK3pGRq11+l8QVdwIB6WkdwFWMtnUvwG6jU1OK7VRYbJtNmfE xhacuQ5NPkxYzOTS76pCNQ7qx40vS5gCP7O2L9zfETBjjk8LJvhrT15SQw/rxFoDVsYx cj7qmVEaIEtAeS3Facfwj1j3HNH+lehgc69rAIKsRYakxGiAmuiWjed+21udiI2y+XyN c8plLrBRQqXyal04IbET3rfqaCEeuI2h+C0ONY3CLQUxyLUjdPDkuNJeQu4e6m+bQqVX D4eMzWIQznurX//ucl+0+kSo9VFN2Ywg7LF8+uMuivPnpHi/KSwnRHbgqwhZbqCu3oiJ zwEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754399620; x=1755004420; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8ZTvedS7awItle5lAauv+Rn2ubK5PmUiyXPE+lywf3w=; b=Z6EpexTDTaid6F5Ue7PQVtPsbT/p66apxprD3a7iBwksUaUh/bUThrYbK9FyXkYouH 30Z9MYrGA4rbXe2mVVDGUZ6C3uuwue2ReB8lOarahE5NCGkPbRh5Fmi9eCG47AjE8h14 1Onc6DcOI+QwZWoI/v3LIobdm8uAmJpTuusqXk0qULJvhr+Oy8xUHdiuMmV9Q6Ma5ybi FVWR8qGuV3ppW4aWqMaTwTT/sbk7budiR6Aw45zWiWhiHshzY0Ls02Zoc2U7qdgcfook jBB4d1uEBJPtaArsJIO3g0J4SPaiM8xYkR4cnZ71tK7nkFmEKj3X4b3nMcgfvw3x/c5M HDWA== X-Forwarded-Encrypted: i=1; AJvYcCXY8HPT2pg/bYIcZSYB5CXspi/e22zAPGzERNbzklAHT6ACqc9FYGUYCNo6RDGi63rvemNU/w==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzkvWsWHtJhtD/1eHkaupEtFfDCff9cijac/V3+u5YTO78ms6Gp 93mUOA1K8+lPZOkbsfEVSAuLVMOx5ZvyiZXHG79NLOcSMc4KlkRzFJDK X-Gm-Gg: ASbGnctciuBMXv2QkyLqhKLoEuAmwIgIem9I9Vz/PasJnYLqbyylDzyCZY00QrfF2na jREJB0MQ4cXZKptVc4z/ZK3pA4xnyjHb1eKj5pvsMxKcXnvzlCpnEUHcb9yNGs7CzpeKiJAn/8g YNGKO3xPxN27fBd2mJMddxpPbJ5uNmXNQ1KtQOTuT5FoLb+f4fwplOHlyE9DETzZHxLmfzVBvpE 7jFIgk6Kv504jloxKn4ybmNwXsWaZMVkAwzPW1XnHPwUq3YcYpKvEUf4o0Z370H4soSZfgjWter pVQ/p4Eg3Ag9aWNVvg3RfUWLCFq+tYi7NW1qQbxRcSJl0JB9EKR6Y8V7q9VZbOdnMgBEmJeprGx VeKwGSRjtD51QadicfnSlaZkjeFoN1PS8LrLEOMEvMoqHfhyunSSIm/wZWA== X-Google-Smtp-Source: AGHT+IH8m2y7mxLoMErxRDktpH4cweWeHHACVOXztf9PqSLleVy/38d6MWrOXkxOe28EvFq+ctcL+Q== X-Received: by 2002:a05:620a:560f:b0:7e6:440f:50b5 with SMTP id af79cd13be357-7e6962682bbmr1650492585a.11.1754399619664; Tue, 05 Aug 2025 06:13:39 -0700 (PDT) Received: from moss-4 (206-204-219-242.res.trstrm.net. [206.204.219.242]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e802190e86sm224520685a.25.2025.08.05.06.13.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Aug 2025 06:13:39 -0700 (PDT) From: "J.D. Smith" To: Michael Albinus Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <874iumdyxh.fsf@gmx.de> (Michael Albinus's message of "Tue, 05 Aug 2025 09:12:42 +0200") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <861pputdu7.fsf@gnu.org> <861ppsxm6z.fsf@gnu.org> <86ms8fw8po.fsf@gnu.org> <874iumdyxh.fsf@gmx.de> Date: Tue, 05 Aug 2025 09:13:37 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: Eli Zaretskii , 78995@debbugs.gnu.org, philipk@posteo.net, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael Albinus writes: > > Pls don't forget the Tramp change in your patch. There are definitely builtin packages that can/should be updated as a result of this new functionality, e.g. transient. But I don't think those changes should be part of this patch, because it's sensible to get the basic capability in place for people to test before adapting other packages. That said, TRAMP may be a special case because of the "chicken-and-egg" problem represented by tramp-loaddefs.el, and the error generated by attempting to load that file before it exists. For now just setting NOERROR when requiring tramp-loaddefs might be the right approach. Stefan, what do you think a good approach is for packages which want to start declaring autoload-macro expand in some of their macros, but /also/ want to support earlier versions of emacs? I can't think of an approach other than each such package including: (unless (alist-get 'autoload-macro macro-declarations-alist) (push '(autoload-macro ignore) macro-declarations-alist)) somewhere. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 10 17:23:41 2025 Received: (at 78995) by debbugs.gnu.org; 10 Aug 2025 21:23:41 +0000 Received: from localhost ([127.0.0.1]:46174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ulDW1-0000L5-1y for submit@debbugs.gnu.org; Sun, 10 Aug 2025 17:23:41 -0400 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]:55504) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ulDVw-0000Kp-LN for 78995@debbugs.gnu.org; Sun, 10 Aug 2025 17:23:38 -0400 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-e8e11af0f54so2424807276.2 for <78995@debbugs.gnu.org>; Sun, 10 Aug 2025 14:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754861011; x=1755465811; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ICh+PjC+3M0XL8f264/cNeyH5gzsYnAcPJJza40M+a8=; b=LOFbU64VqALLU3BmTtDgVrUsU6QOUc0ACwLucJp7KCDUIBPnqcNNH3x1S8Bm2s0LNR 8IqXvxcjp1RBp1fVnlWRGW+1pKCf1dYNUWXl/6zckbZLcxfcAn5agQsnp1VGsD6ZGD8i k7FF5g7j1wNIRFkTC5D6meI4qtYrAIrF80RWG6Kqf3F1EBwCU47P6i8hoauhAuQedELk ztTggOlsNqfoO5/+T8iJ9JKn94SeQK+K46c3XZUV85lqHffaPJpECSnctu7Jd+qRK0Jb vzDPHZ/qHsPAmmLUaPmlO2zAYfnmTMvYYG0lVNWrHJJgwqgIxxw3j4kty0AS05Xn0I/E eACw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754861011; x=1755465811; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ICh+PjC+3M0XL8f264/cNeyH5gzsYnAcPJJza40M+a8=; b=M4MOy0IVNHbsmqEY+qgDlUzPENxiD7CF71flXAJGQNHQxTPkYorobC1ctmRB4N6rPp b4GuIen59FCBM2htHQ5TA7SRPlmehgiVf2P3vNrBV28WVcPbQsaEeOTLNFvMIM442Ugv 0qyC19ap1gAaQ7HyGWTeoj23jRbQj9Bl5mMuwOsLqv0wVAWOD5/HosBhLXEO213RepFm XTG6rJ3ceLMVpFQWMBbUAAzyUZcpcbto7mBAO7dFByeOIB5c7jF951CGlb3e+f2a3JdZ tUiP4vrLTEgAduLNXTtKUcNR1n3LN/1nLiba79MqtsS2MuhL3ZXzJJpvuxIf7trunKXV DxCg== X-Forwarded-Encrypted: i=1; AJvYcCWhcuZJcnIbYbIg5jpeF0SDOtyR8Z7/EEIdrBiAJ5rXrJpWx9GbNlcmsR5sabcnxMTJ835UDw==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yxl31eTstfMxRv3WN1r+uXaGpMvCrmhgUp1PhMsNT2qMN4Ystnn U8TXaFUW/jRDSiQaK5tuUmPmrZS1Vlrwovh85BjRV0nUm9mj9FrtLxDw X-Gm-Gg: ASbGncucTYhMaO30pPKfLRBW9CbW3dl1Jj43AT2U+EbqINUbr0bVMpj9bSGWyoLVP+n YbkNhjsp8pVz9gA6KdcUN/RqP52PPGdQIUqeIp1b9dRUuCbEKlw9Taz/QoqFeMC7S8tSalv1Y0X bNvBZv7MdNxHRi8oKNH+1O26Bnb5Un7n7WOfw+WS0JPEvJtfe5f8Ke6w+/VpQyg0GjKLR0+7A81 PlKhgvI2ZdE5GMARW3ZJCIBamTrz2zzKSY3jOgsg/UMaymuNm3S593ftxEW2pAcnTS/bxmdhmUE +nxP2oHDKWCtkAKsk27BslaWqF5sSvKYRmyK1wY5zktWUvcwDcPbcNwJVSU5PjFYOaZnlJYil4e 2Tgp3BI+BjItg24Rp87JRTRDt9YEQcwP0lh57WUsAYkyrpJ4Q0uge X-Google-Smtp-Source: AGHT+IHzITF8AGv5EBqeP7LBSuZ36ANcAyTyGtRNtIimkGn2LaHhoj6h4QeENgPFl4U9B7yZdQT/mQ== X-Received: by 2002:a05:6902:6109:b0:e8e:1ccd:6a4e with SMTP id 3f1490d57ef6-e904b4b81bcmr11921946276.19.1754861010838; Sun, 10 Aug 2025 14:23:30 -0700 (PDT) Received: from Mac (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e8fd3713f97sm9116280276.9.2025.08.10.14.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 14:23:30 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Sun, 03 Aug 2025 19:17:12 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <861pputdu7.fsf@gnu.org> <861ppsxm6z.fsf@gnu.org> Date: Sun, 10 Aug 2025 17:23:29 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: Eli Zaretskii , 78995@debbugs.gnu.org, philipk@posteo.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> 1. It's somewhat arbitrary which macros request expansion >> >> Eventually, I think for all builtin macros, the question should be >> asked: "Will calls to this macro likely be marked ;;;###autoload"? >> If the answer is yes, the macro should declare >> `autoload-macro=3Dexpand', so that these calls get recursively expanded >> down to their most basic forms =E2=80=94 `defalias', `put', and so on. > > It's a judgment call: will it be more common to *preload* or to > *autoload*? I suppose an argument for preloading a macro's definition and copying in ;;;###autoload calls to it is if it 1) is very long and involved and cannot be reduced to a small number of expanded forms, and 2) is autoloaded many times, thus bloating the autoload file. The only other scenario I can imagine is if it relies on information that is not yet known at compile time, but which is known reliably at load time (network address on emacs start?). But I'm not aware of any such builtin macros. What other preload uses am I missing? Unless there are any more thoughts on this patch I'll give it a last look over and apply to master. I'll patch TRAMP in a separate commit. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 10 17:41:47 2025 Received: (at 78995) by debbugs.gnu.org; 10 Aug 2025 21:41:48 +0000 Received: from localhost ([127.0.0.1]:46194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ulDnX-0001Cu-Gr for submit@debbugs.gnu.org; Sun, 10 Aug 2025 17:41:47 -0400 Received: from mail-yb1-xb35.google.com ([2607:f8b0:4864:20::b35]:56402) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ulDnU-0001Ca-Te for 78995@debbugs.gnu.org; Sun, 10 Aug 2025 17:41:45 -0400 Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-e906924b33eso595780276.0 for <78995@debbugs.gnu.org>; Sun, 10 Aug 2025 14:41:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754862098; x=1755466898; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=A2j1Gfd1Jk7YuF8DpZddwwJw0MgcYQ275YXf2Epws5A=; b=GtjVNWpRAMqJ7iC7Dr55BmvjiVeYAjU2Fhg4jSrIioXKNqEwMZzRv97XOaC5f4Q3sx ZygpHNEA2hB3gDbQWmiNLpRp5tq03Epy7fZclmwVX7IhLfVIGsVNK2j1h6HOuYemZIhb SwT6ucwsAmPsyYSDnXj5pEihwU5p+eoDfEvP2h07AYgb1mmQsFR48E01geb1dVuvwvmL tXvxhT8LIikYzbwgrml/OJLLhbCv3ZeqZQjqHkPWxiOnJDj63qCkoooTCA7mbM9W5f3/ Z5dJgv9lWC/1FZzGt5+0xVKivdgEd1txJGIY0jVravMxsEoQqlozacBpgChm/m5j09xo k7BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754862098; x=1755466898; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=A2j1Gfd1Jk7YuF8DpZddwwJw0MgcYQ275YXf2Epws5A=; b=WxvAEMZL/1YN1khjow3nQXWIDGSq4IzVism7IxbBJjqIaWm7KYW/pOr/TAFilXs/2Q HVvdgs7fLlkoFfliMdWFzhfkasNOs8NzuGb9RbXTOJbBNLY+4dXgb/yysPmDNEOwpyiA M9QVDd+EpVrWGEOAdwkjtCdYTzN1mfvGh1IY1aYjhNIl+TiXbBBsWo0E0Bd/X0BF/6VN VXVH1zjbhphqZbULLV/B8Y7mG4ejryEmqiIl1bY0rEsyIz3LytMngX2Q5Ao1sWwQe01a cMLip+pdNhm1oeR0a69nVH5MP9+R98fyI6PZNLoggQK/cw8fUPlL/+gYvhedQnOq4ioK le0g== X-Gm-Message-State: AOJu0YwtLL9EShYgBQm3+yE7wGg8pquloQLQQM8nfvItG7ETBF8RRQVE fkstX8OEf5uVI6cT1M9Z8lIQnRd2UX9xKbY8o9nO5pd9VQraDbWySaPsKb4u3Q== X-Gm-Gg: ASbGnculvDLRH3M9Luxz4cZeAzIgqesHO4brChAiWZILgXCBRuDRz8lkkvLHZpOPxtn 1Pma3G3zDvsohCt/UdhhfmbfYFQvpWwn/uhOpKL/gwYcKIJyCgqUFd0mO66jvXptI48buy8qggV YTWasIZWiTeHi3dfdkSXi86CVcvmxF3yHCUDgLT4btfiRiN5c+w+j5tEoKrTUl1np7NfyaE0G9z UKgMIv4xNmF/LVqp5ID0xQDOIcswJ5XJnCVQkichvP2mZnodFYGgXFTfLt4sqoQj4JCnUGlFik8 UAky/pcHY5TYYDFUTte6cGnMpvQy+uz2hAbJ69PGwAlkZ/BqO3APZQtViHoBqa+fJncHyHoSpHO ftrz7oPziIDA0J6V/rbaMJ/ZgTQdmqEuo1Gj+AbnpYvooPXFQY62c X-Google-Smtp-Source: AGHT+IGURdDgKusKOBpDioJ8shQgVvDuwvopKc9jcYGYVYo+hb9X7H1a86aZMVg3VjrAPG+JYyUzwA== X-Received: by 2002:a05:6902:4183:b0:e90:4483:d0c2 with SMTP id 3f1490d57ef6-e904b69a9a9mr10547260276.47.1754862098461; Sun, 10 Aug 2025 14:41:38 -0700 (PDT) Received: from Mac (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e900475e270sm6328097276.16.2025.08.10.14.41.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Aug 2025 14:41:37 -0700 (PDT) From: "J.D. Smith" To: Michael Albinus Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (J. D. Smith's message of "Sun, 03 Aug 2025 14:18:22 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> <87bjp1sh2x.fsf@gmx.de> <87a54jgl7a.fsf@gmx.de> <87o6sxfxof.fsf@gmx.de> Date: Sun, 10 Aug 2025 17:41:37 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain "J.D. Smith" writes: > Michael Albinus writes: > >> "J.D. Smith" writes: >> >> Hi, >> >>> Hmm, I guess `loaddefs-gen' was introduced in emacs 29. But I think you >>> don't actually need that `require' at all. Maybe try a simple: >>> >>> (unless (alist-get 'autoload-macro macro-declarations-alist) >>> (push '(autoload-macro ignore) macro-declarations-alist)) >> >> That works with Emacs 28, if I put these lines before the >> tramp--with-startup macro declaration. >> >> I cannot test with the master branch, because the autoload-macro patch >> doesn't seem to be there yet. > > Great. I will push it soon and then you can test, or feel free to try > this patch in the meantime. Here's an updated patch to try with TRAMP, to see if it works as expected in both old and new Emacs versions. Note that there are many places where TRAMP does something more advanced, like: ;;;###tramp-autoload (when (featurep 'dbusbind) (tramp--with-startup (dolist (method tramp-gvfs-methods) ... so I think you'll need to keep autoloading the macro definition too. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=tramp-autoload-macro-expand.patch Content-Description: Tramp autoload-macro expand patch diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index c1fb8ceaa80..9549bb8bcea 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -29,7 +29,7 @@ ;;; Code: -(require 'tramp-loaddefs) +(require 'tramp-loaddefs nil t) ; guard against load during autoload gen (require 'ansi-color) (require 'auth-source) (require 'format-spec) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index e0e080021c7..f9d15216d5d 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -103,8 +103,15 @@ tramp-completion-file-name-regexp (put 'tramp--startup-hook 'tramp-suppress-trace t) + ;; TODO: once (autoload-macro expand) is available in all supported + ;; Emacs versions, this can be eliminated: + ;; backward compatibility for autoload-macro declare form + (unless (assq 'autoload-macro macro-declarations-alist) + (push '(autoload-macro ignore) macro-declarations-alist)) + (defmacro tramp--with-startup (&rest body) "Schedule BODY to be executed at the end of tramp.el." + (declare (autoload-macro expand)) `(add-hook 'tramp--startup-hook (lambda () ,@body))) (eval-and-compile --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 17 05:50:22 2025 Received: (at 78995) by debbugs.gnu.org; 17 Aug 2025 09:50:22 +0000 Received: from localhost ([127.0.0.1]:45324 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1una1t-0006mt-PO for submit@debbugs.gnu.org; Sun, 17 Aug 2025 05:50:22 -0400 Received: from mout.gmx.net ([212.227.15.18]:59233) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1una1q-0006i2-Qh for 78995@debbugs.gnu.org; Sun, 17 Aug 2025 05:50:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1755424212; x=1756029012; i=michael.albinus@gmx.de; bh=J6orN7GHAQ7vV9GFM7wl1YhYhxWhvfTroFKS2a5p2UM=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=CU0jP7qR4LgXICHb08Lch/b723AUQRrQMIbzlQLcX0wc5BAaPLu9TzyqwB5EPp6S tQaKZB2c8Z6dMyPBmCeLWJvg3pG0SCyAA6O0ZHFa93vJLM/zzJtWj+zAvWP1VAxvh 8VkY2TfxyGxotnvButr7hYUsUtbe6mc7o/lS+tyzzQmKNYUs+rlRx2Xns8SbahbG3 zVwbSrbzd/tiABTZOsbMnHmElEf4W//7uLRFvP7xPekiSZh03SiaXWgoDK3l1OrmW 3QMH9QouNFyTu8Qn7HT6BRpSV2ePLeSf4HtQayVGNmtfh3JdpFxFAULr7meF7tSDw RL1juDvJaTvxcSSUCQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.61]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MgvrL-1uLgnB0ejN-00dxzh; Sun, 17 Aug 2025 11:50:12 +0200 From: Michael Albinus To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> <87bjp1sh2x.fsf@gmx.de> <87a54jgl7a.fsf@gmx.de> <87o6sxfxof.fsf@gmx.de> Date: Sun, 17 Aug 2025 11:50:10 +0200 Message-ID: <87y0ri9t0t.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:2eRO5nXIxwDHgRN1X8YWbG8Z8uVdnc6qcNePC+es1JD9Pm9HFoE dPKJ0ADCf2FuwqG6SYW+LIv1l6cJDBX6lpDI92TJE5ztK4enQXGXMCwXClrix/yBhcebSPg TQrD1QzaFPaMY4yJsDs5CNPs2e/OUEvvgfzzW8w/riOxbNzT6zbpKq+gUFStTQ3q8MEmXDc NowmXCzECjaM4t4MEofXw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ofCPfK5mz0Q=;LB4fsM+PZL8ZEM5f2vqAAvNRSCj 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 ihTtnNxrH+TVgKDw= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) "J.D. Smith" writes: Hi, > Here's an updated patch to try with TRAMP, to see if it works as > expected in both old and new Emacs versions. Note that there are many > places where TRAMP does something more advanced, like: > > ;;;###tramp-autoload > (when (featurep 'dbusbind) > (tramp--with-startup > (dolist (method tramp-gvfs-methods) > ... > > so I think you'll need to keep autoloading the macro definition too. I've checked it with both Emacs 28 and 31, and it still works w/o problems. So pls push it to master. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 17 11:21:58 2025 Received: (at 78995) by debbugs.gnu.org; 17 Aug 2025 15:21:58 +0000 Received: from localhost ([127.0.0.1]:47199 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1unfCo-0007hr-Ee for submit@debbugs.gnu.org; Sun, 17 Aug 2025 11:21:58 -0400 Received: from mail-yb1-xb35.google.com ([2607:f8b0:4864:20::b35]:49452) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1unfCl-0007gF-Md for 78995@debbugs.gnu.org; Sun, 17 Aug 2025 11:21:56 -0400 Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-e933de3880bso933961276.3 for <78995@debbugs.gnu.org>; Sun, 17 Aug 2025 08:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755444109; x=1756048909; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=o04rQcE7zC6Tbqg6HFhZgaLhkpSLAmzZwQHWlt4inzg=; b=KbsIT3SIaLjnbEwAYsHZj+a/QoVDdjfgO1oM578qHuw5l+qyLfdJJYkrIo9NcIoK+7 7dxnp0KT5XiPlf0QA9j6W1OOFzXpNDqTbeohRiGeC6gKpbCKyMwgJC0PTCjtG9imcRMw kJSAZCfS2L6miwNZNG2NDvp19g61/R3gk17za66ctYfRR5pzvhQ2XMrfSjyTuMUTM3Pg alNBBtTktFeKi9WxzVo4Lctn2mDAuPmajv7+PDeRBEffOIr+Otnp7x/mOsEBoF37S0+Y DzaikVQGnqLb4nSQPeh8Yz7ad1J+wXnu7PuWg1b0xO5VfGKHKva1pI5519M6EzckgrCT avew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755444110; x=1756048910; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=o04rQcE7zC6Tbqg6HFhZgaLhkpSLAmzZwQHWlt4inzg=; b=l1eZcpM04IjfzdJ1Bd6MPLd8eXYAnCJJ/g2F9XKjZioRm7WH7HkaS3FQbq1aRbI/2+ 9wBIiE/2DgpGVXUuYBb50uEL8m9VkjnWUmvM4K1Y5IR749DYUjXTzfumW8fxYum5oZ1e zylsMpM9eUV/OWdoWwCXHo7ud1P8x64lyO7KmKyqodoWLw0UWEm2Bz8cfh4gPgshuMFr gsG0V1QxUgJDleWKG9hDZ/GKsKH1uhx7fkG0EeBO6vTIF8NTKnE2DbOvXs0gxfGYfB92 TBPMn2tCg2memo0kOJ81KXmnnxjLqo+ceB9bfaguamNVkUmkYAUROsf3YhvGRHwpB8CT +t0Q== X-Gm-Message-State: AOJu0YwAsGWpCYfaw2YFqdVb75BfwxWmf+gg8+4KqFrcxSC85XBlJ8Zs gJglQNbiGt1y9D29sePeNrO3tlF33OnfQ5NBx/gEfwALP9JqjgrRdHWA X-Gm-Gg: ASbGncsc7MbHsZt5AgdbZwpHwWwbcItrfBv1dfy7rhdymOD5alhvWQfD10RqL65fuAZ VeT2NNym3zTaZAJgSk3x/5x7/8Guq8D5A+ood8jj9zORM+fSCt3VVinLDoqQfeDYZJ1wDSFuiVc IPw/mvriHDlavnfNV0/FUvQz7zGnEp+mFt+4JzgSAqGEKSypkZB31I42EncOYoAiRZhDmvU7OEC xyde4BX12bmbeQ5dQmEszPqQ7p9Td5MtyYqpIIjGaWzVXAUCdlB7Kxz6XiNkbZKBQDUO6hFVgOL MJXDSQpnjfJqxIGbu0fCdd+u8p6t37JGyg280XQRteeFM0PZdnbKeB9AVXVuU521MfrSyQIkWWX TVEq+Tno2FoKKrJ5brHInd6PeqsOZtzjkMr6IP2LqmkVaPm19LVMJlD+F X-Google-Smtp-Source: AGHT+IFrY3EYaliNBpQTjb9yDjaLsq0PObePPojgVSu3URBj/1xDsB9A8mMdL+Nu0dyD0bQpJDy3LQ== X-Received: by 2002:a05:690c:730a:b0:71c:bf3:afa6 with SMTP id 00721157ae682-71e6dd74562mr84089577b3.42.1755444109602; Sun, 17 Aug 2025 08:21:49 -0700 (PDT) Received: from moss-4 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 00721157ae682-71e6deb96fdsm16550857b3.23.2025.08.17.08.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Aug 2025 08:21:49 -0700 (PDT) From: "J.D. Smith" To: Michael Albinus Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: <87y0ri9t0t.fsf@gmx.de> (Michael Albinus's message of "Sun, 17 Aug 2025 11:50:10 +0200") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> <87ecty5csf.fsf@gmx.de> <87fredsmy8.fsf@gmx.de> <87bjp1sh2x.fsf@gmx.de> <87a54jgl7a.fsf@gmx.de> <87o6sxfxof.fsf@gmx.de> <87y0ri9t0t.fsf@gmx.de> Date: Sun, 17 Aug 2025 11:21:48 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael Albinus writes: > "J.D. Smith" writes: > > Hi, > >> Here's an updated patch to try with TRAMP, to see if it works as >> expected in both old and new Emacs versions. Note that there are many >> places where TRAMP does something more advanced, like: >> >> ;;;###tramp-autoload >> (when (featurep 'dbusbind) >> (tramp--with-startup >> (dolist (method tramp-gvfs-methods) >> ... >> >> so I think you'll need to keep autoloading the macro definition too. > > I've checked it with both Emacs 28 and 31, and it still works w/o > problems. So pls push it to master. Great, thanks. Done, and closing. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 17 11:22:22 2025 Received: (at control) by debbugs.gnu.org; 17 Aug 2025 15:22:22 +0000 Received: from localhost ([127.0.0.1]:47214 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1unfDC-0007jA-04 for submit@debbugs.gnu.org; Sun, 17 Aug 2025 11:22:22 -0400 Received: from mail-yb1-xb2d.google.com ([2607:f8b0:4864:20::b2d]:55718) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1unfDA-0007iv-KA for control@debbugs.gnu.org; Sun, 17 Aug 2025 11:22:21 -0400 Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-e934c8f961aso273009276.3 for ; Sun, 17 Aug 2025 08:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755444135; x=1756048935; darn=debbugs.gnu.org; h=subject:from:to:message-id:date:from:to:cc:subject:date:message-id :reply-to; bh=8es++uSFB1u2lDZAmlbXG/r9xBCOvXdTSGPJV2sWgf8=; b=Ef3Je6fXAr7+GWsIgJORLQh9/hbLA5IWdhvjhdu6YpCy2no5bj1O49aAHOId6pVNDj iPK/3w1uYycraHnf8mMpdQl4UFIIRPtCrUDppSTdjZKTCah+0P1CcRZ4pfmSyj7x6I5o u4iKudmw6BJ01TXnO9bJ/J0jiA3NyRaRa4HJyFqNjq+oMysD74kQDDYum7LKwrQANdqS pMHe5AxNc3bTtWnB2gcVwqNq/eEuKX7CdMnmYMqdlAydQnAnMUUMYmhg4i/UbSzalhAR jUuaApiZZiD3HF7mbdZ3r+9+88bVE9WvVfWnuj20HwSb4A0bl6Z7fLJG2aPeIGRZU9Zg gQWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755444135; x=1756048935; h=subject:from:to:message-id:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8es++uSFB1u2lDZAmlbXG/r9xBCOvXdTSGPJV2sWgf8=; b=FBxsCj1UOh8L7JkHLiQd5BnT21ALMuMRVJzQeEmK9UXofrdBmEJRIOwEaEdd++b5+p wr5KtfIe3H/btEqum8elyUib15B+f1BnHKePy52BAcxtLYcGpVCOGq31mNVP3yYqastP fPcZ9Kjtjzahfi33i73+r1KZAW9DIJWbBWttnrxX7Z/oDoPa/VrSwfZzBJO8hENKgU/8 alCEwicNuyLNgWcM/7gM8dArpttgzdDUERu3PKAiaO4OXc4lphnDK7kgCVT1AH7xgrzB NVxGc8iQPeSexmijYZMZkCz97G61FvliBMphw1HLyfVFvbqZKVt624pl5NkcCmphOBJA fFOg== X-Gm-Message-State: AOJu0YzKgOLXEYxWxROaNaWuEMW/iYwRBy6f/jvcivc8+jGMpkQ4zikI oQ0SPTdZ5jyn4YdppomPP5X6dpclMnhy4gsV1M2ENCjoH+TE/Dd0UsDV/rcCJY0F X-Gm-Gg: ASbGnctenb/4Ikc/ZevG7VHBdn9pYL9aDgGZfg7efcQzO2DYyJJq8Gofob3MmNdhcMc 4EK2mpZXY9tctl9NVUJB4dttv8KbxTYyd2Ew6eWiD5SGvC1JMKyZr9Uxgcmnhkaj0Dvtz93enKX 7UuEeGaERwImAfvZYND9hnSDDsVAIJo49LBAsOsRtm4b5U6pkwJZuQSkv0YWuKnwkRa3oLUGd/8 Lby37suELYt6GPw/AKuv/H28gAtXs2UVJMp7/FrF7lhVKUgFdDxhcsyeYBBoxWOrGdxGgoDgvDN JO0AcQXaiFE4wi+9Tq6O8BzQV8dfofpyht5SZAMSbFyZtmOVo0EiFa1beQHQx3yRjG6Irr+tp/d x/fG+bxzZUbBSCp2MnF8TBtDMwSvTsYSRyXnJva0jsWKIt3IqmstmpNQqvFHf04Ovr5E= X-Google-Smtp-Source: AGHT+IHLASAAKGl21pwEtnLnZHE7Ef4rhem2mR/y49EjnvLAfSHsQErq8dOQiT4MLB69/G17tast3Q== X-Received: by 2002:a05:6902:4615:b0:e90:6d7d:aacf with SMTP id 3f1490d57ef6-e93323ade05mr11231372276.15.1755444134754; Sun, 17 Aug 2025 08:22:14 -0700 (PDT) Received: from moss-4 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e9332887e75sm2346751276.35.2025.08.17.08.22.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Aug 2025 08:22:14 -0700 (PDT) Date: Sun, 17 Aug 2025 11:22:13 -0400 Message-Id: To: control@debbugs.gnu.org From: "J.D. Smith" Subject: control message for bug #78995 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) close 78995 31 quit From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 20 07:18:02 2025 Received: (at 78995) by debbugs.gnu.org; 20 Aug 2025 11:18:02 +0000 Received: from localhost ([127.0.0.1]:56264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uogpN-0007un-Rk for submit@debbugs.gnu.org; Wed, 20 Aug 2025 07:18:02 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:22957) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uogpL-0007uL-77 for 78995@debbugs.gnu.org; Wed, 20 Aug 2025 07:18:00 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 45E2F440A44; Wed, 20 Aug 2025 07:17:52 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1755688670; bh=dtP4JQCywZE6IQ46ID7dZjCPWbIxbTC8Ypjqdf3AYu4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=gpa+PH6FNFYX96ADt27dcXa/9rTpfdDzMfgPm3zd1+af3omHuqfvNU9VVGzwEEyYF 99BrLbrT/XttZ9D3t1N3bIJj42Z4pOGzOvP5VosF8JT2d08qV4oGdoPvcwGOGERzyP saUOyEoK4lZRu6snEnMWyevmnmHyTYi1JMNSBZGkjgavco3nHlwUjElAcsIHYG5Dyp mC/UZxXIERaqZ/06+n32H6/rhb2ZQiD3YiP01TPtnRqKLrHCc9P3b6jKxk/lHG55Re rtjzma1TwgCYZOEyEs+uT5sJQPP/P4+VO1qDe9QxmasLlOG5kXkVsp7ACDeDdFgDUf eP53wd2iDnJww== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 97FC744096C; Wed, 20 Aug 2025 07:17:50 -0400 (EDT) Received: from asado (dyn.144-85-191-021.dsl.vtx.ch [144.85.191.21]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8A00912044C; Wed, 20 Aug 2025 07:17:49 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Changes to `loaddefs.el` for define-minor-mode In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Wed, 20 Aug 2025 07:17:45 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.061 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) AFAICT, the new code seems to change the contents of `loaddefs.el` for `define-minor-mode`, e.g.: % grep '(.*global-auto-revert-mode' **/*defs*.el lisp/ldefs-boot.el:(defvar global-auto-revert-mode nil "\ lisp/ldefs-boot.el:(custom-autoload 'global-auto-revert-mode "autorevert" nil) lisp/ldefs-boot.el:(autoload 'global-auto-revert-mode "autorevert" "\ lisp/ldefs-boot.el:evaluate `(default-value \\='global-auto-revert-mode)'. lisp/loaddefs.el:(autoload 'global-auto-revert-mode "autorevert" "\ % As you can see the `global-auto-revert-mode` variable ends up not preloaded. I'm generally opposed to preloading variables, but the change introduces a backward incompatibility with packages which presume they can take the value of `global-auto-revert-mode` without resorting to any `boundp` check, such as Magit. So I suggest the patch below, Stefan diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 9e91a11204d..e0b3859136c 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -155,7 +155,7 @@ loaddefs-generate--shorten-autoload ;; employing :autoload-end to omit unneeded forms). (defconst loaddefs--defining-macros '( define-skeleton define-derived-mode define-compilation-mode - define-generic-mode define-globalized-minor-mode define-minor-mode + define-generic-mode define-globalized-minor-mode cl-defun defun* cl-defmacro defmacro* define-overloadable-function transient-define-prefix transient-define-suffix transient-define-infix transient-define-argument transient-define-group From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 20 10:19:44 2025 Received: (at 78995) by debbugs.gnu.org; 20 Aug 2025 14:19:45 +0000 Received: from localhost ([127.0.0.1]:57185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uojfE-0002vO-6n for submit@debbugs.gnu.org; Wed, 20 Aug 2025 10:19:44 -0400 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]:44206) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uojfB-0002v7-LD for 78995@debbugs.gnu.org; Wed, 20 Aug 2025 10:19:42 -0400 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-71d6014810fso58353977b3.0 for <78995@debbugs.gnu.org>; Wed, 20 Aug 2025 07:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755699575; x=1756304375; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=PsFPA/AEHRypL0/zPUJcpkyLFO0d5KgRUkLvmlqVlK8=; b=nrg/Deu2LawQPd5EMG+aBiM8lGUiBYIke3OPgt2HDvpZCJy0OgDqW98s0A/A+on2FT 7pysRigC3hKis9E9hqG1wSbFnl0fSIovSbza/CKvQdBuvMXbA3fdsGwHNH5JVsmH5dhM fkgVlLLTll/DvXwSpyOZsvVsUFUsmshuTOx1uIJkslOWO7HFyXbPlL8S2gxTZWX06JWT wXw00BhUzq5zpsTjhp1diNTqmYYJ/86pVazey3K0XcaeaOrZyPPNyPxxB1LtGR3hAlbJ y8kjH0afD2PRK0cmzhhNGKcLVK8O6vx2UEHenuXn1FPPDtgPk1axfH5HBI+uY55PlpC3 XyXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755699575; x=1756304375; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PsFPA/AEHRypL0/zPUJcpkyLFO0d5KgRUkLvmlqVlK8=; b=ggcymcdCrREX6y6Y+hW7AllQIs7KbJ66pvSlIP4q7c1QQ8Us1WzqfDCLUtI0wrEfna SHvxMGdfHvSJKEccQ8t1uFSGoo2A9ZDqft7OOelt5x6gSM6faQzImlUo3hWt5ZsXOLvR XFiyHG3TKFYV6G1wB/0zJRhVlY+hyGZyNPAEVYoAwXBP2IbgaTcSveMX9SVCFARnNmjn LJcJZIEzOYCBipmlu4xAb7vpITmFrHMRQU5WqV0TyzB1CTX4ot6BSDBTlbqwQGKkd72P xMYhX6RA8IZs2euhsna/owyckzam8PMArVO6KeozBBd1cqa6baDQ6xjEUHJIP/E1nRMK cPHA== X-Gm-Message-State: AOJu0YxAEW0RpMidhCX0892PnyG9BZhDoPpFffU2g+DcI+qlnlvI3J+J +HCSPIniu+QRjy94NVCwjtAgyZzxwtdfa9pyjIOu0n5f4Eq4QSwrdqsUtq/qnx3v X-Gm-Gg: ASbGncsZNdC0IhbhPG8wtSfMK+v3G0ycVA61bLxXSwEl0l5AJo/j+ABKHS6AC54ALJk L4grrSawxGhhapDiETIt+uwMtuJlo36zQrthbW8S+TTQjFdsicZCXRjpbYupCidCoVNjetywVVk z8LqvXOup4ut51rG3/03AlA8zapX3w2Tk7cNqDXqQ/9Vx/mDEYrw16NV7QwQ9tXYFBjl9go39WY FzQog3j0xrWpkv43izq9OORGhJ/XRFOZ4LI3OFO8m7xrWWuKG4rf0Z1fjdk5pmEqLDP663CVQRx 6XamzRSo4kXqncLJA9N4OQayHwT2loid1cRyDs8/AbUxCux1jcrRvoD5Bc7gG7O0dSddXxV33BM hgYQaEG3GOPl4jDhRTd9V1u54k7CyL4UEcEVvFqKnfmhiXk0em/9A2wrdIb5BqrxcmCg= X-Google-Smtp-Source: AGHT+IEv2nLcASpF+AEXcjlSs7ub1f7rAVI6dnCKsjLmMn+hX/1Jx4PPTnIp5i95+GPeGTJzC0k1GA== X-Received: by 2002:a05:690c:6993:b0:71b:7043:21af with SMTP id 00721157ae682-71fb326dfcemr35015717b3.42.1755699574936; Wed, 20 Aug 2025 07:19:34 -0700 (PDT) Received: from moss-4 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 00721157ae682-71e6e0be8b0sm36458507b3.66.2025.08.20.07.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Aug 2025 07:19:34 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Wed, 20 Aug 2025 07:17:45 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Wed, 20 Aug 2025 10:19:33 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: > AFAICT, the new code seems to change the contents of `loaddefs.el` for > `define-minor-mode`, e.g.: > > % grep '(.*global-auto-revert-mode' **/*defs*.el > lisp/ldefs-boot.el:(defvar global-auto-revert-mode nil "\ > lisp/ldefs-boot.el:(custom-autoload 'global-auto-revert-mode "autorevert" nil) > lisp/ldefs-boot.el:(autoload 'global-auto-revert-mode "autorevert" "\ > lisp/ldefs-boot.el:evaluate `(default-value \\='global-auto-revert-mode)'. > lisp/loaddefs.el:(autoload 'global-auto-revert-mode "autorevert" "\ > % > > As you can see the `global-auto-revert-mode` variable ends up > not preloaded. I'm generally opposed to preloading variables, but the > change introduces a backward incompatibility with packages which presume > they can take the value of `global-auto-revert-mode` without resorting > to any `boundp` check, such as Magit. I don't see this: % grep '(.*global-auto-revert-mode' **/*defs*.el ldefs-boot.el:(defvar global-auto-revert-mode nil "\ ldefs-boot.el:(custom-autoload 'global-auto-revert-mode "autorevert" nil) ldefs-boot.el:(autoload 'global-auto-revert-mode "autorevert" "\ ldefs-boot.el:evaluate `(default-value \\='global-auto-revert-mode)'. loaddefs_old.el:(defvar global-auto-revert-mode nil "\ loaddefs_old.el:(custom-autoload 'global-auto-revert-mode "autorevert" nil) loaddefs_old.el:(autoload 'global-auto-revert-mode "autorevert" "\ loaddefs_old.el:evaluate `(default-value \\='global-auto-revert-mode)'. loaddefs.el:(defvar global-auto-revert-mode nil "\ loaddefs.el:(custom-autoload 'global-auto-revert-mode "autorevert" nil) loaddefs.el:(autoload 'global-auto-revert-mode "autorevert" "\ loaddefs.el:evaluate `(default-value \\='global-auto-revert-mode)'. (N.B.: `loaddefs_old.el' was a backup taken prior to the improvements we made here.) To me, this looks like you don't have autoload-macro declarations exposed while building loaddefs (recall this used to be a hard-coded list), so the `define-minor-mode' does not get expanded correctly. What I'd expect/hope is that `define-minor-mode' is already defined via autoload when autoload generation occurs, and has declared itself `(autoload-macro expand)`, in `loaddefs.el'. If you `make bootstrap', do you see: % grep '(.*define-minor-mode.*autoload-macro' **/*defs*.el lisp/loaddefs.el:(function-put 'define-minor-mode 'autoload-macro 'expand) This is essential, because the emacs which is used to generate loaddefs.el incorporates this file (right? see below). Summarizing, during generation of loaddefs.el, we need either: 1. easy-mmode to have been actually loaded, so its macros are properly defined along with their declarations, or 2. the autoload file used in the version of emacs which is building the autoload file to contain autoload-macro expand. Chicken-and-eggy again, though it does work for me. I just don't have a clear enough picture of the build sequence. Questions I have: 1. What does `ldefs-boot.el' do? Is it just a "backup" of `loaddefs.el', or is it ever actually loaded? 2. Which version of emacs is used to generate loaddefs.el? I think the "final version" is. 3. Is loaddefs.el compiled into the version of emacs that generates loaddefs.el? 3. If so, how is that circular dependency broken? Iteration? Is that what `ldefs-boot' is about. 4. Is there a list somewhere of packages that are always explicitly loaded for every emacs? Is easy-mmode on that list? JD > > So I suggest the patch below, > > > Stefan > > > diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el > index 9e91a11204d..e0b3859136c 100644 > --- a/lisp/emacs-lisp/loaddefs-gen.el > +++ b/lisp/emacs-lisp/loaddefs-gen.el > @@ -155,7 +155,7 @@ loaddefs-generate--shorten-autoload > ;; employing :autoload-end to omit unneeded forms). > (defconst loaddefs--defining-macros > '( define-skeleton define-derived-mode define-compilation-mode > - define-generic-mode define-globalized-minor-mode define-minor-mode > + define-generic-mode define-globalized-minor-mode > cl-defun defun* cl-defmacro defmacro* define-overloadable-function > transient-define-prefix transient-define-suffix transient-define-infix > transient-define-argument transient-define-group From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 20 12:24:56 2025 Received: (at 78995) by debbugs.gnu.org; 20 Aug 2025 16:24:56 +0000 Received: from localhost ([127.0.0.1]:57478 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uolcO-0000wl-Da for submit@debbugs.gnu.org; Wed, 20 Aug 2025 12:24:56 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:17825) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uolcL-0000wR-KP for 78995@debbugs.gnu.org; Wed, 20 Aug 2025 12:24:54 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4AF2C441968; Wed, 20 Aug 2025 12:24:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1755707086; bh=J45fWVvMKaltIEVoyP0/s4ADURFaGoj3C9OZ+DRWT+M=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=j+1ktCKe73kX4t97pwIhwG98XOHBmw6etBOohJWdw3Z9gk/V0qWHh5meZ8429wv23 2tJOn1l5/RwscbhvYFR/AO/y4xai7CALOvui1ALtSyzetgC/DK6ouN3wQghKvDvYPW brA4wzpeWwGObS7Qpid2tavqSQwCx16qzhjs/hHbvPtMswoR1YGtNta8f+Ql6sKKAD hinTOA3IYvKbXdrW55ZYAT/KTzfxJZoR+P92YUU5fEdsSpG64yo3qoeq5+V7bwXAbA ZeqjDwB+FYJSTYZgRpM32P3wj5tw6DSnE7RulUqX3t3qnRD2YiAIXp+FIEylqdS2kW A/vS4/gjTn7Lg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 683E844196D; Wed, 20 Aug 2025 12:24:46 -0400 (EDT) Received: from asado (dyn.144-85-191-021.dsl.vtx.ch [144.85.191.21]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 5C0AF120478; Wed, 20 Aug 2025 12:24:45 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Wed, 20 Aug 2025 12:24:39 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.060 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I don't see this: Hmm... I'll have to investigate further, then. Might be some issue on my side. Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 22 10:45:11 2025 Received: (at 78995) by debbugs.gnu.org; 22 Aug 2025 14:45:11 +0000 Received: from localhost ([127.0.0.1]:37014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1upT0x-00034M-7m for submit@debbugs.gnu.org; Fri, 22 Aug 2025 10:45:11 -0400 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]:50273) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1upT0r-0002Ps-BF for 78995@debbugs.gnu.org; Fri, 22 Aug 2025 10:45:06 -0400 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-e94f7232b30so2248386276.0 for <78995@debbugs.gnu.org>; Fri, 22 Aug 2025 07:45:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755873898; x=1756478698; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=jaOvI/FKRI7laCsjw8E76PgRwUCAnhR3SCQmvYeIXjM=; b=Rxi24WTrfdwRMVZSq8f4XwS/NlHnOjORZaq2+Gn6p3NHGAIVXiUQjaFcr+nAQqQsk5 PJccbnYlvsVwopmyR7sFL3m44y/9ND9pHufd5pqkpoaph2irUk4RftPFMA0RbY3+/HJ5 ygh8SwyNI9AG2TXXsFRz+KnsO0BfmoSGxkVpjWoGH9BGo2k1lCFfL/1CBnMxopLy7EB+ i9g8rRcX3bZ21U7cJkzzV+Rytar8+WcZx7tHpkGzWubmM1FKyOWZu6/1Qse1AVy5Wtn1 +iEvRokMvihRxNYWt7Am0OWp/NY3gkBR3DDsb0prnC9N/Njf+NFw99VgyK6ii61LECxA nZ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755873898; x=1756478698; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jaOvI/FKRI7laCsjw8E76PgRwUCAnhR3SCQmvYeIXjM=; b=w00JVJQ12shmvmqf60QB/OIzxozwRSAwTPAiFdSBLjdXjkO1vUYmXlo6FFNlrJKeqz njSqfVBbmjJVKgQ5WgIPTNRA/8DamPzGPnhcOgE7SH+onlF7hwb+u4vMf0C9M1HfdYyo c4lVLWaPoMFBJQaVnoMtf0q4Bq9MK9SApvMwFBia1hQzJD4r6wIoW78PXU01vdsS884A c9Zzv4wL2niPbE59v4KqgE6Ubi9UKP7l10+Y8z0oS7Jrs8gHfESq+mSa80g6Yhu/IKzp FSf/tXlpPbvYh9c/Rie1qn3ZNemFZlDvM/K0LYHjeEkGiz0M1gNg2g5xB+MhptDLnzT+ Z9OA== X-Gm-Message-State: AOJu0YydbbDKWgucpUxGBDuqEQWEWQdduaARYhnpLKwhFGWkaLtIawqA 3W/HomTB/BMgX7D4ioLj6LrT50bKGBi+Gg3+FeOezuN6HKe1HtVdHixROhxW+f1g X-Gm-Gg: ASbGncviOAkgwW4uZZFD18BOdPgnV3OjQ4T1jfkIraes0bQ7mDOXqb8bd+M6JOrpDis QZipcWH6SeCib12r7FSakcM3nhwXn6ZULorOYlNPe4sLpTl39RwTZLvj5vJMLo2mAV9BV9SJdG1 aBjKJ5G0nc6gunnxl8OE0DyejNzxPNVf37hdzPZRedhF9SHiYOtG2n8DMy77m2AJCGcXau6tMWr EiXG12xNGe3sDN+3lsViT6OD1x2IIWKuIOzN2YGDyQXGeDkIzzf/Sv+mllEwTZtJC+ONx09INJV ahhFYMXDaXgaUrJBVbhXEmu4eltKV3QLiuqNSZs6+FL9t8cPchenhx0IIePnQm52/XTAsnjWJGl +VAybCCCAypfnpv8bKSIveaDwr44TYonuye9uHqTjfCdYZ5Fm0lpnFDJmHD1ENE8Y8aM= X-Google-Smtp-Source: AGHT+IENCUSnCoU7Jid7W0Xc1MCpKE7fF1BkBj0wkVbfqvhZz2Jxtl0bIMty2yarcM1Rux28xFcmBw== X-Received: by 2002:a05:6902:2381:b0:e95:2525:9019 with SMTP id 3f1490d57ef6-e952525972bmr1723303276.18.1755873898337; Fri, 22 Aug 2025 07:44:58 -0700 (PDT) Received: from moss-4 (cm-24-53-143-223.buckeyecom.net. [24.53.143.223]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e952c354aaesm36253276.18.2025.08.22.07.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Aug 2025 07:44:57 -0700 (PDT) From: "J.D. Smith" To: Stefan Monnier Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: (Stefan Monnier's message of "Wed, 20 Aug 2025 12:24:39 -0400") References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Fri, 22 Aug 2025 10:44:57 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> I don't see this: > > Hmm... I'll have to investigate further, then. > Might be some issue on my side. Did the problem go away with a `make bootstrap'? I'd feel more confident if I understood better how the Emacs which produces loaddefs.el itself includes autoloads. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 23 02:44:33 2025 Received: (at 78995) by debbugs.gnu.org; 23 Aug 2025 06:44:33 +0000 Received: from localhost ([127.0.0.1]:38477 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uphzN-0002s7-8a for submit@debbugs.gnu.org; Sat, 23 Aug 2025 02:44:33 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:63021) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uphzK-0002ro-V1 for 78995@debbugs.gnu.org; Sat, 23 Aug 2025 02:44:31 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 778DC440690; Sat, 23 Aug 2025 02:44:24 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1755931463; bh=qQQyZ3MGGM+zKTHxnIJ/y1jnSxazfrPcm6E7r246JHA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=V20kS3C1ntmLfTstIT0ESwBPzeaXnQitp1F2STXoQ8EwjHK1waFYJj7cuMSW63Ew4 cwc6/HwAG5MaRons4ps9xxpCQJalKiUpjRV1wHSUiTZqwlx3WANsYPSQ1dtNI1uZpe FyNGWEkYwkcvUx85Nu6biv03hI96N0rJ1MHDAovWk/JxE0QN4BfeVVBzpY7BD37tCB EFU/BozsLNjdEabnCpfGpu+mt+q57kBwoT3rwWgOae9CFfumFFagmEhtvdbp2ikvdT gndQgDDVDZRIwzEckcqpY5htqJlBjaZsReB9/CAvtfwABCZMIav5aW4qet3hQzEZjy 1lGfAm50NpYVQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3253E44040D; Sat, 23 Aug 2025 02:44:23 -0400 (EDT) Received: from asado (dyn.144-85-186-084.dsl.vtx.ch [144.85.186.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1CCF51203CD; Sat, 23 Aug 2025 02:44:21 -0400 (EDT) From: Stefan Monnier To: "J.D. Smith" Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros In-Reply-To: Message-ID: References: <2015688C-B278-44FB-AF0B-778221B350F8@gmail.com> Date: Sat, 23 Aug 2025 02:44:19 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.073 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78995 Cc: 78995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> Hmm... I'll have to investigate further, then. >> Might be some issue on my side. > Did the problem go away with a `make bootstrap'? Yup. And I wasn't able to reproduce the problem afterwards, so I don't know where it came from. > I'd feel more confident if I understood better how the Emacs which > produces loaddefs.el itself includes autoloads. =F0=9F=99=82 Stefan