emacs绑定键插入另一个 [英] emacs bind key to the insertion of another

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

问题描述

我有 paredit-forward paredit-backward 绑定到>和<

I have paredit-forward and paredit-backward bound to > and < respectively.

这意味着如果我要输入something-> something-else,我可以输入something,光标被传送到屏幕的另一部分,使用something-else完成打字。

This means if I want to type "something->something-else" I instead type "something-" the cursor is teleported to another part of the screen, and finish typing with "something-else".

我的解决方案是使用 C - 。 code> C - ,插入它们。
我试过这个:

My solution to this is to use C-. and C-, to insert them. I tried this:

(define-key key-translation-map (kbd "C-.") (kbd ">"))
(define-key key-translation-map (kbd "C-,") (kbd "<"))

以前的命令导致另一个paredit-forward键绑定,因为我正在创建一个键盘链接:

The previous command results in the another paredit-forward keybind because I am creating a keybind chain like so:

C-. → > → paredit-forward

而不是

C-. → > → the "greater than" key is inserted into whatever text box I am in.

这是我的我正在寻找。

谢谢。

推荐答案

命令。命令通常是交互式功能,但也可以是键盘宏(以字符串或向量格式)。执行键盘宏会导致Emacs执行宏的键序列将导致的事情。

Keys are bound to commands. Commands are usually interactive functions, but can also be keyboard macros (in either string or vector format). Executing a keyboard macro causes Emacs to do the things which the macro's key sequences would cause to be done.

(kbd>)导致键盘宏>;所以你告诉Emacs,当 C - 。键入时,应该执行> 被打字。

(kbd ">") results in the keyboard macro ">"; so you have told Emacs that when C-. is typed, it should do the things which are done when > is typed.

通常(在大多数缓冲区中)> 将被绑定 self-insert-command ,因此键盘宏(kbd>) em>只需插入> 字符,但您已修改该绑定。

Normally (in most buffers) > would be bound to self-insert-command, and therefore the keyboard macro (kbd ">") would simply insert a > character, but you've modified that binding.

我相信你想将 C - 。绑定到插入> 字符的命令。这样的命令是:

I believe you want to bind C-. to a command which inserts a > character. Such a command is:

(lambda () (interactive) (insert ">"))

这篇关于emacs绑定键插入另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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