【问题标题】:In elisp How do I extract value from a variable在elisp中如何从变量中提取值
【发布时间】:2013-02-04 15:47:50
【问题描述】:

我在第一个练习部分(Emacs Lisp Intro),但我没听懂; 3.12 练习:

编写一个函数,测试当前值是否 `fill-column' 大于传递给函数的参数,如果是,则打印适当的消息。

我有:

(defun is-fill-equal (number)
   "Is fill-column greater than the argument passed to the function."
   (interactive "p")
(if (= fill-column number)
    (message "They are equal.")
  (message "They are not equal."))

无论我尝试什么,我都会收到此错误:

调试器进入--Lisp 错误: (void-variable number)

【问题讨论】:

    标签: elisp emacs23


    【解决方案1】:

    最后少了一个括号。试试:

    (defun is-fill-equal (number)
       "Is fill-column greater than the argument passed to the function."
       (interactive "p")
       (if (= fill-column number)
           (message "They are equal.")
         (message "They are not equal.")))
    

    错误信息的原因是你可能在函数定义的末尾C-x e。由于您缺少一个括号,Emacs 认为您要评估的表达式是 (if (= fill-column number) ...) 并且 number 在该上下文中是未绑定的。

    【讨论】:

    • 谢谢。我尝试了几种变体,但一直重复同样的错误。
    猜你喜欢
    • 1970-01-01
    • 2020-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多