1

It seems I totally do not understand the mechanism of package loading in Emacs.

I have in my init.el something like this:

(use-package elpy
  :ensure t
  :init
  (elpy-enable)
  :config
  (defalias 'workon 'pyvenv-workon)
  (setenv "WORKON_HOME" "/home/algor/miniconda3/envs")
  :custom
  (elpy-modules (elpy-module-sane-defaults
                 elpy-module-company
                 elpy-module-eldoc
                 elpy-module-pyvenv))
  (eldoc-idle-delay 5))

As I understand, first of all it loads a file containing (provide 'elpy), in my case it is .emacs.d/elpa/elpy-20220203.108/elpy.el.

But after starting Emacs I get the following errors:

Error (use-package): elpy/:init: Symbol’s function definition is void: elpy-module-sane-defaults
Error (use-package): elpy/:catch: Symbol’s function definition is void: elpy-module-sane-defaults

Also, I check that this function doesn't exist by hand.

It looks quite strange to me since I can find the definition of this function in elpy.el. I also can execute the definition by C-x C-e, and after that I can check that the function exists.

Am I wrong that the file elpy.el is executed while emacs is starting?

3
  • Stab in the dark: do you need to quote the list?
    – NickD
    Commented Feb 8, 2022 at 13:50
  • you could try adding :demand t to your configuration to make sure use-package isn't deferring loading of your config. you could also try your customization out in non-use-package form to make sure it is formatted right.
    – martian
    Commented Feb 8, 2022 at 16:22
  • This may be a duplicate question. I searched for that (tag quote etc.), but didn't find a dup. If someone finds one then this question should probably by closed.
    – Drew
    Commented Feb 8, 2022 at 16:38

1 Answer 1

0

As @Nickd suggested in a comment, try quoting the list.

  (elpy-modules '(elpy-module-sane-defaults
                  elpy-module-company
                  elpy-module-eldoc
                  elpy-module-pyvenv))

It looks like the code produced by use-package is evaluating what you provide for the list of modules. Instead of providing something that evaluates to a list of modules, you provided a sexp that's a list with car elpy-module-sane-defaults. That sexp gets evaluated, as an application of the (supposed) function elpy-module-sane-defaults to the other list elements.

6
  • Thank you, it helps! But I don't understand why the error was "Symbol’s function definition is void". If the sexp tried to be evalueted then the error should be "wrong arguments" or something like that, should't it?
    – Alex
    Commented Feb 8, 2022 at 16:42
  • It was trying to call elpy-module-sane-defaults as a function: I don't know if it is a function or not (haven't checked), but even if it is, it is not defined yet at that point. But you'd have to dig into use-package to see what it is actually doing.
    – NickD
    Commented Feb 8, 2022 at 16:56
  • The sexp is a (nonempty) list. Such a sexp is evaluated as a function application. Its first element is regarded as a function, and that is applied to the evaluations of the other elements (the arguments to the function). The argument elements are evaluated in order. When the car (first element) of the list is a symbol, its function value (what is returned by passing that symbol to function symbol-function) is used as the function to be applied to the arguments (evaluations of the other list elements).
    – Drew
    Commented Feb 8, 2022 at 16:57
  • See the Elisp manual, node Function Forms.
    – Drew
    Commented Feb 8, 2022 at 16:59
  • @NickD's comment here is a valid point. I just took a guess that this should be a quoted list.
    – Drew
    Commented Feb 8, 2022 at 17:06

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.