This answer how to map C-c !
to create a new python shell for the current buffer.
The main code is this:
(defun my-python-start-or-switch-repl (&optional msg)
"Start and/or switch to the REPL."
(interactive "p")
(if (python-shell-get-process)
(python-shell-switch-to-shell)
(progn
(run-python (python-shell-calculate-command) t t)
(python-shell-switch-to-shell)
)
)
)
As it can be seen, it uses run-python
, so it only opens a shell that has the name of the buffer it was opened it from, e.g., if the program is foo.py
, then the shell has the name: *Python[foo.py]*
, but it doesn't run foo.py
. Is there a way to have dedicated shells that by default run the program from which they being generated?