【问题标题】:"Symbol's function definition is void: cl-defstruct" error for my emacs script我的 emacs 脚本的“符号的函数定义无效:cl-defstruct”错误
【发布时间】:2016-01-17 06:27:38
【问题描述】:

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

emacs --script script.el

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

(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 宏?谢谢!

【问题讨论】:

    标签: emacs elisp


    【解决方案1】:

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

    【讨论】:

    • 谢谢!那行得通。我实际上尝试过(require 'cl),但没有成功,所以我发布了这个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多