[ESS] Changing keybindings in the interactive R shell
spinuvit at gmail.com
Thu Oct 30 23:11:02 CET 2014
>>> Lucas Holland on Thu, 30 Oct 2014 11:52:26 +0100 wrote:
> (add-hook 'inferior-ess-mode-hook
> (local-set-key [\M-n] '(lambda () (interactive) (insert "~")))
This is a wrong syntax. A couple of related points first:
- Don't overwrite useful keys like M-n to unrelated commands. If you
go to that path you will have to overwrite them for all other
- How is pressing M-n better than "~"? You are forgoing a handy key for
the sake of a symbol which is already on the keyboard.
- M-n is a comint key so you will probably want to hook it into
comint-mode-map to have the same functionality across all repls.
So, the right syntax and recommended bindings are:
(define-key comint-mode-map [(meta ?p)] 'comint-previous-matching-input-from-input)
(define-key comint-mode-map [(meta ?n)] 'comint-next-matching-input-from-input)
(define-key comint-mode-map [(control meta ?n)] 'comint-next-prompt)
(define-key comint-mode-map [(control meta ?p)] 'comint-previous-prompt)
For ess use `inferior-ess-mode-map` instead of `comint-mode-map`.
For most people `comint-previous-matching-input-from-input` is one of
the most commonly used commands. You better get used to it also.
More information about the ESS-help