diff options
| author | Kévin Le Gouguec | 2021-12-13 05:17:00 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-12-13 05:17:00 +0100 |
| commit | 9bd3f78645e14fdbaf3a569df5e0a52249c4f90e (patch) | |
| tree | 137b73a22f01899457e0a5eac03339b72e031d42 /lisp/progmodes/python.el | |
| parent | 62139aeb42e286b51afe7dd6045ba7f5519593fc (diff) | |
| download | emacs-9bd3f78645e14fdbaf3a569df5e0a52249c4f90e.tar.gz emacs-9bd3f78645e14fdbaf3a569df5e0a52249c4f90e.zip | |
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).
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index f1c3e75bb73..6357c4f2d3e 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -2994,8 +2994,9 @@ killed." | |||
| 2994 | (mapconcat #'identity args " "))) | 2994 | (mapconcat #'identity args " "))) |
| 2995 | (with-current-buffer buffer | 2995 | (with-current-buffer buffer |
| 2996 | (inferior-python-mode)) | 2996 | (inferior-python-mode)) |
| 2997 | (when show (display-buffer buffer)) | ||
| 2998 | (and internal (set-process-query-on-exit-flag process nil)))) | 2997 | (and internal (set-process-query-on-exit-flag process nil)))) |
| 2998 | (when show | ||
| 2999 | (pop-to-buffer proc-buffer-name)) | ||
| 2999 | proc-buffer-name)))) | 3000 | proc-buffer-name)))) |
| 3000 | 3001 | ||
| 3001 | ;;;###autoload | 3002 | ;;;###autoload |
| @@ -3027,7 +3028,6 @@ process buffer for a list of commands.)" | |||
| 3027 | (python-shell-make-comint | 3028 | (python-shell-make-comint |
| 3028 | (or cmd (python-shell-calculate-command)) | 3029 | (or cmd (python-shell-calculate-command)) |
| 3029 | (python-shell-get-process-name dedicated) show))) | 3030 | (python-shell-get-process-name dedicated) show))) |
| 3030 | (set-buffer buffer) | ||
| 3031 | (get-buffer-process buffer))) | 3031 | (get-buffer-process buffer))) |
| 3032 | 3032 | ||
| 3033 | (defun run-python-internal () | 3033 | (defun run-python-internal () |