Subject: Re: bug#77502: 31.0.50; Should after-load-functions hook report .eln file names?

From: Eli Zaretskii <[email-masked]>
Date: Sat, 05 Apr 2025 13:14:22 +0300

> From: Sean Devlin <[email-masked]>
> Date: Thu, 3 Apr 2025 13:35:19 -0500
> 
> Hi folks,
> 
> I am not sure if this is a bug or not, but the behavior was confusing to
> me.
> 
> Recipe:
> 
> 0. If necessary, rebuild Emacs with native compilation support.
> 1. Emacs -Q
> 2. In scratch, evaluate:
> 
> (setq force-load-messages t)
> (add-hook 'after-load-functions
> 	  (lambda (file)
> 	    (message "after load: %s" file)))
> 
> 3. M-x load-library RET org RET
> 4. C-h e
> 
> The messages buffer will show a lot of messages like this:
> 
> Loading find-func (native compiled elisp)...
> after load: /Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/find-func.elc
> Loading find-func (native compiled elisp)...done
> 
> The load messages show that a native library was loaded, but the
> after-load hook reports loading a byte-compiled file.
> 
> The documentation for after-load-functions says:
> 
> "Each function there is called with a single argument, the absolute name
> of the file just loaded."
> 
> I do not understand the intricacies of the native compiler and loader,
> so maybe this behavior is expected. But the result seemed misleading to
> me, and I could not find documentation of the disparity between what
> after-load-functions reports and what is actually loaded.
> 
> Is this a bug?

Not sure if this is a bug or a feature.  We record the *.elc names in
load-history, and those are the names passed to after-load-functions.
I've added Stefan and Andrea to this discussion, in case they have
comments.

If this is a feature, I guess we should update the documentation.

Thanks.