"Symbol's function definition is void: cl-defstruct" 我的 emacs 脚本出错

"Symbol's function definition is void: cl-defstruct" error for my emacs script

我正在尝试编写一个 emacs 脚本以通过以下方式从命令行调用:

emacs --script script.el

当我尝试在所述脚本中包含 cl-defstructdefstruct 时,我遇到了问题。例如,当我在 emacs 中使用 M-x eval-buffer 运行 时,以下工作正常但当 运行 作为脚本时失败:

(cl-defstruct test slot)
(setq myTest (make-test))
(setf (test-slot myTest) "hello")
(message (test-slot myTest))

上面应该只吐出消息 "hello" 但是当 运行 作为脚本时,我看到以下错误:

Loading 00debian-vars...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /etc/emacs/site-start.d/50python-docutils.el (source)...
Symbol's function definition is void: cl-defstruct

最后一行特别令人惊讶。为什么 cl-defstruct 宏在此设置中无法识别的任何想法?谢谢!

尝试在脚本顶部添加 (require 'cl-lib)