问题描述
这可能很简单,但是我在谷歌搜索时没有发现任何有用的东西。所以这里是:)
This is perhaps quite simple, but I haven't found anything useful when googling. So here it goes :)
我在守护进程模式下使用Emacs( emacs --daemon
),它真的很方便。我也使用dvorak,并发现重新映射到(反之亦然)从长远来看非常方便,并使用以下内容进行翻译: p>
I use Emacs in daemon mode (emacs --daemon
) and it's really handy. I also use dvorak and have found that remapping to (and vice versa) is really handy in the long run, and use the following for making that translation:
(keyboard-translate ?\C-j ?\C-c)
(keyboard-translate ?\C-c ?\C-j)
当使用Emacs作为守护进程不当我启动一个新客户端(cli / gui)时,C-j 不再绑定到。 Whaaat?
This works great when not using Emacs as a daemon. When I start a new client (cli/gui) is no longer bound to . Whaaat?
所以我想在创建一个新的客户端框架后,我需要运行 keyboard-translate
但我不知道该怎么做。我尝试过一个 defadvice
我发现某处,但无法使其工作,所以我放弃了并删除它。
So I guess I'll need to run the keyboard-translate
after creating a new client frame, but I have no idea how to do it. I've tried with a defadvice
I found somewhere, but couldn't make it work so I gave up and removed it.
推荐答案
keyboard-translate
说:
这些指示我们正确的方向,虽然有一个错误在该文档中,引用的信息节点不存在。搜索表明节点实际上被重命名为(elisp)多个终端
,您也可以在这里阅读: http://www.gnu.org/s/emacs/manual/html_node/elisp/Multiple-Terminals.html
which points us in the right direction, although there's an error in that documentation, as the referenced info node doesn't exist. A search suggests that the node is actually renamed (elisp)Multiple terminals
, which you can also read here: http://www.gnu.org/s/emacs/manual/html_node/elisp/Multiple-Terminals.html
所以当您启动emacs作为守护进程时,您尚未连接到终端(或至少不连接到终端对您有用),因此您的命令不会为您最终使用的终端生成绑定。
So when you start emacs as a daemon, you have not yet connected to a terminal (or at least, not to one that is useful to you), and so your commands do not generate bindings for the terminal(s) that you end up using.
after-make框架函数
变量提供了一种解决方法。
The after-make-frame-functions
variable provides one way to resolve this.
(defun my-dvorak-translations (&optional frame)
"Re-map keys in the current terminal."
(keyboard-translate ?\C-j ?\C-c)
(keyboard-translate ?\C-c ?\C-j))
;; Evaluate both now (for non-daemon emacs) and upon frame creation
;; (for new terminals via emacsclient).
(my-dvorak-translations)
(add-hook 'after-make-frame-functions 'my-dvorak-translations)
在实验上,重复你的命令是安全的,所以我们不需要担心每个终端只执行一次(但是如果我们这样做,我们可以使用(get-device-terminal FRAME)
来帮助)。
Experimentally it appears safe to repeat your commands, so we don't need to worry about only executing this once per terminal (but if we did, we could use (get-device-terminal FRAME)
to help with that).
这篇关于在Emacs中,使用守护程序/客户机在新框架上运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!