I just saw this line near the top of the file use-package.el
:
(declare-function package-installed-p 'package)
How can 'package
be a useful 2nd argument, when the doc for declare-function
says that the third argument should be a filename?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityHow can
'package
be a useful 2nd argument, when the doc fordeclare-function
says that the third argument should be a filename?
It's a mistake in use-package.el, now fixed. If you run check-declare
on the unfixed version you'll see in *Messages*
:
Malformed declaration for `package-installed-p'
Malformed declaration for `(, command)'
The first is the 'package
mistake, the second is a false positive on use-package
code that generates a declare-function
statement call.
The reason it's like this, is that check-declare-scan
works by regexp rather than actually parse the lisp code, so it can't be 100% certain about which statements are real.
It means the function is defined by the file providing the feature package
which is package.el
. It's the same as with(require 'foo)
which will also load a file foo.el
from theload-path
.
check-declare-file
on use-package.el
and look at *Messages*
you'll see Result: "Malformed declaration for `package-installed-p'"
.
– npostavs
Jul 14 '16 at 19:07
I emailed JohnWiegley, and he said the following:
That code was contributed by another, but I'm fairly certain it's just using the symbol-name of the symbol. The same sort of thing works with eval-after-load:
(eval-after-load "foo" ...)
(eval-after-load 'foo ...)
FILE
argument is. Consider filing a bug report:M-x report-emacs-bug
. The doc string even says that that argument is looked up bylocate-library
, whose doc also says it must be a string. On the other hand,declare-function
is for the byte-compiler, and the doc says thatFILE
is not used during byte-compilation. It could be clearer, IMO. – Drew Jul 9 '16 at 6:38'package
as a second argument? Is that even legal, or functional? Should I learn to do the same thing? – Kevin Jul 9 '16 at 22:18