From d816a29f5a9cdcebd8f69ad0a6555eaca051587e Mon Sep 17 00:00:00 2001 From: memeplex Date: Thu, 3 Jan 2019 02:28:30 -0300 Subject: [PATCH] Avoid spurious empty lines in font lock buffer, fixes #33959 --- lisp/progmodes/python.el | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 27d31ab..81a6e89 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2556,19 +2556,19 @@ python-shell-font-lock-cleanup-buffer (defun python-shell-font-lock-comint-output-filter-function (output) "Clean up the font-lock buffer after any OUTPUT." - (if (and (not (string= "" output)) - ;; Is end of output and is not just a prompt. - (not (member - (python-shell-comint-end-of-output-p - (ansi-color-filter-apply output)) - '(nil 0)))) - ;; If output is other than an input prompt then "real" output has - ;; been received and the font-lock buffer must be cleaned up. - (python-shell-font-lock-cleanup-buffer) - ;; Otherwise just add a newline. - (python-shell-font-lock-with-font-lock-buffer - (goto-char (point-max)) - (newline))) + (unless (string= "" output) + (if ;; Is end of output and is not just a prompt. + (not (member + (python-shell-comint-end-of-output-p + (ansi-color-filter-apply output)) + '(nil 0))) + ;; If output is other than an input prompt then "real" output has + ;; been received and the font-lock buffer must be cleaned up. + (python-shell-font-lock-cleanup-buffer) + ;; Otherwise just add a newline. + (python-shell-font-lock-with-font-lock-buffer + (goto-char (point-max)) + (newline)))) output) (defun python-shell-font-lock-post-command-hook () @@ -2597,6 +2597,7 @@ python-shell-font-lock-post-command-hook (point-max)))) (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)) -- 2.20.1