“格式错误的函数”警告并要求“无法打开加载文件:”错误

时间:2014-04-08 21:13:51

标签: emacs elisp

我遇到了这两个问题:

以顶级形式: init.el:28:1:警告:`(add-path(p)(add-to-list(quote load-path)(concat     emacs-root p)))'是一个格式错误的函数 init.el:42:1:错误:无法打开加载文件:exec-path-from-shell

在编译以下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

这些问题对我来说都很令人费解。

  1. 我不明白为什么这个基金被认为是“畸形” `(add-path(p)(add-to-list(quote load-path)(concat emacs-root p)))'

  2. 其次,“require”无法加载文件。

  3. 这些问题只发生在编译期间,而不是编译的代码工作正常

    非常感谢任何指针

    问候,罗马

2 个答案:

答案 0 :(得分:0)

你需要拥有&#34; cl-lib&#34;在编译时加载:

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

此外,正如Stefan在your other question的评论中所解释的那样,你不应该在eval-when-compile中定义变量。只需使用defvar

答案 1 :(得分:0)

cl-labelscl-lib提供,而不是由cl提供。所以你需要(require 'cl-lib)(你也可以将其包裹在eval-when-compile中)。