From a6dc66a5441bc6832c12d362edd2d886edc1612a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabi=C3=A1n=20Ezequiel=20Gallina?= Date: Sat, 26 Jul 2014 23:02:38 -0300 Subject: [PATCH] Faster comint output. * lisp/progmodes/python.el: (python-comint-output-filter-function): Make obsolete. (python-comint-postoutput-scroll-to-bottom): New function. (inferior-python-mode): Set comint-output-filter-functions to a minimum. Fixes: debbugs:16875 --- lisp/ChangeLog | 9 +++++++++ lisp/progmodes/python.el | 30 +++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6713626c457..789ad74e95c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2014-07-27 Fabián Ezequiel Gallina + + Faster comint output. (Bug#16875) + * progmodes/python.el: + (python-comint-output-filter-function): Make obsolete. + (python-comint-postoutput-scroll-to-bottom): New function. + (inferior-python-mode): Set comint-output-filter-functions to a + minimum. + 2014-07-27 Fabián Ezequiel Gallina * progmodes/python.el (python-shell-font-lock-post-command-hook): diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 2d4276b2f2b..99c3b0ee1f6 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2114,10 +2114,19 @@ uniqueness for different types of configurations." (rx eos)) output)) -(defun python-comint-output-filter-function (output) - "Hook run after content is put into comint buffer. -OUTPUT is a string with the contents of the buffer." - (ansi-color-filter-apply output)) +(define-obsolete-function-alias + 'python-comint-output-filter-function + 'ansi-color-filter-apply + "24.5") + +(defun python-comint-postoutput-scroll-to-bottom (output) + "Faster version of `comint-postoutput-scroll-to-bottom'. +Avoids `recenter' calls until OUTPUT is completely sent." + (when (and (not (string= "" output)) + (python-shell-comint-end-of-output-p + (ansi-color-filter-apply output))) + (comint-postoutput-scroll-to-bottom output)) + output) (defvar python-shell--parent-buffer nil) @@ -2281,6 +2290,10 @@ interpreter is run. Variables `python-ffap-setup-code' and `python-ffap-string-code' can customize this mode for different Python interpreters. +This mode resets `comint-output-filter-functions' locally, so you +may want to re-add custom functions to it using the +`inferior-python-mode-hook'. + You can also add additional setup code to be run at initialization of the interpreter via `python-shell-setup-codes' variable. @@ -2300,11 +2313,10 @@ variable. (python-shell-prompt-set-calculated-regexps) (setq comint-prompt-regexp python-shell--prompt-calculated-input-regexp) (setq mode-line-process '(":%s")) - (make-local-variable 'comint-output-filter-functions) - (add-hook 'comint-output-filter-functions - 'python-comint-output-filter-function) - (add-hook 'comint-output-filter-functions - 'python-pdbtrack-comint-output-filter-function) + (set (make-local-variable 'comint-output-filter-functions) + '(ansi-color-process-output + python-pdbtrack-comint-output-filter-function + python-comint-postoutput-scroll-to-bottom)) (set (make-local-variable 'compilation-error-regexp-alist) python-shell-compilation-regexp-alist) (define-key inferior-python-mode-map [remap complete-symbol] -- 2.39.2