GNU bug report logs - #78995
[PATCH] ;;;autoload-expand for special macros

Previous Next

Package: emacs;

Reported by: JD Smith <jdtsmith <at> gmail.com>

Date: Fri, 11 Jul 2025 19:29:02 UTC

Severity: normal

Tags: patch

Fixed in version 31

Done: "J.D. Smith" <jdtsmith <at> gmail.com>

Full log


Message #83 received at 78995 <at> debbugs.gnu.org (full text, mbox):

From: "J.D. Smith" <jdtsmith <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 78995 <at> debbugs.gnu.org, Michael Albinus <michael.albinus <at> gmx.de>
Subject: Re: bug#78995: [PATCH] ;;;autoload-expand for special macros
Date: Sun, 27 Jul 2025 15:14:21 -0400
[Message part 1 (text/plain, inline)]
Stefan Monnier <monnier <at> iro.umontreal.ca> 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% 
   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% 
     INFO     Scraping 1566 files for loaddefs...64% 
   Got nil car:
   nil "goto-addr" expansion
   loaddefs-gen: loading file tramp-adb (for tramp--with-startup)
   Loading tramp-adb...
   Source file ‘code/emacs/emacs-mac/lisp/net/tramp-loaddefs.el’ newer than byte-compiled file; using older file
   Source file ‘code/emacs/emacs-mac/lisp/emacs-lisp/cl-loaddefs.el’ newer than byte-compiled file; using older file
     INFO     Scraping 1566 files for loaddefs...80% 
   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% 
   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 = 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. 

>>> 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=emacs,
> 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?

[autoload-expand_5.patch (text/x-patch, attachment)]

This bug report was last modified 27 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.