繁体   English   中英

Emacs:Emacs23中的错误类型参数错误,但在Emacs24中没有

[英]Emacs: wrong-type-argument error in Emacs23 but not in Emacs24

首先,我承认我是Emacs和ELisp的一个新手(就这个问题而言,一般来说是Lisp),我偶然发现了一个错误,这个错误使我在尝试写作时已经陷入了很长一段时间我的.emacs文件。

这是重现该问题所需的最小代码示例(即,具有仅包含以下内容的.emacs):

(defun define-esc-key (keybind)
  (define-key key-translation-map (kbd keybind) 'my-esc))
(define-esc-key "M-j")

这将对Emacs23产生以下错误:

Lisp error: (wrong-type-argument integer-or-marker-p keybind)
  read-kbd-macro(keybind)
  #[(keys) "\301!\207" [keys read-kbd-macro] 2 2186954](keybind)
  (kbd keybind)
  (define-key key-translation-map (kbd keybind) (quote my-esc))
  define-esc-key("M-j")

但是可以像我期望的那样在Emacs24中工作。 如果我用"Mj"替换define-esc-key函数体中的keybind实例,它也可以在Emacs23中使用。

(顺便说一句,对不起,标题不好,但我想不出更具描述性。)

NEWS文件:

* Lisp Changes in Emacs 24.3
...
*** `kbd' is now a function rather than a macro.

这意味着在早期的Emacs版本中,调用中必须确实存在kbd的参数,而不是在示例中使用变量。

另外,您可以使用eval和反引号插入值:

(eval `(kbd ,keybind))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM