1

It seems that declare-function + check-declare-file do not recognize functions defined via cl-defun.

I was happy using declare-function because it comes with check-declare-file that actually checks whether the declaration is consistent with the actual code in some other source file. However, when I upgraded the code for one of my declared functions, adding some keyword arguments and relying on cl-defun for handling them, check-declare-file could not validate and said that the function was not to be found.

Is there a workaround I could use? Or maybe declare-function is obsolete and there is some newer method I should use instead?

phs
  • 1,095
  • 6
  • 13
  • Please edit your question and add the exact error message. In what context did you encounter it? – NickD Jul 29 '20 at 21:40
  • @NickD. My initial description was quite confused. The error occurs when using `check-declare-file`. Thanks! – phs Jul 30 '20 at 05:56

1 Answers1

1

At first note that check-declare-verify actually has a pattern for cl-defun in its regexp. So it should work.

If it does not maybe you should double-check and report an error if your code is not the source of the problem.

If it really turns out that you did not make any error and want to suppress the warning the doc string for declare-function answers your question:

(declare-function FN FILE &optional ARGLIST FILEONLY)

Optional FILEONLY non-nil means that check-declare will check only that FILE exists, not that it defines FN. This is intended for function definitions that check-declare does not recognize, e.g., defstruct.

So use a non-nil FILEONLY argument in check-declare for functions defined by cl-defun.

Tobias
  • 32,569
  • 1
  • 34
  • 75