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

From: Stefan Monnier <[email-masked]>
Date: Fri, 31 Jan 2014 09:49:50 -0500

>>> I guess I should wrap those TeX-auto-add-type calls with a
>>> `eval-when-compile', right?
>> You could.
> No, I get a compile error in tex.el when compiling

Of course, eval-when-compile and eval-and-compile come with their own
set of problems.  My "you could" wasn't really meant as an encouragement.

>> Or you could turn them into macros.
> Indeed, that looks like a typical use-case for macros, but I'm rather
> sure that there's a good reason that the auto parser stuff is like it
> is.  David?

Whatever the reason, looking at the code of TeX-auto-add-type, I think
it *really* should be turned into a macro, and use defvar/defalias
instead of set/fset.

> While we are at it: David, is there any reason why somebody would want
> to set TeX-install-font-lock to 'ignore nowadays so that font-latex is
> not loaded?

Would that make AUCTeX use tex-mode.el's font-lock rules?

>> Good question.  We usually use `declare-function' for these, but
>> admittedly, it's not a great solution.
> I see.  The reason for the code above is that foo is only callable in
> very special conditions.

That's what I expected.  We also have such code in various parts
of Emacs.  But we don't have a really good solution w.r.t to silencing
those warnings.

One potential solution I haven't investigated is to create a new
`require-autoload' which behaves somewhat like `require' (when
interpreted) but which the compiler would replace by a bunch of
autoloads (auto-generated by the compiler by taking the intersection of
the functions provided by the `require' and the functions called in the
file).  So you'd replace that code with

   (require-autoload 'url-util)
   (defun foo ()
     (url-util-* ...))

and url-util would only be loaded once you call `foo'.
Maybe `require-lazy' would be a better name for it, but in any case as
long as it's not implemented, its name doesn't matter much.

        Stefan