Charlie
Charlie

Reputation: 2851

Changing the home key behavior in an R session in emacs

I would like to change the behavior of the home key within an R session run from emacs. When I press the home key, it takes me all the way to the > prompt. I'd like the home key to take me to the start of the command entry (i.e., two points in from the start of the line). I assume that I can make this adjustments via my .emacs file; any guidance for the commands that I would need to add to that file would be appreciated. Thanks!

Upvotes: 1

Views: 99

Answers (1)

Tyler
Tyler

Reputation: 10032

The behaviour you want is already available as C-a. You can rebind the home key with the following line:

(local-set-key (kbd "<home>") 'comint-bol)

There are a number of ways to get this to happen automatically when you are using the R session. I use something like the following:

;; Define the keybinding you want
(defun my-inferior-ess-mode-hook ()
  (local-set-key (kbd "<home>") 'comint-bol))

;; add the key-binding to the hook that gets called whenever you start an R session:
(add-hook 'inferior-ess-mode-hook 'my-inferior-ess-mode-hook)

That's a bit much for a single key-binding, but you can extend the definition of my-inferior-ess-mode-hook to include a number of customizations you'd like to use.

Upvotes: 1

Related Questions