Function: python-shell-font-lock-post-command-hook
python-shell-font-lock-post-command-hook is a byte-compiled function
defined in python.el.gz.
Signature
(python-shell-font-lock-post-command-hook)
Documentation
Fontifies current line in shell buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-shell-font-lock-post-command-hook ()
"Fontifies current line in shell buffer."
(let ((prompt-end (cdr (python-util-comint-last-prompt))))
(when (and prompt-end (> (point) prompt-end)
(process-live-p (get-buffer-process (current-buffer))))
(let* ((input (buffer-substring-no-properties
prompt-end (point-max)))
(deactivate-mark nil)
(start-pos prompt-end)
(buffer-undo-list t)
(replacement
(python-shell-font-lock-with-font-lock-buffer
(delete-region (point-min) (point-max))
(insert input)
(font-lock-ensure)
(buffer-string)))
(replacement-length (length replacement))
(i 0))
;; Inject text properties to get input fontified.
(while (not (= i replacement-length))
(let* ((plist (text-properties-at i replacement))
(next-change (or (next-property-change i replacement)
replacement-length))
(plist (let ((face (plist-get plist 'face)))
(if (not face)
plist
;; Replace FACE text properties with
;; FONT-LOCK-FACE so input is fontified.
(plist-put plist 'face nil)
(plist-put plist 'font-lock-face face)))))
(set-text-properties
(+ start-pos i) (+ start-pos next-change) plist)
(setq i next-change)))))))