From 5d313b0bb11ec7ace8ab6b3cee7aac3345aa4692 Mon Sep 17 00:00:00 2001 From: memeplex Date: Mon, 14 Oct 2019 21:37:20 -0300 Subject: [PATCH] Avoid spurious empty lines in font lock buffer, fixes #33959 * lisp/progmodes/python.el: add clause to avoid writing a newline to the font lock buffer when an empty string is received as output. --- lisp/progmodes/python.el | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index b168b62..86a809b 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2600,18 +2600,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 (let ((output (ansi-color-filter-apply output))) - (and (python-shell-comint-end-of-output-p output) - ;; Assume "..." represents a continuation prompt. - (not (string-match "\\.\\.\\." output)))) - ;; If output ends with an initial (not continuation) input prompt - ;; then 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) + (unless (string= output "") + (if (let ((output (ansi-color-filter-apply output))) + (and (python-shell-comint-end-of-output-p output) + ;; Assume "..." represents a continuation prompt. + (not (string-match "\\.\\.\\." output)))) + ;; If output ends with an initial (not continuation) input prompt + ;; then 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 () "Fontifies current line in shell buffer." -- 2.20.1