1

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?

2
  • 1
    Good catch. I'd say that the doc string needs to be fixed, to more precisely state what the FILE argument is. Consider filing a bug report: M-x report-emacs-bug. The doc string even says that that argument is looked up by locate-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 that FILE is not used during byte-compilation. It could be clearer, IMO. – Drew Jul 9 '16 at 6:38
  • Thanks Drew. Could you please take a guess at what the code author was trying to achieve by providing '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
0

How can 'package be a useful 2nd argument, when the doc for declare-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.

0

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.elfrom theload-path.

2
  • Not a bad guess, but it doesn't actually work. If you run 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
  • Oh, I stand corrected. – Tassilo Horn Jul 14 '16 at 19:08
0

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 ...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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