On Apr 12, 2021, at 5:32 AM, Lars Ingebrigtsen <larsi@gnus.org> wrote:
I was unable to reproduce this (in Emacs 28). I pasted this into the *Python* buffer:
Pasting multiple lines constitutes a single command for post-command-hook. In that case you would not expect to see any repeated lines.
Do you have a step-by-step recipe, starting from "emacs -Q", to reproduce this problem?
emacs -Q
M-x run-python
C-x 5 b “ *Python-font-lock*”
In inferior python shell: type any line.
C-c SPC (`comint-accumulate’) to continue.
Type another line. Notice the first line is repeated.
Repeat steps 5 & 6 several times.
The issue is how input is gathered from the prompt to the end of shell buffer in the post-command-hook:
(let* ((input (buffer-substring-no-properties
prompt-end (point-max)))
Line-at-a-time also won’t be able to handle editing lines before the last. On emacs-devel Stefan has been helpful with some ideas to perform font lock in-place in the shell buffer, which is working well in my tests. I’m using that as part of a package to implement true multi-line editing (ala iPython).