emacs-diffs
[Top][All Lists]
Advanced

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

master 6cfc312: Python shell: rearrange printing of newline before outpu


From: Lars Ingebrigtsen
Subject: master 6cfc312: Python shell: rearrange printing of newline before output
Date: Wed, 15 Sep 2021 04:03:02 -0400 (EDT)

branch: master
commit 6cfc312d7196d7c7c70e7030b344891ecea8c4f1
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Python shell: rearrange printing of newline before output
    
    * progmodes/python.el (python-shell-output-filter-in-progress)
    (python-shell-output-filter-buffer): Move defvars to avoid compiler
    warnings.
    (python-shell-eval-setup-code): Don't print a newline in
    __PYTHON_EL_eval.
    (python-shell-send-string): Insert newline before output when
    applicable (bug#50514).
---
 lisp/progmodes/python.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index d9fc5c5..fae350d 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2189,6 +2189,9 @@ virtualenv."
   :type '(alist regexp)
   :group 'python)
 
+(defvar python-shell-output-filter-in-progress nil)
+(defvar python-shell-output-filter-buffer nil)
+
 (defmacro python-shell--add-to-path-with-priority (pathvar paths)
   "Modify PATHVAR and ensure PATHS are added only once at beginning."
   `(dolist (path (reverse ,paths))
@@ -2821,7 +2824,6 @@ def __PYTHON_EL_eval(source, filename):
         from __builtin__ import compile, eval, globals
     else:
         from builtins import compile, eval, globals
-    sys.stdout.write('\\n')
     try:
         p, e = ast.parse(source, filename), None
     except SyntaxError:
@@ -3162,6 +3164,11 @@ t when called interactively."
                       (python-shell--encode-string string)
                       (python-shell--encode-string (or (buffer-file-name)
                                                        "<string>")))))
+    (unless python-shell-output-filter-in-progress
+      (with-current-buffer (process-buffer process)
+        (save-excursion
+          (goto-char (process-mark process))
+          (insert-before-markers "\n"))))
     (if (or (null (process-tty-name process))
             (<= (string-bytes code)
                 (or (bound-and-true-p comint-max-line-length)
@@ -3172,9 +3179,6 @@ t when called interactively."
              (file-name (or (buffer-file-name) temp-file-name)))
         (python-shell-send-file file-name process temp-file-name t)))))
 
-(defvar python-shell-output-filter-in-progress nil)
-(defvar python-shell-output-filter-buffer nil)
-
 (defun python-shell-output-filter (string)
   "Filter used in `python-shell-send-string-no-output' to grab output.
 STRING is the output received to this point from the process.



reply via email to

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