终端元素箭头键绑定中的emacs [英] emacs in terminal meta arrow keybindings

查看:137
本文介绍了终端元素箭头键绑定中的emacs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚从终端模式中使用Emacs.app切换到emacs服务器和emacsclient,使用iterm2作为终端模拟器。我有一些麻烦与一些钥匙扣虽然。特别是M左箭头打印字符D,M向右箭头打印C,M向上箭头打印A和M向下箭头打印B. M-ret似乎工作,至少对于组织模式。我在iterm2中使用xterm默认的键,并将左右选项键绑定到+ Esc。我可以使用Esc-left或Esc-right获得组织模式中的M左功能这在组织模式中特别令人讨厌。我要重新绑定我的.emacs中的密钥吗?我怎么会这样做?



我已经看过这个 http://orgmode.org/manual/TTY-keys.html#TTY-keys ,但我不明白为什么箭头键在终端不可用。



编辑:



Cat meta-up: ^ [[1; 9A
Cat meta-down: ^ [[1; 9B
Cat meta-right: ^ [[1; 9C
Cat元左: ^ [[1; 9D



主要问题解决了,但是现在我遇到麻烦了 shift-up < select> undefined。我尝试了一个类似的映射,我从 cat 中得到的转义序列: ^ [[1; 2A ]。解决方案1 ​​

$ b
$ b

根据您在此提供的信息,您可以尝试一件事。你告诉emacs将这些转义序列映射到正确的键序列:

 (add-hook'term-setup-hook 
'(lambda()
(定义键功能键映射\e [1; 9A[M-up])
(定义键功能键映射
(定义键功能键映射\e [1; 9C[M-right])
(定义键功能-key-map\e [1; 9D[M-left])))

解决方案2



我还发现了另一个可能的解决方案,有一点谷歌搜索:重新定义iTerm绑定,以匹配什么emacs正在寻找。 p>>>> http://offbytwo.com/2012/01/15/emacs-plus-paredit-under-terminal.html



从上述页面引用:


返回到iTerm2下的配置文件密钥绑定,并添加以下绑定:




  M-up:Esc- [1; 4A 
M-down:Esc- [1; 4B
M右:Esc- [1; 4C
M左:Esc- [1; 4D


I have just switched from using Emacs.app to emacs server and emacsclient in terminal mode using iterm2 as my terminal emulator. I am having some trouble with some keybindings though. Particularly M-left arrow prints the character D, M-right arrow prints C, M-up arrow prints A, and M-down arrow prints B. M-ret seems to work though, at least for org mode. I am using the xterm defaults for keys in iterm2 and have the left and right option keys bound to +Esc. I can get the M-left functionality in org-mode with Esc-left or Esc-right This is particularly annoying in org-mode. Am I going to have to just rebind the keys in my .emacs? How would I go about doing that?

I have looked at this http://orgmode.org/manual/TTY-keys.html#TTY-keys, but I don't understand why the arrow keys should be unavailable in the terminal.

edit:

Cat meta-up: ^[[1;9A Cat meta-down: ^[[1;9B Cat meta-right: ^[[1;9C Cat meta-left: ^[[1;9D

Main problem solved, but I am now having trouble with shift-up. "<select> undefined". I tried a similar mapping with the escape sequence I got from cat: ^[[1;2A. Reluctant to create another question for a similar problem.

解决方案

Solution 1

Based on the info you provided here's one thing you can try. You tell emacs to map those escape sequences to the proper key sequences:

(add-hook 'term-setup-hook
  '(lambda ()
     (define-key function-key-map "\e[1;9A" [M-up])
     (define-key function-key-map "\e[1;9B" [M-down])
     (define-key function-key-map "\e[1;9C" [M-right])
     (define-key function-key-map "\e[1;9D" [M-left])))

Solution 2

I also found another possible solution with a little googling: redefine the iTerm bindings instead to match what emacs is looking for.

http://offbytwo.com/2012/01/15/emacs-plus-paredit-under-terminal.html

Quote from the above page:

Go back to the profile key bindings under iTerm2 and add bindings for the following:

M-up      : Esc-[1;4A
M-down    : Esc-[1;4B
M-right   : Esc-[1;4C
M-left    : Esc-[1;4D

这篇关于终端元素箭头键绑定中的emacs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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