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

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

问题描述

我刚刚从使用 Emacs.app 切换到终端模式下的 emacs 服务器和 emacsclient,使用 iterm2 作为我的终端模拟器.不过,我在某些键绑定方面遇到了一些麻烦.特别是 M-left 箭头打印字符 D,M-right 箭头打印 C,M-up 箭头打印 A,M-down 箭头打印 B. M-ret 似乎有效,至少对于 org 模式.我对 iterm2 中的键使用 xterm 默认值,并将左右选项键绑定到 +Esc.我可以使用 Esc-left 或 Esc-right 在 org-mode 中获得 M-left 功能 这在 org-mode 中特别烦人.我是否只需要重新绑定 .emacs 中的密钥?我该怎么做?

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?

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

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.

Cat meta-up:^[[1;9A猫元向下:^[[1;9B猫元右:^[[1;9C猫元左:^[[1;9D

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

主要问题已解决,但我现在在使用 shift-up 时遇到问题.<选择>未定义".我用从 cat 得到的转义序列尝试了类似的映射:^[[1;2A.不愿意为类似问题创建另一个问题.

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.

推荐答案

解决方案 1

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

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])))

解决方案 2

我还通过谷歌搜索找到了另一种可能的解决方案:重新定义 iTerm 绑定以匹配 emacs 正在寻找的内容.

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

引用自上页:

返回到 iTerm2 下的配置文件键绑定,并为以下内容添加绑定:

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天全站免登陆