I have a lot of code in my init file like this:

(when library-is-available
  ;; Code that use that uses functions from library

However, I get warnings that the functions that I am using are not known to be defined. What is an easy way to avoid these warnings? Can I perhaps ignore these code parts and not include them in the compiled file?

  • what about something like this?: (eval-when-compile (require 'cl-lib)) (defun foo () (cl-incf (point)))
    – jue
    Mar 29, 2021 at 23:39

1 Answer 1


Node Warning Tips of the Elisp manual tells us:

• To avoid a compiler warning about an undefined function that you know will be defined, use a declare-function statement (see Declaring Functions).

• If you use many functions, macros, and variables from a certain file, you can add a require (see require: Named Features) for that package to avoid compilation warnings for them, like this:

     (require 'foo)

If you need only macros from some file, you can require it only at compile time (see Eval During Compile). For instance,

       (require 'foo))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.