emacs -- 按键绑定问题

发布于 2024-10-11 17:38:03 字数 1736 浏览 5 评论 0原文

我已成功使用 Ctrl+Shift+Up ' Ctrl+Shift+down '

Ctrl+Shift+left' Ctrl+Shift+正确的不同的命令。但是当我

尝试使用 Ctrl+s 命令 save-buffer 和 Ctrl+Shift+s 时,

相当于 Ctrl+S ,到另一个命令,它有一些问题。

save-buffer 工作正常,但是当我输入 Ctrl+Shift+s 时,它会执行

命令 save-buffer。我使用 Ctrl+q 查找

Ctrl+sCtrl+Shift+S 的控制序列,得到相同的结果,即^S

我预计 Ctrl+s 会得到 ^s,但事实并非如此。

有人知道原因吗?

另一个问题是:我使用Ctrl+c作为命令killing-ring-save。在这种

情况下,所有以 Ctrl+c 开头的命令(数量较多)现在都不起作用。

有没有办法用另一个自定义前缀替换前缀 Ctrl+c


我可能会向错误的方向提出问题。我使用ctrl+c作为

kill-ring-save。它在 emacs 中运行良好(无模式)。但是,如果我打开 .c 文件(C 模式),那么

当我键入 Ctrl+c 时,它会等待我键入另一个键。我认为在这种情况下,

ctrl+c被视为前缀。在这种情况下,我需要进行以下修改:

使用自定义的前缀,例如 Ctrl+a ,如 Ctrl+c ;删除

前缀 Ctrl+c ;使用Ctrl+c作为杀戮环保存。

我将以下内容添加到我的 ~/.emacs 中:

(global-set-key (kbd "Ca") mode-specific-map)

(global-set-key (kbd "Cc") 'kill-ring-save)

(global -set-key (kbd "Cf") 'isearch-forward)

(global-set-key (kbd "Cv") 'yank)

(global-set-key (kbd "Cs") 'save-buffer)

(defun my -c-initialization-hook ()

(define-key c-mode-base-map (kbd "Ca") 模式特定映射)

(define-key c-mode-base-map (kbd "Cc") 'kill -ring-save))

(add-hook 'c-initialization-hook 'my-c-initialization-hook)

但这不起作用。 Ctrl+c 仍然被视为前缀,所以我不能将其用作

kill-ring-save。此外,如果我输入 Ctrl+a Ctrl+c,它表示它未定义

。 (我认为它会得到与我输入 Ctrl+c Ctrl+c 相同的结果)

I have successfully used Ctrl+Shift+Up ' Ctrl+Shift+down '

Ctrl+Shift+left' Ctrl+Shift+Right to different commands. But when I

tried to use Ctrl+s to the command save-buffer and Ctrl+Shift+s, which

is equivalent to Ctrl+S, to another command, it has some problem.

save-buffer works fine, but when I type Ctrl+Shift+s, it excute

the command save-buffer. I used Ctrl+q to find the control sequences of

Ctrl+s and Ctrl+Shift+S, I get the same result, which is ^S.

I expect that I will get ^s for Ctrl+s, but it doesn't.

Anyone knows the reason?

Another queston is: I use Ctrl+c for the command killing-ring-save. In this

case, all commands (which are of large number) begin with Ctrl+c don't work now.

Is there a way to replace the prefix Ctrl+c by another customized prefix?


I may pose my question in the wrong direction. I use ctrl+c as

killing-ring-save. It works fine in emacs (no mode). But if I open a .c file (C-mode), then

when I type Ctrl+c, it waits me to type another key. I think in this case,

ctrl+c is regarded as a prefix. In this case, I need the following modifications:

Using a custom defined prefix, say Ctrl+a, as Ctrl+c ; Remove the

prefix Ctrl+c ; Using Ctrl+c as killing-ring-save.

I add the following to my ~/.emacs :

(global-set-key (kbd "C-a") mode-specific-map)

(global-set-key (kbd "C-c") 'kill-ring-save)

(global-set-key (kbd "C-f") 'isearch-forward)

(global-set-key (kbd "C-v") 'yank)

(global-set-key (kbd "C-s") 'save-buffer)

(defun my-c-initialization-hook ()

(define-key c-mode-base-map (kbd "C-a") mode-specific-map)

(define-key c-mode-base-map (kbd "C-c") 'kill-ring-save))

(add-hook 'c-initialization-hook 'my-c-initialization-hook)

But this doesn't work. Ctrl+c is still regarded as a prefix, so I can't use it

as kill-ring-save. Furthermore, if I type Ctrl+a Ctrl+c, it said it's not

defined. (I thought it will have the same result as I type Ctrl+c Ctrl+c)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

木槿暧夏七纪年 2024-10-18 17:38:03

Cc 绑定很棘手,CUA 模式很好地解决了这个问题,只有在标记了区域时才使其执行kill-ring-save。

The C-c binding is tricky, CUA mode solves it well, by only making it do kill-ring-save when you have a region marked.

垂暮老矣 2024-10-18 17:38:03

首先,Control-S 是一个 ASCII 控制字符 - ^s^S 是相同的字符。

然而,键与字符不同,如果您将 Emacs 与窗口管理器一起使用,那么您可以区分键 CsCSs。后者是 Control-Shift-s。

您遇到的问题是,如果您没有显式绑定字母键的移位版本,则移位字母键将使用未移位键的绑定。这是一个“特点”。

所以你需要绑定CsCSs

(global-set-key (kbd "C-s") 'save-buffer)
(global-set-key (kbd "C-S-s") 'another-command)

First, Control-S is an ASCII control character -- ^s and ^S are the same character.

Keys are something different from characters, however, and if you are using Emacs with a window manager then you can distinguish the keys C-s and C-S-s. The latter is Control-Shift-s.

The problem you are hitting is that if you do not explicitly bind the shifted version of a letter key, then the shifted letter key uses the binding of the unshifted key. This is a "feature".

So you need to bind both C-s and C-S-s.

(global-set-key (kbd "C-s") 'save-buffer)
(global-set-key (kbd "C-S-s") 'another-command)
寂寞清仓 2024-10-18 17:38:03

如果您在终端中运行 emacs,则 shift-ctl-c 问题的原因可能是终端驱动程序。在这种情况下,请输入命令 stty stop undef,然后再次运行 emacs,看看是否会影响问题。另外,看看你是否在使用shift-ctl-其他字母时遇到同样的问题

If you're running emacs in a terminal, then the reason for the shift-ctl-c issue could be the terminal driver. In that case, give the command stty stop undef, then run emacs again, and see if it affects the problem. Also, see if you get same problem with shift-ctl-other letters

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文