绑定M-< up> / M-< down>在Emacs 23.1.1 [英] Binding M-<up> / M-<down> in Emacs 23.1.1

查看:136
本文介绍了绑定M-< up> / M-< down>在Emacs 23.1.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图放入一个我从Eclipse中遗漏的功能,其中 Alt + [ Up / Down ]但是不能为我的生活找出如何正确地分配给这些键。我正在使用它在 -nw 模式(所以只是在一个shell窗口),通常在屏幕会话中运行。

I'm trying to put in a feature that I miss from Eclipse, where Alt+[Up/Down] transposes the lines up or down, but can not for the life of me figure out how to assign to these keys properly. I am using it in -nw mode (so just in a shell window), and typically run in a screen session.

使用全局键绑定,我可以让它使用字母组合,如(kbdMm),但是我为箭头键尝试的每个组合只是给我一个没有意义的消息,我总是得到:

Using a global key binding, I can get it to work with letter combinations, like (kbd "M-m"), but every combination I have tried for the arrow keys just gives me a message that doesn't make sense, I always get:

"ESC <up> is undefined"

我尝试过:

(global-set-key (kbd "M-<up>") 'transpose-line-up)    
(global-set-key (kbd "<escape>-<up>") 'transpose-line-up)
(global-set-key [M-up] 'transpose-line-up)
(global-set-key [\e \M-O A] 'transpose-line-up)

Ch c 只是返回:

ESC <up> (translated from ESC M-O A) is undefined

这些都不工作,使用 ESC Alt

None of these work, either using ESC or Alt.

任何想法如何使这项工作?我喜欢将这些作为 Alt + [ Up / Down ],只是因为这是我习惯的。

Any idea how I can make this work? I would prefer to have these as Alt+[Up/Down] just because that is what I am used to.

修改

从评论中:


  • Cq Up 打印 ^ [OA

Cq M-Up 打印 ^ [并将光标向上移动一行。

C-q M-Up prints ^[ and moves the cursor up a line.

Ch k Alt + Up )打印 ESC< up> (从ESC MO A翻译)未定义

感谢您的建议,但他们都是一样的。

Thanks for the suggestions, but they all turned out the same.

推荐答案

Emacs有一个复杂机制来处理各种终端类型的功能键和修饰符编码的变化。在所有情况下,它都不能开箱即用。以下设置应在您的终端上工作:

Emacs has a complex mechanism to handle the vicissitudes of function key and modifier encodings on various terminal types. It doesn't work out of the box in all cases. The following settings should work on your terminal:

(define-key input-decode-map "\e\eOA" [(meta up)])
(define-key input-decode-map "\e\eOB" [(meta down)])
(global-set-key [(meta up)] 'transpose-line-up)
(global-set-key [(meta down)] 'transpose-line-down)

您应该可以使用(kbd< M-up>)(kbd < M-down>)代替 [(meta up)] [(meta down)] ,只要您已经完成了关于终端使用的转义序列的Emacs(通过 input-decode-map )的步骤编码这些组合键。

You should be able to use (kbd "<M-up>") and (kbd "<M-down>") in place of [(meta up)] and [(meta down)], as long as you've done the step of telling Emacs (via input-decode-map) about the escape sequences that your terminal uses to encode these key combinations.

这篇关于绑定M-&lt; up&gt; / M-&lt; down&gt;在Emacs 23.1.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆