[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
python-shell-send-string changes break continued Python commands
From: |
JD Smith |
Subject: |
python-shell-send-string changes break continued Python commands |
Date: |
Sat, 11 Feb 2023 09:39:06 -0500 |
I’ve noticed some breaking changes to the function python-shell-send-string in
the recent past, related to continued commands.
Example of a continued Python command:
>>> for i in range(12):
…
I maintain a package called python-mls [1] which enables sending multi-line
statements to the inferior python process. It works by noticing the “…”
continuation prompt python provides on continued commands, interrupting, and
allowing Emacs to format and send its own multiline command (check the link for
a GIF of it in action).
Unfortunately, the new logic of `python-shell-send-string’ defeats all
continued commands, since it wraps even simple single line statements like “if
True:” in the helper function __PYTHON_EL_eval(). This helper will attempt to
compile the statement, breaking “continued commands” as above.
Single-line commands do not need any special treatment when sending to the
python interpreter, and are likely the most common type of command sent.
To reenable continued command functionality as well as for efficiency, simply
using `comint-send-string' for single-line command input, as before, would be a
suitable fix. Pseudo-code:
(if (string-match ".\n+." string) ;Multiline.
(new-PYTHON_EL_eval_functionality…)
(comint-send-string process string))
I’m happy to put a patch together if this sounds sensible.
[1] https://github.com/jdtsmith/python-mls
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- python-shell-send-string changes break continued Python commands,
JD Smith <=