I'm using emacs 26.1 with ESS. Whenever I open a R session with M-x R it opens in a random window. However, I would like it to open in the currently selected window.

It seems to be a similar issue as here emacs opens shells in a random window, how to change this? but the provided solution does not work for me.

1 Answer 1


I am using the package shackle for that. After the package is installed the following setting should do what you want

(setq shackle-rules '(("*R:?[0-9]?*" :regexp t :same t)))
(shackle-mode 1)

If you do not want to use an external package you might be able to adapt this answer https://emacs.stackexchange.com/a/13585/15268 to your needs.

Note: the regexp R:?[0-9]? ensures that the setting applies to all intances of R. The buffer with the first instance is called *R* and the second is *R:2* etc. on my system.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.