gpt4 book ai didi

Emacs 全局设置键到 C-TAB

转载 作者:行者123 更新时间:2023-12-02 07:42:17 26 4
gpt4 key购买 nike

我正在尝试在 Emacs 中设置 Ctrl+TAB 的键绑定(bind)。我使用了以下调用:

(global-set-key (read-kbd-macro "C-TAB") 'my-func)

但是,每当我使用它时,我都会得到一个

<C-tab> is undefined

错误消息。尝试将绑定(bind)设置为“C-tab”会导致错误消息。

如何设置与 C-TAB 的绑定(bind)?

最佳答案

与其他人建议的不同,最好使用 kbd (或者read-kbd-macro,这基本上是相同的)以防您想在其他版本的 Emacs 中使用相同的配置文件; kbd适用于 Emacs 和 XEmacs 的多个版本,其中按键序列的内部表示不同。

(global-set-key (kbd "<C-tab>") 'my-func)

read-kbd-macro使用的输入格式记录在 edmacro-mode 的文档字符串中:

  • The special words RET, SPC, TAB, DEL, LFD, ESC, and NUL represent special control characters. The words must be written in uppercase.

  • A word in angle brackets, e.g., <return>, <down>, or <f1>, represents a function key. (Note that in the standard configuration, the function key <return> and the control key RET are synonymous.) You can use angle brackets on the words RET, SPC, etc., but they are not required there.

这写得有些遗憾;第一个要点中提到的 TAB 是 TAB 的 ASCII 字符,添加 Control 修饰符会对其执行一些无意义的操作。当您按下 Control-Tab 时,Emacs 将其视为(通过您的窗口系统;它在文本终端中不起作用)<tab>使用 Control 修饰符,您可以将其表示为 C-<tab><C-tab> .

关于Emacs 全局设置键到 C-TAB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/916797/

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