重新定义 emacs 中的键ENSIME scala 模式
我正在尝试重新定义“M-”。在 ENSIME 模式下,以便它运行自动完成而不是 ensime-edit-definition。这是默认绑定。我在 .emacs 中有以下代码:
(defun my-scala-mode()
(ensime-mode)
(local-set-key [return] 'newline-and-indent)
(local-unset-key (kbd "M-."))
(local-set-key (kbd "M-.") 'auto-complete)
(global-unset-key (kbd "M-."))
(global-set-key (kbd "M-.") 'auto-complete)
;(scala-electric-mode)
(yas/minor-mode-on))
(add-hook 'scala-mode-hook 'my-scala-mode)
但是,一旦加载 ensime 模式,就会以某种方式将键重新定义回默认值。如果我注释掉“(ensime-mode)”,那么它映射正确。
我应该在这里做什么?我还缺少其他模式挂钩吗?或者顺序应该不同吗?
谢谢
I'm trying to redefine the "M-." in the ENSIME mode so that it runs auto-complete instead of ensime-edit-definition. Which is the default binding. I have the following code in the .emacs:
(defun my-scala-mode()
(ensime-mode)
(local-set-key [return] 'newline-and-indent)
(local-unset-key (kbd "M-."))
(local-set-key (kbd "M-.") 'auto-complete)
(global-unset-key (kbd "M-."))
(global-set-key (kbd "M-.") 'auto-complete)
;(scala-electric-mode)
(yas/minor-mode-on))
(add-hook 'scala-mode-hook 'my-scala-mode)
However, once ensime mode loads, and somehow redefines the keys back to the default. If I comment out "(ensime-mode)" then it maps correctly.
What should I do here? Is there another mode hook I'm missing? Or should the order be different?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然 ensime-mode 是一个次要模式,因此它的绑定优先于主要模式的绑定。 local-set-key 影响主要模式的绑定。您可能想要执行类似以下的操作(保证 100% 未经测试):
或者
Apparently ensime-mode is a minor-mode, so its bindings take precedence over the major-mode's bindings. And local-set-key affects the major mode's bindings. You might want to do something like the following (guarantedd 100% untested) instead:
or