on GNU EMACS's python-mode, loading entire buffer

Meredith Montgomery mmontgomery at levado.to
Wed Aug 31 09:40:13 EDT 2022


Meredith Montgomery <mmontgomery at levado.to> writes:

[...]

> I would also be interested in a command that restarts the REPL afresh
> and reloads my buffer --- sort of like keyboard's [F5] of the IDLE.

A partial solution for this is the following procedure.

--8<---------------cut here---------------start------------->8---
(defun python-revert-and-send-buffer-to-repl ()
  "Revert current buffer and sends it to the Python REPL."
  (interactive)
  (revert-buffer "ignore-auto-no" "no-confirm")
  (python-shell-send-buffer))
--8<---------------cut here---------------end--------------->8---

We can map this to the F5-key and that improves things.  But a restart
of the REPL would be the ideal.  (Sometimes we really want to start
afresh.  Sometimes.  Most often we don't want that.)


More information about the Python-list mailing list