unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: "Barton, Mark" <Mark.Barton@disney.com>,
	"50514@debbugs.gnu.org" <50514@debbugs.gnu.org>
Subject: bug#50514: 28.0.50; org inline call to python src block req C-g to break
Date: Tue, 14 Sep 2021 21:36:23 +0200	[thread overview]
Message-ID: <87k0jjq79k.fsf@gmail.com> (raw)
In-Reply-To: <073CC0D1-9900-4613-87E8-D69EA1C11623@disney.com> (Mark Barton's message of "Tue, 14 Sep 2021 19:25:46 +0000")

[-- Attachment #1: Type: text/plain, Size: 248 bytes --]

Lars, can you install the attached patch, which solves the parts of this
issue which originate in my recent changes?  The patch also does the
correct thing w.r.t. the text fields in the comint, something I was
unaware of until yesterday.

Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Python-shell-rearrange-printing-of-newline-before-ou.patch --]
[-- Type: text/x-patch, Size: 2550 bytes --]

From 096a3cb45baa4ff954c19c1d2d34dd86757ef4f5 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Tue, 14 Sep 2021 05:31:45 +0200
Subject: [PATCH] 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,
---
 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 d9fc5c5009..fae350dea2 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2189,6 +2189,9 @@ python-shell-compilation-regexp-alist
   :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 @@ python-shell-eval-setup-code
         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 @@ python-shell-send-string
                       (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 @@ python-shell-send-string
              (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.
-- 
2.31.1


  parent reply	other threads:[~2021-09-14 19:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 23:06 bug#50514: 28.0.50; org inline call to python src block req C-g to break Barton, Mark
2021-09-11 13:04 ` Lars Ingebrigtsen
2021-09-11 13:26 ` Augusto Stoffel
2021-09-12  6:22   ` Barton, Mark
2021-09-12  6:51     ` Augusto Stoffel
2021-09-12  8:27       ` Barton, Mark
2021-09-12  9:15         ` Augusto Stoffel
2021-09-12 17:00           ` Barton, Mark
2021-09-12 20:04             ` Barton, Mark
2021-09-14  6:42               ` Augusto Stoffel
2021-09-14 17:54                 ` Barton, Mark
2021-09-14 18:29                   ` Augusto Stoffel
2021-09-14 19:25                     ` Barton, Mark
2021-09-14 19:31                       ` Augusto Stoffel
2021-09-14 22:20                         ` Barton, Mark
2021-09-15  6:28                           ` Augusto Stoffel
2021-09-14 19:36                       ` Augusto Stoffel [this message]
2021-09-15  8:02                         ` Lars Ingebrigtsen
2022-08-25 15:12                           ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0jjq79k.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=50514@debbugs.gnu.org \
    --cc=Mark.Barton@disney.com \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).