gpt4 book ai didi

emacs - Emacs : wrong-type-argument error in Emacs23 but not in Emacs24

转载 作者:行者123 更新时间:2023-12-02 10:46:57 29 4
gpt4 key购买 nike

首先,我承认我是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中工作。
如果我用 keybind替换 define-esc-key函数主体中的 "M-j"实例,它也可以在Emacs23中使用。

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

最佳答案

NEWS文件:

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

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

另外,您可以使用 eval和反引号插入值:
(eval `(kbd ,keybind))

关于emacs - Emacs : wrong-type-argument error in Emacs23 but not in Emacs24,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21237159/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com