3

While reading the source file prelude-ivy.el in the Prelude modules directory, I saw that there was a warning associated with "here" in the last line, specifically that prelude-required-packages was not known to be a defined function.

I recognize that this is not exactly devastating but I am curious to understand better how to make a symbol "known to be defined" as a function. I tried a few things, like (require 'prelude-packages) but only moved the harmless warning around. I'm guessing that if I understand why this warning is being reported, a fix will be readily evident.

Drew
  • 75,699
  • 9
  • 109
  • 225
pajato0
  • 399
  • 1
  • 8

1 Answers1

5

Your question is a little confusing, but I suspect you actually mean that you've byte-compiled the prelude-ivy.el library (as opposed to "reading the source file"), and that the compiler has produced a warning that the function prelude-require-packages is not known to be defined (n.b. not "prelude-required-packages", which does not appear anywhere in the file; and the warning would be quite specific about it being a function, rather than a "symbol", which is not known to be defined).

The warning would look like this:

In end of data:
prelude-ivy.el:71:1:Warning: the function ‘prelude-require-packages’ is not known to be defined.

(And for future reference, if you have a question about a warning or error message, you should always copy and paste that message into your question -- doing so here would have eliminated all the confusion.)

The message tells us that the byte-compiler got all the way through the file and never encountered a definition for that function, even though it was used earlier in the file:

(prelude-require-packages '(ivy swiper counsel))

The warning (which will indeed be harmless in practice) can be silenced by informing the byte-compiler where the function prelude-require-packages is defined:

(declare-function 'prelude-require-packages "prelude-packages")

See C-hig (elisp)Declaring Functions

phils
  • 48,657
  • 3
  • 76
  • 115
  • Thank you both Drew and Phils for providing an answer and teaching how to write a better question. Both are very much appreciated. – pajato0 Jul 21 '18 at 03:00