Function: python-shell-comint-watch-for-first-prompt-output-filter
python-shell-comint-watch-for-first-prompt-output-filter is a
byte-compiled function defined in python.el.gz.
Signature
(python-shell-comint-watch-for-first-prompt-output-filter OUTPUT)
Documentation
Run python-shell-first-prompt-hook when first prompt is found in OUTPUT.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-shell-comint-watch-for-first-prompt-output-filter (output)
"Run `python-shell-first-prompt-hook' when first prompt is found in OUTPUT."
(when (not python-shell--first-prompt-received)
(setq-local python-shell--first-prompt-received-output-buffer
(concat python-shell--first-prompt-received-output-buffer
(ansi-color-filter-apply output)))
(when (python-shell-comint-end-of-output-p
python-shell--first-prompt-received-output-buffer)
(if (string-match-p
(concat python-shell-prompt-pdb-regexp (rx eos))
(or python-shell--first-prompt-received-output-buffer ""))
;; Skip pdb prompts and reset the buffer.
(setq python-shell--first-prompt-received-output-buffer nil)
(setq-local python-shell--first-prompt-received t)
(setq python-shell--first-prompt-received-output-buffer nil)
(cl-letf (((symbol-function 'python-shell-send-string)
(lambda (string process)
(comint-send-string
process
(format "exec(%s)\n" (python-shell--encode-string string))))))
;; Bootstrap: the normal definition of `python-shell-send-string'
;; depends on the Python code sent here.
(python-shell-send-string-no-output python-shell-setup-code)
(python-shell-send-string-no-output python-shell-eval-setup-code)
(python-shell-send-string-no-output python-shell-eval-file-setup-code))
(with-current-buffer (current-buffer)
(let ((inhibit-quit nil))
(python-shell-readline-detect)
(run-hooks 'python-shell-first-prompt-hook))))))
output)