Now in 27.1, things are different. I say C-c C-c and it tells me to
start the process with C-c C-p. I mean --- is that the most polite
thing to do? I feel like it's telling me --- go send this buffer
yourself!
Meredith Montgomery <mmontgomery@levado.to> writes:
Now in 27.1, things are different. I say C-c C-c and it tells me to
start the process with C-c C-p. I mean --- is that the most polite
thing to do? I feel like it's telling me --- go send this buffer
yourself!
Hmm, I noticed that too, but I thought it was a change in python-mode
itself. I just got used to it. I didn't bother trying to chase it down.
To start a new process, try C-u C-c C-p .
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.
Meredith Montgomery <mmontgomery@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.
(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))
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.)
Meredith Montgomery <mmontgomery@levado.to> writes:
Meredith Montgomery <mmontgomery@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.
(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))
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.)
It's not easy to restart the REPL. You can send "quit()" to it and
invoke run-python again interactively by typing out one command after another, but if you write a procedure such as this one below, it doesn't work: it gives me the impression that there's a timing issue, that is, perhaps the procedure is too fast and something happens before it
should.
(defun python-save-send-buffer-to-repl ()
(interactive)
(save-buffer)
(python-shell-send-string "quit()")
(run-python)
(python-shell-send-buffer)
(python-shell-switch-to-shell))
On Sun, 04 Sep 2022 16:47:07 -0300 Meredith Montgomery <mmontgomery@levado.to> wrote:
Meredith Montgomery <mmontgomery@levado.to> writes:
Meredith Montgomery <mmontgomery@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.
(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))
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.)
It's not easy to restart the REPL. You can send "quit()" to it and
invoke run-python again interactively by typing out one command after
another, but if you write a procedure such as this one below, it doesn't
work: it gives me the impression that there's a timing issue, that is,
perhaps the procedure is too fast and something happens before it
should.
(defun python-save-send-buffer-to-repl ()
(interactive)
(save-buffer)
(python-shell-send-string "quit()")
(run-python)
(python-shell-send-buffer)
(python-shell-switch-to-shell))
It does seem like a timing issue. This works for me:
(defun python-save-send-buffer-to-repl ()
(interactive)
(save-buffer)
(python-shell-send-string "quit()")
(sit-for 0.1)
(run-python)
(python-shell-send-buffer)
(python-shell-switch-to-shell))
But if I decrease the wait to 0.05 it doesn't work.
Process Python finished
Traceback (most recent call last):
Traceback (most recent call last):hello
--8<---------------cut here---------------end--------------->8---
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 75:44:04 |
Calls: | 6,716 |
Calls today: | 4 |
Files: | 12,247 |
Messages: | 5,357,403 |