From f5bed1021b782347c4f57449c8f7825a9a5f2bf6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabi=C3=A1n=20Ezequiel=20Gallina?= Date: Sun, 27 Jul 2014 23:47:29 -0300 Subject: [PATCH] Grab all Python process output before inferior-python-mode hooks. * lisp/progmodes/python.el (inferior-python-mode): Call accept-process-output and sit-for to ensure all output for process has been received before running hooks. (python-shell-internal-get-or-create-process): Cleanup accept-process-output and sit-for calls. --- lisp/ChangeLog | 9 +++++++++ lisp/progmodes/python.el | 13 +++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cda49f48dcc..0fc4f7c1bfc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2014-07-28 Fabián Ezequiel Gallina + + Grab all Python process output before inferior-python-mode hooks. + * progmodes/python.el (inferior-python-mode): Call + accept-process-output and sit-for to ensure all output for process + has been received before running hooks. + (python-shell-internal-get-or-create-process): Cleanup + accept-process-output and sit-for calls. + 2014-07-28 Fabián Ezequiel Gallina More robust shell startup and code setup. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 433dbc1dafd..a3e100f0578 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2361,7 +2361,10 @@ variable. (make-local-variable 'python-shell-internal-last-output) (when python-shell-font-lock-enable (python-shell-font-lock-turn-on)) - (compilation-shell-minor-mode 1)) + (compilation-shell-minor-mode 1) + ;; Ensure all the output is accepted before running any hooks. + (accept-process-output (get-buffer-process (current-buffer))) + (sit-for 0.1 t)) (defun python-shell-make-comint (cmd proc-name &optional pop internal) "Create a Python shell comint buffer. @@ -2499,13 +2502,7 @@ there for compatibility with CEDET.") (proc-buffer-name (format " *%s*" proc-name))) (when (not (process-live-p proc-name)) (run-python-internal) - (setq python-shell-internal-buffer proc-buffer-name) - ;; XXX: Why is this `sit-for' needed? - ;; `python-shell-make-comint' calls `accept-process-output' - ;; already but it is not helping to get proper output on - ;; 'gnu/linux when the internal shell process is not running and - ;; a call to `python-shell-internal-send-string' is issued. - (sit-for 0.1 t)) + (setq python-shell-internal-buffer proc-buffer-name)) (get-buffer-process proc-buffer-name))) (define-obsolete-function-alias -- 2.39.2