Subject: Re: bug#69290: declare-function doesn't work when combined with --eval and -batch

From: Eli Zaretskii <[email-masked]>
Date: Tue, 20 Feb 2024 21:51:59 +0200

> From: Konstantin Kharlamov <[email-masked]>
> Date: Tue, 20 Feb 2024 21:59:31 +0300
> 
> Stumbled upon that while trying to improve CI in Evil mode. Enabling byte-compilation
> causes warnings about `undo-redo` undeclared on older Emacs'es, so tried to work
> around that with `declare-function`. Turns out it doesn't work.

Of course it does.  If used correctly, that is.  We do that in
gazillion places in our sources.

>     λ cat test.el
>     ;;; -*- lexical-binding: t -*-
>     (hello)
>     λ emacs -batch --eval '(declare-function hello nil)' -f batch-byte-compile test.el
> 
>     In end of data:
>     test.el:2:2: Warning: the function ‘hello’ is not known to be defined.
> 
> ## Expected
> 
> There's no warning

What does the doc string of declare-function tell you about its usage
and effect?