When using python-mode in Emacs, I first split the screen via C-x 3.
I'd like to be able do C-c ! to launch py-shell in the other window, not in the window currently active. How can I configure Emacs to do that without having to switch windows with C-x o before launching the shell?
I'm using Emacs 24.3.1, and I've got all my configuration files in ~/.emacs.d.
I just installed the python-mode package using package-install with the Marmalade repository, and I haven't yet edited any .el file related to python-mode.
As @BleedingFingers says you can simply use a macro and bind that to a key. It's up to you whether or not you want to re-use the C-c ! binding for the macro or bind it to a different key.
Here's how to proceed should you decide to go with the macro option, starting with Emacs showing only a single window:
Define macro
F3
C-x 3
C-x o
M-x
py-shellRETC-x o
F4
Assign name to macro
M-x
name-last-kbd-macroRETpy-shell-other-windowRETYou can replace
py-shell-other-windowwith whatever name you would like to use for the macro.Add macro to your configuration
Open your configuration file, move point (cursor) to an empty line and do
M-x
insert-kbd-macroRETThis will insert the macro definition into your configuration file.
Bind macro to key
Add the following code to your configuration file to bind the macro to a key in
python-mode:Turn key binding on
Mark the lines added in the previous step and run M-x
eval-regionRET, or simply restart Emacs.Celebrate :)