emacs - elisp warning "reference to free variable" -
i wandering how rid of elisp warning. setup following:
i have init.el file sets "emacs-root" variable:
;; root of emacs-related stuff (defvar emacs-root (if (or (eq system-type 'cygwin) (eq system-type 'gnu/linux) (eq system-type 'linux) (eq system-type 'darwin)) "~/.emacs.d/" "z:/.emacs.d/" "path emacs configuration root is."))
then in init.el have
;; load plugins el-get (require 'el-get-settings)
in el-get-settings.el loading packages el-get , appending "el-get/el-get" folder load-path:
;; add el-get load path, , install if doesn't exist (add-to-list 'load-path (concat emacs-root "el-get/el-get"))
the problem have lips warning on 'emacs-root' in last expression add-to-list : "reference free variable 'emacs-root'"
what doing wrong here , there way make compiler happy?
this setup works ok btw - don't have issues during load time, annoying warning.
regards, roman
when compiling file reference variable emacs-root
, variable must defined. easiest way avoid warning add
(eval-when-compile (defvar emacs-root)) ; defined in ~/.init.el
in el-get-settings.el
before offending form.
alternatively, can move defvar
init.el
el-get-settings.el
.
note can use eval-when-compile
in defvar
speed-up loading compiled file (of course, if that, should not copy compiled file between platforms):
(defvar emacs-root (eval-when-compile (if (or (eq system-type 'cygwin) (eq system-type 'gnu/linux) (eq system-type 'linux) (eq system-type 'darwin)) "~/.emacs.d/" "z:/.emacs.d/")) "path emacs configuration root is.")
note original defvar emacs-root
in question if broken, sets variable emacs-root
"path emacs configuration root is."
on windows.
Comments
Post a Comment