emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master ab67287: Avoid extra lines in python-shell font loc


From: Noam Postavsky
Subject: [Emacs-diffs] master ab67287: Avoid extra lines in python-shell font lock buffer (Bug#33959)
Date: Tue, 22 Oct 2019 20:16:07 -0400 (EDT)

branch: master
commit ab6728787245e0d46bd8a8919e30c882f6011182
Author: memeplex <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Avoid extra lines in python-shell font lock buffer (Bug#33959)
    
    * lisp/progmodes/python.el
    (python-shell-font-lock-comint-output-filter-function): Avoid writing
    a newline to the font lock buffer when receiving an empty string.
---
 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..634c297 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2600,18 +2600,19 @@ goes wrong and syntax highlighting in the shell gets 
messed up."
 
 (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 "") ;; See Bug#33959.
+    (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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]