Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

void variable error while using byte-compiled init files #436

Closed
sheepduke opened this issue Mar 12, 2017 · 3 comments
Closed

void variable error while using byte-compiled init files #436

sheepduke opened this issue Mar 12, 2017 · 3 comments

Comments

@sheepduke
Copy link

Hi,

I was trying to changing my init files into use-package forms, and everything was fine.
Then I was thinking of speeding up the loading process by byte compiling every file under "~/.emacs.d/settings" directory (the directory I place all the init files), so I did.
However I got a problem while loading some .elc file, "emacs --debug-init" gives:

Debugger entered--Lisp error: (void-variable personal-keybindings)
  add-to-list(personal-keybindings (("C-/") undo-tree-undo undo))

This is strange because if I load .el instead of .elc then everything works.
Also if I use the old require-and-define-key way instead of use-package, the problem disappears.

I am using snippet below to automatically load my file:

(mapc 'load (directory-files "~/.emacs.d/settings/" t "^[a-zA-Z0-9].*.elc$"))

Code snippet that causes the problem:

(use-package undo-tree
  :init
  ;; Show diffs when browsing through the undo tree
  (setq undo-tree-visualizer-diff t)
  ;; Don't show relative times in the undo tree visualizer
  (setq undo-tree-visualizer-timestamps nil)
  ;; Don't save history to a file
  (setq undo-tree-auto-save-history nil)

  :bind 
  ("C-/" . undo-tree-undo)
  ("C-?" . undo-tree-redo)
  ("C-x u" . undo-tree-visualize))

  :config (global-undo-tree-mode))

This problem only appears iff both use-package and byte compiled init files are used.

Any idea?

@npostavs
Copy link
Contributor

Try adding (require 'bind-key) to your init file.

In uncompiled code, using the use-package macro will autoload use-package which also loads bind-key. But when you compile, the expansion of the macro doesn't need to load use-package, so it never gets loaded. Perhaps the use-package macro should add (require 'bind-key) to its expansion?

@sheepduke
Copy link
Author

sheepduke commented Mar 12, 2017 via email

@sheepduke
Copy link
Author

sheepduke commented Mar 12, 2017

Adding "(require 'use-package)" before loading other init files solved the problem.
It was caused by lacking loading of use-package.

sangwoo-joh added a commit to sangwoo-joh/dotfiles that referenced this issue Dec 29, 2020
jeffkreeftmeijer added a commit to jeffkreeftmeijer/.emacs.d that referenced this issue Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants