Subject: bug#32390: 26.1; python.el: cleanup font lock buffer after input is sent

From: Carlos Pita <[email-masked]>
Date: Fri, 31 Aug 2018 08:56:58 -0300

My report was for ipython. I've attached a screenshot showing the problem.

The way I'm fixing this issue at the moment is by patching
python-shell-font-lock-comint-output-filter-function like this:

(defun python-shell-font-lock-comint-output-filter-function (output)
  "Clean up the font-lock buffer after any OUTPUT."
  (if (and (python-shell-comint-end-of-output-p
            (ansi-color-filter-apply output))
           (not (string-match "\\.\\.\\.: $" output)))
      ;; If output is other than an input prompt then "real" output has
      ;; been received and the font-lock buffer must be cleaned up.
      (python-shell-font-lock-cleanup-buffer)
    ;; Otherwise just add a newline.
    (python-shell-font-lock-with-font-lock-buffer
      (goto-char (point-max))
      (newline)))
  output)