I expect the package to be require'd as soon as mdi-insert is called but I get:

Error (use-package): spaceline :config: Symbol’s function definition is void: mdi-insert


(let ((default-directory (expand-file-name "lisp/" user-emacs-directory)))

(require 'package)
 load-prefer-newer t
 package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)

(unless (package-installed-p 'use-package)
  (package-install 'use-package t))
 use-package-always-defer t
 use-package-always-ensure t)

(use-package org
  :pin org
  :ensure org-plus-contrib)

(use-package spaceline
  :ensure nil
  :demand t
  (message (mdi-insert "star")))

(use-package mdi :ensure nil)

~/.emacs.d/lisp/mdi/mdi.el: https://github.com/angrybacon/mdi/blob/master/mdi.el#L1952-L1957

(mdi is a package I wrote myself and placed under lisp/)

Also, it works with :demand t in the declaration for mdi. But I would like to defer the package if possible.

  • 1
    You don't have anything there that would cause mdi to load. Try adding a :commands mdi-insert to the use-package form for mdi. (Also, as pointed out by @Basil: are you sure you called the function mdi-insert? It doesn't seem to appear in the linked mdi.el.)
    – Omar
    Jul 1, 2017 at 6:02

2 Answers 2


Maybe I am missing something, but the linked mdi.el file does not define the function mdi-insert. Its main entry-point is the autoloaded function mdi.

Either way, if adding :demand t to the mdi use-package form results in the desired behaviour, this means that the definitions in mdi.el being used aren't being successfully autoloaded. Note that adding an autoload cookie (;;;###autoload) to an Elisp file does not automatically make it visible to Emacs. See the Elisp Manual and this post by lunaryorn for more information.

Some other observations:

  • If you intend to byte-compile your user-init-file, especially in a noninteractive emacs, you may want to eval-and-compile modifications to load-path (in your case, the call to normal-top-level-add-subdirs-to-load-path).
  • The use-package form for the spaceline package includes the :demand t clause. This means that the package will be required immediately, so everything in its :config clause should either be previously defined or autoloaded.
  • Given my previous observation that mdi.el does not seem to define the function mdi-insert, I find it strange that adding :demand t to the mdi use-package form results in the desired behaviour. Again, I could be missing something, though.

(use-package mdi :ensure nil)

is mdi installed?

You might also have to add

:after mdi

in use-package spaceline

  • If by installed you mean present under lisp/mdi/ then yes. :after didn't help. But I doubt it needs it: for instance, zenburn-with-color-variables (macro from zenburn.el) is available in other use-package declarations I have (without needing :after zenburn). Apr 30, 2017 at 22:18
  • Just to clarify, mdi is a package I wrote myself and placed in lisp/. Apr 30, 2017 at 22:32
  • ah I see. I wonder if you need to add :load-path "lisp/" like lunaryorn did in his use-package stanzas sometimes
    – Rski
    May 1, 2017 at 9:50
  • Nope, that didn't do it. May 1, 2017 at 10:14
  • Try adding :load-path "lisp/mdi" May 31, 2017 at 0:36

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.