[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#57885: [PATCH] Add a command to restart the Python shell
From: |
Stefan Kangas |
Subject: |
bug#57885: [PATCH] Add a command to restart the Python shell |
Date: |
Sat, 17 Sep 2022 13:32:53 -0400 |
Augusto Stoffel <arstoffel@gmail.com> writes:
> I think "C-c C-n" would be a reasonable keybinding, but since I can't
> find any precedent, I didn't include a keybinding.
`C-c C-n' is usually used to go to the next thing, so maybe we could try
to find some better key.
Looks good to me (but I didn't test it), with two minor comments:
> +(defun python-shell-restart (&optional show)
> + "Restart the Python shell.
> +With a prefix argument, also SHOW the buffer."
> + (interactive "P")
> + (with-current-buffer
> + (or (when (derived-mode-p 'inferior-python-mode)
> + (current-buffer))
As a minor style point, I'd prefer:
(and (derived-mode-p 'inferior-python-mode)
(current-buffer))
to make it clear that we want the value.
> + (seq-some (lambda (dedicated)
> + (get-buffer (format "*%s*"
> (python-shell-get-process-name
> + dedicated))))
> + '(buffer project nil))
> + (user-error "No Python shell"))
> + (when-let ((proc (get-buffer-process (current-buffer))))
> + (kill-process proc)
> + (while (accept-process-output proc)))
Should there be an error here if there is no running process?
> + (python-shell-make-comint (python-shell-calculate-command)
> + (string-trim (buffer-name) "\\*" "\\*")
> + show)))
- bug#57885: [PATCH] Add a command to restart the Python shell, Augusto Stoffel, 2022/09/17
- bug#57885: [PATCH] Add a command to restart the Python shell, Eli Zaretskii, 2022/09/17
- bug#57885: [PATCH] Add a command to restart the Python shell,
Stefan Kangas <=
- bug#57885: [PATCH] Add a command to restart the Python shell, Richard Stallman, 2022/09/18
- bug#57885: [PATCH] Add a command to restart the Python shell, Augusto Stoffel, 2022/09/19
- bug#57885: [PATCH] Add a command to restart the Python shell, Richard Stallman, 2022/09/27
- bug#57885: [PATCH] Add a command to restart the Python shell, Augusto Stoffel, 2022/09/28
- bug#57885: [PATCH] Add a command to restart the Python shell, Richard Stallman, 2022/09/28
- bug#57885: [PATCH] Add a command to restart the Python shell, Augusto Stoffel, 2022/09/29