I have this function in my config file and for some reason, I'm getting this error: Symbol's value as variable is void: *.

 (defun reload-config()
   "Reload config.org"
   (load-file (concat EMACS_DIR CONFIG_FILE)))

I have a similar function that works right.

 (defun find-config ()
   "Edit config.org"
   (find-file (concat EMACS_DIR CONFIG_FILE)))

Ps: I'm defining EMACS_DIR and CONFIG_FILE as

 (setq EMACS_DIR "~/.emacs.d/")
 (setq CONFIG_FILE "config.org")

From C-h f load-file RET:

Load the Lisp file named FILE.

I'm assuming ~/.emacs.d/config.org is an org file, not a Lisp file. That is, it starts something like:

* all my amazing settings
#+BEGIN_SRC emacs-lisp
  (setq whos-awesome 'i-am)

We can see that the first thing in that file is *; that is, just an asterisk. So when Emacs tries to load that file, it will look for the variable meaning of *, fail to find it, and throw an error.

If your file is set up as the example above shows, where all the Emacs Lisp is in #+BEGIN_SRC emacs-lisp blocks, you can use org-babel-load-file. From its documentation:

Load Emacs Lisp source code blocks in the Org FILE.

You can use it as follows:

(org-babel-load-file (concat EMACS_DIR CONFIG_FILE))
  • thank's a lot, you're a genius hahaha. The correct thing to do was to use init.el file, that has the babel load file stuff. Thanks for making me understand what was happening. I did know that was some silly error but I didn't know which. – Lucas Peixoto Nov 17 '19 at 18:25
  • Glad to help out! It's hard, because you see the asterisk in the error message, and it's not super obvious that * is the variable it's trying to look up. – zck Nov 17 '19 at 22:26

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.