unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefankangas@gmail.com>
To: Augusto Stoffel <arstoffel@gmail.com>, 57885@debbugs.gnu.org
Subject: bug#57885: [PATCH] Add a command to restart the Python shell
Date: Sat, 17 Sep 2022 13:32:53 -0400	[thread overview]
Message-ID: <CADwFkmmo6-=aV5QmcpZWX0tDY-g0yPUcYLM6Tu4YL+i+tw4_dA@mail.gmail.com> (raw)
In-Reply-To: <875yhmapwr.fsf@gmail.com>

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)))





  parent reply	other threads:[~2022-09-17 17:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-17 17:09 bug#57885: [PATCH] Add a command to restart the Python shell Augusto Stoffel
2022-09-17 17:15 ` Eli Zaretskii
2022-09-17 17:36   ` Augusto Stoffel
2022-09-17 17:32 ` Stefan Kangas [this message]
2022-09-17 17:39   ` Augusto Stoffel
2022-09-17 18:04     ` Stefan Kangas
2022-09-18  6:53       ` Augusto Stoffel
2022-09-18 10:53         ` Lars Ingebrigtsen
2022-09-19  3:32     ` Richard Stallman
2022-09-19  7:20       ` Augusto Stoffel
2022-09-28  2:52         ` Richard Stallman
2022-09-28  6:36           ` Augusto Stoffel
2022-09-29  3:00             ` Richard Stallman
2022-09-29  7:09               ` Augusto Stoffel
2022-10-07 22:47                 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmmo6-=aV5QmcpZWX0tDY-g0yPUcYLM6Tu4YL+i+tw4_dA@mail.gmail.com' \
    --to=stefankangas@gmail.com \
    --cc=57885@debbugs.gnu.org \
    --cc=arstoffel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).