[deleted] · 2022-11-21 10:11
[deleted]
AsterOps · 2022-11-21 11:31
You answered on your question.
jobbflykt · 2022-11-21 11:35
run-python, C-c C-p, can be advised to switch back to the previous window.
(defun advice-run-python (&optional CMD DEDICATED SHOW)
"Switch back to previous window.
C-c C-p is usually invoked from a .py-buffer, with the intention to do
C-c C-c next."
(other-window 1))
(advice-add 'run-python :after 'advice-run-python)
[deleted] · 2022-11-21 14:50
[deleted]
jobbflykt · 2022-11-22 07:23
For extra credit, here is an advice that displays the \*Python\* buffer when doing C-c C-c if it's not already visible.
(defun advice-python-shell-send-buffer (&optional SEND-MAIN MSG)
"Display *Python* buffer if it exists and is not already visible. Used for C-c C-c in a python source buffer."
(let ((name "*Python*"))
;; We want to display the buffer if it's not in a
;; window already.
(unless (get-buffer-window name t)
(display-buffer name 'display-buffer-in-previous-window))))
(advice-add 'python-shell-send-buffer :after
'advice-python-shell-send-buffer)
[deleted] · 2022-11-22 08:23
[deleted]
jobbflykt · 2022-11-22 11:51
No, advice-run-python is separate from advice-python-shell-send-buffer. The latter is just a convenient way to show the \*Python\* buffer after doing C-c C-c if it has become hidden. One can use one of them or both independently.
[deleted] · 2022-11-22 11:57
[deleted]