本文介绍了终端Emacs input-decode-map的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在终端中询问了Emacs中的Ctrl-arrow键绑定问题:

I have asked a question about Ctrl-arrow keybinding in Emacs in terminal:

有人被告知,那个Linux终端仿真器不处理此组合。我设法为 loadkeys 命令创建一个文件,它们处理这些密钥:

And was told, that Linux terminal emulator doesn't process this combination. I managed to create a file for loadkeys command, that processes these keys:

control keycode 105 = F100
string F100 = "\033[[left"
control keycode 106 = F101
string F101 = "\033[[right"

然后从root加载它:

Then loaded it from root:

#loadkeys ./funcskeys

之后,每次单击Ctrl-right或Ctrl在控制台中,我收到右或左打印。现在我需要在Emacs中处理这个。据我所知,从这个问题:

After that every time I click Ctrl-right or Ctrl-left in console, I get 'right' or 'left' printed. Now I need to process this in Emacs. As far as I understand from this question:

结合M-上/ M-< down>在Emacs 23.1.1中

Binding M-<up> / M-<down> in Emacs 23.1.1

必须使用 input-decode-map 函数完成。但我不能让它工作。请帮助。

it must be done, using input-decode-map function. But I couldn't make it work. Plz, help.

推荐答案

稍微更改funcskeys文件以产生以下转义序列:

Change your "funcskeys" file slightly to produce the following escape sequences:

control keycode 105 = F100
string F100 = "\033[1;5D"
control keycode 106 = F101
string F101 = "\033[1;5C"

然后将以下行添加到 .emacs file:

Then add the following lines to your .emacs file:

(define-key input-decode-map "\e[1;5C" [(control right)])
(define-key input-decode-map "\e[1;5D" [(control left)])

运行 loadkeys 并重新启动Emacs后,和应该工作。您可以输入以下内容来验证:

After running loadkeys and restarting Emacs, and should work. You can verify this by typing:

要将这些击键实际绑定到命令,例如 forward-word ,则可能需要将以下行添加到 .emacs 文件中:

To actually bind these keystrokes to a command, such as forward-word, you might have to add the following lines to your .emacs file as well:

(global-set-key [(control right)] 'forward-word)
(global-set-key [(control left)] 'backward-word)

请注意,这种整体方法只能使键组合和工作。它,例如使 / 工作,或涉及 and work. It does not for instance make / work, or any other key combinations involving the character.

这篇关于终端Emacs input-decode-map的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!