Search code examples
remacsdot-emacs

Backward kill in R session in emacs


I have one more question about customizing emacs for use with an R session. I like to use the backward kill function, but this deletes the command prompt in the R session. I have tried modifying the function

 ;; Kill to the start of the command line for R
 (defun backward-kill-r ()
   "Kill chars backward until encountering the end of a line."
   (interactive)
   (delete-region (point-at-bol) (point)))

But I get the same prompt-deleting behavior. I'm guessing that I can change point-at-bol to correct this, but what do I need to change it to? Thanks!


Solution

  • C-c C-u does what you want already. I find C-a C-k to be the easiest way to do this though, as I use C-a (move to the beginning of the line, which does the right thing in iESS mode) and C-k (kill line) are part of my emacs 'muscle-memory'.

    FYI, instead of point-at-bol you want comint-bol, which will give you the behaviour you're after, if you don't want to use either of the suggestions above.