5

我正在尝试ErgoEmacs模式,看看我是否可以更舒适地使用 Emacs。它的一些键绑定相当直观,但在许多情况下,我不想完全替换默认值。

例如,在 ErgoEmacs 的导航快捷结构的上下文中,Mh 作为 Ca 的替代品是有意义的——但我希望能够同时使用两者,而不仅仅是 Mh。我尝试简单地复制命令:

;; Move to beginning/ending of line
(defconst ergoemacs-move-beginning-of-line-key   (kbd "C-a")) ; original
(defconst ergoemacs-move-end-of-line-key         (kbd "C-e")) ; original
(defconst ergoemacs-move-beginning-of-line-key   (kbd "M-h")) ; ergoemacs
(defconst ergoemacs-move-end-of-line-key         (kbd "M-H")) ; ergoemacs

但是 Emacs 只是简单地用第二个键绑定覆盖了第一个键绑定。解决这个问题的最佳方法是什么?

4

3 回答 3

4

要从 ergo-emacs 邮件列表重新发布回复:

夏李说:

这很容易。
在 ergoemacs-mode.el 文件中,有这一行(加载“ergoemacs-unbind”)只需将其注释掉即可。这应该是你需要做的所有事情。但是,请注意,ErgoEmacs 键绑定定义了那些常用的快捷键,例如 Open、Close、New、Save... 使用键 Ctrl+o、Ctrl+w、Ctrl+n、Ctrl+s 等。其中大约 7 个左右。所以,我认为其中一些将使用 Ctrl 打击 emacs 传统绑定。如果您是 ErgoEmacs 的新手并尝试探索它,您可以尝试从几个键开始。此页面可能包含一些有用的信息: http ://code.google.com/p/ergoemacs/wiki/adoption 感谢您查看 ErgoEmacs!
Xah ∑ http://xahlee.org/

于 2010-06-15T22:38:48.173 回答
3

事实证明,ErgoEmacs 使用两个文件来定义键绑定。一个是主ergoemacs-mode.el文件,另一个是您选择的特定键盘布局(例如ergoemacs-layout-us.el)。后一个文档创建一个常量,前者用于创建键绑定。因此,当我认为我在复制键绑定时,我实际上是在更改随后用于该目的的常量。

解决方案:

在 ergomacs-mode.el 中:

;; Move to beginning/ending of line
(define-key ergoemacs-keymap ergoemacs-move-beginning-of-line-key 'move-beginning-of-line)
(define-key ergoemacs-keymap ergoemacs-move-end-of-line-key 'move-end-of-line)
(define-key ergoemacs-keymap ergoemacs-move-beginning-of-line-key2 'move-beginning-of-line)  ; new
(define-key ergoemacs-keymap ergoemacs-move-end-of-line-key2 'move-end-of-line)  ; new

在 ergoemacs-layout-us.el 中:

;; Move to beginning/ending of line
(defconst ergoemacs-move-beginning-of-line-key  (kbd "M-h"))
(defconst ergoemacs-move-end-of-line-key        (kbd "M-H"))
(defconst ergoemacs-move-beginning-of-line-key2 (kbd "C-a"))    ; new
(defconst ergoemacs-move-end-of-line-key2       (kbd "C-e"))    ; new
于 2010-06-15T21:33:54.213 回答
2

嗯?ErgoEmacs 的一些黄金原则是否对每个功能都有一种且只有一种方式?因为普通键绑定的工作方式完全相反:您一次命名一个键并指定它应该做什么。如果一种模式定义了一个全局变量来表示“行尾绑定的键”,那么当然只能有一个值,但是使用正常的绑定命令,您可以将相同的函数绑定到尽可能多的组合你喜欢。事实上,我见过的每一个键绑定看起来都像这样

(global-set-key [(meta space)] 'just-one-space)

或者像这样

(add-hook 'c-mode-hook 'my-c-mode-hook)
(defun my-c-mode-hook ()
  (define-key c-mode-map [(control c) b] 'c-insert-block))

如果它仅适用于特定模式。

于 2010-06-15T19:27:20.833 回答