all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>, awrhygty@outlook.com
Cc: 53219@debbugs.gnu.org
Subject: bug#53219: 27.2; shell-mode output is stolen by python-eldoc
Date: Thu, 13 Jan 2022 18:26:23 +0100	[thread overview]
Message-ID: <87a6fzmts0.fsf@miha-pc> (raw)
In-Reply-To: <87iluo9n9q.fsf@gnus.org>


[-- Attachment #1.1: Type: text/plain, Size: 1091 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> awrhygty@outlook.com writes:
>
>> Evaluate the form below and type 'C-p' or 'C-n' repeatedly to display
>> python eldoc messages.
>> After 20-30 key input, an error occurs.
>> Then look at the *shell* buffer, some numbers in output lines are
>> absent.
>> If setting debug-on-error to 't, *Backtrace* buffer popups,
>
> That sounds familiar -- I think I recall something like this being fixed
> in eldoc...
>
> Yes, I can reproduce this problem in Emacs 27.2, but not in Emacs 29.
> So I guess this has been fixed by now, and I'm closing this bug report.

Not quite yet. I found a more reliable reproducer for Emacs 29, which
could reproduce the bug on my machine with emacs -q.

(progn
  (setq debug-on-error t)
  (shell)
  (insert " i=0; while sleep 0.05; do i=$((i + 1)); echo $i; done")
  (comint-send-input)
  (run-python)
  (switch-to-buffer (generate-new-buffer "tmp"))
  (insert "len\nstr")
  (python-mode))

If it doesn't work bug immediately, try lowering the "0.05" number.

Please consider applying the following patch to fix this.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Fix-python-eldoc-affecting-unrelated-comint-processe.patch --]
[-- Type: text/x-patch, Size: 1624 bytes --]

From 45c345f0b170c3ffc41f186b3c2b70dbccaa23fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha@kamnitnik.top>
Date: Thu, 13 Jan 2022 18:20:13 +0100
Subject: [PATCH] Fix python-eldoc affecting unrelated comint processes

* lisp/progmodes/python.el (python-shell-send-string-no-output): Don't
let-bind comint-preoutput-filter-functions globally for all comint
processes.  Modify the behaviour of only the current python
process (bug#53219).
---
 lisp/progmodes/python.el | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index edd3139a7a..5889f2ab67 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3216,11 +3216,13 @@ python-shell-output-filter
 (defun python-shell-send-string-no-output (string &optional process)
   "Send STRING to PROCESS and inhibit output.
 Return the output."
-  (let ((process (or process (python-shell-get-process-or-error)))
-        (comint-preoutput-filter-functions
-         '(python-shell-output-filter))
-        (python-shell-output-filter-in-progress t)
-        (inhibit-quit t))
+  (or process (setq process (python-shell-get-process-or-error)))
+  (cl-letf (((process-filter process)
+             (lambda (_proc str)
+               (with-current-buffer (process-buffer process)
+                 (python-shell-output-filter str))))
+            (python-shell-output-filter-in-progress t)
+            (inhibit-quit t))
     (or
      (with-local-quit
        (python-shell-send-string string process)
-- 
2.34.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

  reply	other threads:[~2022-01-13 17:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12 17:54 bug#53219: 27.2; shell-mode output is stolen by python-eldoc awrhygty
2022-01-13  6:13 ` Lars Ingebrigtsen
2022-01-13 17:26   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-01-14  7:34     ` 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

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

  git send-email \
    --in-reply-to=87a6fzmts0.fsf@miha-pc \
    --to=bug-gnu-emacs@gnu.org \
    --cc=53219@debbugs.gnu.org \
    --cc=awrhygty@outlook.com \
    --cc=larsi@gnus.org \
    --cc=miha@kamnitnik.top \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.