It is not a good idea to change the global map for this as this answer recommends: it affects far more than the binding that you want to change which is only valid inside the Ediff Control Panel buffer. In particular, it will affect how >
is handled in fundamental mode, text modes, programming modes - anywhere where the mode itself does not redefine >
, so its definition would be fetched from the global map. When you type >
in such a buffer, you will get an error message: ediff-toggle-help: This command runs in Ediff Control Buffer only!
.
You need to change it in the appropriate keymap, the one that corresponds to the major mode of the Ediff Control Panel buffer. In this case, that is the keymap called ediff-mode-map
.
You can do that (using the "new" interface from keymap.el
) like this:
(keymap-set ediff-mode-map ">" #'ediff-toggle-help)
However, putting the above in your init file will not work. ediff-mode-map
is not defined at that point. The usual solution is to do the mapping in a function that is called from the major mode hook, but that solution does not work here because ediff-mode-map
is a local keymap to each Ediff Control Panel and is not defined when the mode hook is run. But ediff
provides a number of hooks (do C-h v ediff--hook<TAB>
to see a completion buffer with all twenty-seven of them): the problem is to find one that is run after the local ediff-mode-map
is defined and populated. The one I picked certainly satisfies this condition but it may not be the only one: it is ediff-startup-hook
. The code that you should put in your init file then looks like this:
(defun my/ediff-mode-bindings ()
(keymap-set ediff-mode-map ">" #'ediff-toggle-help))
(add-hook 'ediff-startup-hook #'my/ediff-mode-bindings)
Lightly tested.
Note that the above will overwrite the current binding of >
in ediff-mode-map
, which by default is the function ediff-scroll-horizontally
. If you need that function, you can always do M-x ediff-scroll-horizontally
. But it is probably better to use a different key, one that is not currently used in ediff-mode-map
. Assuming that the inverted ?
is easily typed on your keyboard, maybe use that instead?