Elisp warning "reference to a free variable"

I am wandering around how to get rid of the elisp warning. my setup is this:

I have an init.el file that sets the variable "emacs-root":

;; root of all 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 to where EMACS configuration root is."))

then in my init.el i have

;; load plugins with el-get
(require 'el-get-settings)

in el-get-settings.el I download packages using el-get and adding the "el-get / el-get" folder to the download path:

 ;; add el-get to the load path, and install it if it doesn't exist
 (add-to-list 'load-path (concat emacs-root "el-get/el-get"))

the problem is that I have a lip warning on "emacs-root" in the last expression for add-to-list: "reference to a free emacs-root variable"

what am i doing wrong here and is there a way to make the compiler happy?

this setting works fine btw - I have no problems at boot time, it's just an annoying warning.

With respect, Roman

+4
1

, emacs-root, . -

(eval-when-compile (defvar emacs-root)) ; defined in ~/.init.el

el-get-settings.el .

defvar init.el el-get-settings.el.

, eval-when-compile defvar (, , ):

(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 to where EMACS configuration root is.")

, defvar emacs-root , , emacs-root "Path to where EMACS configuration root is." .

+4

Source: https://habr.com/ru/post/1535271/


All Articles