jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 260 forks source link

How to restart python process in same buffer #2036

Closed uliw closed 11 months ago

uliw commented 11 months ago

While developing, I frequently need to reload modules and submodules, so I have the following function to restart the python process:

(defun elpy-shell-restart-and-send-region-or-buffer (arg)
  "Send the region of buffer after restarting the shell."
  (interactive "P")
  (elpy-shell-kill t)
  (elpy-shell-send-region-or-buffer arg))

However, that allways starts a new window for the new process, which becomes quite messy over time. settting

(add-to-list 'display-buffer-alist
     '("\\*Python\\*" display-buffer-reuse-mode-window))

does not help either. And yes, I am aware that ipython has reload magic, but last time I checked, the ipython output had no way of linking error messages back into the source code. Which is alo quite handy to have.

uliw commented 11 months ago

never mind. Setting (elpy-shell-kill nil) in yteh above code solves the problem