Subject: Re: bug#16573: 24.3; Auctex (11.87.2) in Elpa issues hundreds of warnings on compile

From: Stefan Monnier <[email-masked]>
Date: Thu, 30 Jan 2014 10:41:18 -0500

> 1. Many TeX-* and LaTeX-* functions and variables are not generated
>    before tex.el and latex.el are loaded.  AUCTeX has an auto parser
[...]
>    The byte-compiler doesn't seem to execute top-level funcalls, so all
>    those functions/vars are unknown at compile-time.

Indeed, the byte-compiler compiles the code, rather than executes it.

But if it sees a (require 'foo) it will run that (require 'foo), i.e. it
will load foo.el(c), which executes all of the code in there.
So a (require 'tex) will execute (TeX-auto-add-type "symbol" "TeX") at
compile-time, and will hence cause TeX-symbol-list to exist at compile-time.

>      (TeX-auto-add-type "acronym" "LaTeX")
[...]
> I guess I should wrap those TeX-auto-add-type calls with a
> `eval-when-compile', right?

You could.  Or you could turn them into macros.

> 3. How should one deal with code like this?
>       (when (featurep 'font-latex)
>         (font-latex-add-keywords ...))

    (when (fboundp 'font-latex-add-keywords)
      (font-latex-add-keywords ...))

> 4. Or with code like this?
>
>       (defun foo ()
>         (require 'url-util)
>         (url-util-* ...))

Good question.  We usually use `declare-function' for these, but
admittedly, it's not a great solution.

        Stefan