我正在测试在 emacs init.el
(Emacs 24.3) 中加载包。我按照作者的博客emacs prelude
自动加载包,并将那里的代码复制到我init.el
的底部。loop
但是,我收到有关函数/符号的错误消息,其中显示:
Symbol's function definition is void: loop
有人可以解释如何修复代码吗?
我在网上搜索了一下,好像loop
是一个宏cl-lib
。我的猜测是loop
缺少 for 的定义,我试图通过添加 来解决问题(require 'cl-lib)
,如代码所示,但错误仍然存在。还有其他关于类似错误消息的 SO 问题,例如:ELisp: cl-loop for "Symbol's value as variable is void",Symbol 的函数定义是 void: declare-function。但是错误消息对于缺少的内容有所不同,并且答案大多建议替代路线,例如使用较新版本的 emacs。
- 代码 -
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "http://stable.melpa.org/packages/") t)
(package-initialize)
;;; check & load packages
(defvar prelude-packages
'( haskell-mode )
"A list of packages to ensure are installed at launch.")
;;(require 'cl-lib) ;debug
(defun prelude-packages-installed-p ()
(loop for p in prelude-packages
when (not (package-installed-p p)) do (return nil)
finally (return t)))
(unless (prelude-packages-installed-p)
;; check for new packages (package versions)
(message "%s" "Emacs Prelude is now refreshing its package database...")
(package-refresh-contents)
(message "%s" " done.")
;; install the missing packages
(dolist (p prelude-packages)
(when (not (package-installed-p p))
(package-install p))))
(provide 'prelude-packages)
;;; end load packages