Roman Shestakov
Roman Shestakov

Reputation: 507

"malformed function" warning and require "Cannot open load file:" error

I am getting these two issues :

In toplevel form: init.el:28:1:Warning: `(add-path (p) (add-to-list (quote load-path) (concat emacs-root p)))' is a malformed function init.el:42:1:Error: Cannot open load file: exec-path-from-shell

during compiling the following elisp:

(eval-when-compile (require 'cl))
;; root of all emacs-related stuff
(eval-when-compile
  (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."))

 (eval-when-compile
   (defvar emacs-root "~/.emacs.d"
    "Path to where EMACS configuration root is."))

;; path to where plugins are kept
(defvar plugin-path (concat emacs-root "el-get")
   "*Path to el-get plugins.")

;; for portability with < 24.3 EMACS
(unless (fboundp 'cl-labels) (fset 'cl-labels 'labels))

;; add paths to various configuration modes
(cl-labels
  ((add-path (p)
            (add-to-list 'load-path
                         (concat emacs-root p))))
 (add-path  ".")
 (add-path  "settings")
 (add-path  "site-lisp")
 (add-path  "erlang")
 (add-path  "exec-path-from-shell"))
;; set PATH, because we don't load .bashrc
(require 'exec-path-from-shell) ;; <- Error: Cannot open load file: exec-path-from-shell

both these issues are very puzzling to me.

  1. I don't see why this fund considered "malformed" `(add-path (p) (add-to-list (quote load-path) (concat emacs-root p)))'

  2. and secondly why "require" is not able to load file.

these issues only happen during compilation, not compiled code works ok

would really appreciate any pointers

Regards, Roman

Upvotes: 0

Views: 1756

Answers (2)

sds
sds

Reputation: 60014

You need to have "cl-lib" loaded at compile time:

(eval-when-compile (require 'cl-lib))

Also, as Stefan explained in his comments in your other question, you should not define variables in eval-when-compile. Just use defvar.

Upvotes: 0

Stefan
Stefan

Reputation: 28531

cl-labels is provided by cl-lib, not by cl. So you need (require 'cl-lib) (which you can also wrap in eval-when-compile).

Upvotes: 0

Related Questions