1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Make `M-x run-python' select the window again

Interactively, we want M-x run-python to focus the interpreter buffer.
The previous code failed in two ways:

- the call to 'display-buffer' was not reached if an interpreter
  was already running,

- set-buffer is ineffectual if the interpreter's window is not
  selected: once Emacs returns to the command loop, the current buffer
  will revert back to what the selected window contains.

* lisp/progmodes/python.el (python-shell-make-comint): Handle the SHOW
argument regardless of whether an interpreter buffer exists, and use
pop-to-buffer to select the window.
(run-python): Delegate buffer management to
'python-shell-make-comint'.

* test/lisp/progmodes/python-tests.el
(python-tests--run-python-selects-window): Rename from
'python-tests--bug31398', and adjust assertions (bug#52380).
This commit is contained in:
Kévin Le Gouguec 2021-12-13 05:17:00 +01:00 committed by Lars Ingebrigtsen
parent 62139aeb42
commit 9bd3f78645
2 changed files with 14 additions and 8 deletions

View file

@ -2994,8 +2994,9 @@ killed."
(mapconcat #'identity args " ")))
(with-current-buffer buffer
(inferior-python-mode))
(when show (display-buffer buffer))
(and internal (set-process-query-on-exit-flag process nil))))
(when show
(pop-to-buffer proc-buffer-name))
proc-buffer-name))))
;;;###autoload
@ -3027,7 +3028,6 @@ process buffer for a list of commands.)"
(python-shell-make-comint
(or cmd (python-shell-calculate-command))
(python-shell-get-process-name dedicated) show)))
(set-buffer buffer)
(get-buffer-process buffer)))
(defun run-python-internal ()