But then, why bother round-tripping text out to a special-use buffer anyway,
vs. just letting font-lock operate in-situ in the shell buffer itself using
python-mode’s fairly simple font-lock-defaults. The only thing needed to
make this work is asking font-lock to ignore all the text with ‘field of
‘output?
Maybe you can try something like the following?
(defvar python--font-lock-keywords ...)
(defvar python-font-lock-keywords
'(python--apply-font-lock))
(defun python--apply-font-lock (limit)
(while (< (point) limit)
(let ((next-boundary (find-next-boundary limit)))
(if (we-should-skip-this-block)
(goto-char next-boundary)
(let ((font-lock-keywords python--font-lock-keywords))
(font-lock-ensure (point) limit))))))
-- Stefan