Subject: Re: bug#71537: 30.0.50; [PATCH] missing autoload cookies

From: Gerard Vermeulen <[email-masked]>
Date: Thu, 13 Jun 2024 20:57:50 +0000

On 13.06.2024 17:33, Eli Zaretskii wrote:
>> Date: Thu, 13 Jun 2024 14:59:06 +0000
>> From: Gerard Vermeulen <[email-masked]>
>> 
>> I propose the attached patch adding three missing autoload cookies
>> to eliminate two require forms from two sections in my init.el.
>> 
>> To eliminate (require 'shortdoc) from the first section:
>> (with-eval-after-load 'help-fns
>>    ;; ChatGPT recommends to require `shortdoc' contrary to the
>>    ;; `shortdoc-help-fns-examples-function' documentation string.
>>    (require 'shortdoc)
>>    (add-hook 'help-fns-describe-function-functions
>>              #'shortdoc-help-fns-examples-function)
>>    (setopt help-enable-symbol-autoload t))
>> 
>> And to eliminate (require 'pulse) from the second section:
>> (require 'pulse) ; since `pulse' does not autoload `pulse-delay' and
>>                   ; `pulse-iterations'.
>> 
>> (defun flash-line-around-point (&rest _)
>>    "Flash the line around point."
>>    (let ((pulse-iterations 16)
>>          (pulse-delay 0.1))
>>      (pulse-momentary-highlight-one-line (point))))
>> 
>> (dolist (command '(scroll-up-command
>>                     scroll-down-command
>>                     recenter-top-bottom
>>                     other-window))
>>    (advice-add command :after #'flash-line-around-point))
> 
> Thanks, but I don't understand why what we have now constitutes a
> problem.  help-fns loads shortdoc when it needs it, and
> pulse-momentary-highlight-one-line is autoloaded already (you don't
> need to auto-load variables to assign values to them).
> 
> Can you describe the problems you have if you delete those 'require's
> from your init file, and explain why manually requiring them is a
> problem?

I try: after deleting those require's:

1. and after doing "M-x describe-function shortdoc" before shortdoc has 
been
     (auto)loaded by something else, I get in my message window:

     help-fns--run-describe-functions: Symbol’s function definition is 
void: shortdoc-help-fns-examples-function

     and the help window does not show (is not created).

     Addition of an autoload cookie to 
shortdoc-help-fns-examples-function
     fixes this.

2. and after calling "other-window" flash-line-around-point gets called,
     but I get in my message window:

     byte-code: Defining as dynamic an already lexical var: 
pulse-iterations

     and the expected visual effect (a slow - about 2 seconds - flashing 
of
     the line containing point) does not show itself.  Addition of the 
two
     autoload cookies to the two defcustoms pulse-iterations and 
pulse-delay
     fixes this.

Manually requiring the two requires is not a real problem, but just 
somewhat
inconvenient and surprising in my point of view (FWIW).