[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#57885: [PATCH] Add a command to restart the Python shell
From: |
Augusto Stoffel |
Subject: |
bug#57885: [PATCH] Add a command to restart the Python shell |
Date: |
Sat, 17 Sep 2022 19:39:10 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
On Sat, 17 Sep 2022 at 13:32, Stefan Kangas wrote:
> 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.
Okay, then let's decide later (or not decide :-)).
> 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.
Okay
>> + (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?
>
No, and if fact, if the process is dead, you want to call this command
to start the shell again (it happens to me and it works).
0001-lisp-progmodes-python.el-python-shell-restart-New-co.patch
Description: Text Data
- 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, 2022/09/17
- bug#57885: [PATCH] Add a command to restart the Python shell,
Augusto Stoffel <=
- 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