key-translation-map 的按键如何在特定的mode下表现为别的功能?

(define-key key-translation-map (kbd "s-a") (kbd "C-g"))

我把 s-a 绑定成 C-g,又想在某些特殊的情节中解放s-a, 比如在 magit 写 commit message 的时候,我希望 s-a 的行为是 with-editor-cancel 。

但是怎么写都不如 key-translation-map 优先级高的样子

“解放”就是让低优先级的其他map起作用?那可以给magit加个hook,(define-key key-translation-map (kbd "s-a") nil)(解绑),然后退出magit的时候再map回来?

1 个赞