[ESS] Changing keybindings in the interactive R shell

Grant Rettke gcr at wisdomandwonder.com
Fri Oct 31 16:17:34 CET 2014


Use the key-chord package

http://melpa.org/#/key-chord

And set up a chord using available key on your keyboard.

- and = for example might be a good option for inserting a tilde using
your helper function.

On Fri, Oct 31, 2014 at 3:14 AM, Lucas Holland <hollandlucas at gmail.com> wrote:
> Hi Vitalie,
>
> thanks for your reply. The reason I want to do such a foolish thing is because my keyboard (Mac) doesn’t have a tilde key. By default, Alt-n produces a tilde (this is OS-wide). That’s why I thought it would make sense to stick with that convention for Emacs (so I don’t have a different keybinding for one program) and to bind comint-next-matching-input-from-input to something else other than M-n.
>
> What would you do in such a situation?
>
> Thanks!
>
>
>
>>
>>
>>>>> Lucas Holland on Thu, 30 Oct 2014 11:52:26 +0100 wrote:
>>
>> [...]
>>
>>> (add-hook 'inferior-ess-mode-hook
>>>          '(lambda()
>>>             (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
>>   repls.
>>
>> - 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.
>>
>>
>>  Vitalie
>
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



-- 
Grant Rettke
gcr at wisdomandwonder.com | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson



More information about the ESS-help mailing list