From: Ben Sturmfels via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Alex Branham <alex.branham@gmail.com>
Cc: 29592@debbugs.gnu.org
Subject: bug#29592: 25.3; python does not print input or output in the inferior process
Date: Sat, 26 Feb 2022 10:00:35 +1100 [thread overview]
Message-ID: <87tucmft64.fsf@sturm.com.au> (raw)
In-Reply-To: <8735k6obhp.fsf@sturm.com.au> (Ben Sturmfels's message of "Sat, 26 Feb 2022 08:57:38 +1100")
The GitHub ticket below for elpy also mentions this issue and includes some
"quick-and-dirty" that does seem to address the issue. The code works,
but I get an extra line break in the REPL when evaluating lines other
than the first line of the buffer.
https://github.com/jorgenschaefer/elpy/issues/924#issuecomment-314922197
> This is not an elpy issue, it also occurs with plain python-mode. It
> seems to be caused by certain versions of Python only. A quick-and-dirty
> fix is (in .emacs):
>
> (defun python-shell-append-to-output (string)
> (let ((buffer (current-buffer)))
> (set-buffer (process-buffer (python-shell-get-process)))
> (let ((oldpoint (point)))
> (goto-char (process-mark (python-shell-get-process)))
> (insert string)
> (set-marker (process-mark (python-shell-get-process)) (point))
> (goto-char oldpoint))
> (set-buffer buffer)))
>
> (defadvice python-shell-send-string
> (around advice-python-shell-send-string activate)
> (interactive)
> (let* ((append-string1
> (if (string-match "import codecs, os;__pyfile = codecs.open.*$" string)
> (replace-match "" nil nil string)
> string))
> (append-string2
> (if (string-match "^# -\\*- coding: utf-8 -\\*-\n*$" append-string1)
> (replace-match "" nil nil append-string1)
> append-string1))
> (append-string
> (if (string-match "^\n*$" append-string2)
> (replace-match "" nil nil append-string2)
> append-string2)))
> (python-shell-append-to-output
> (concat (string-trim-right append-string) "\n")))
> (if (called-interactively-p 'any)
> (call-interactively (ad-get-orig-definition 'python-shell-send-string))
> ad-do-it))
next prev parent reply other threads:[~2022-02-25 23:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-06 18:59 bug#29592: 25.3; python does not print input or output in the inferior process Alex Branham
2017-12-12 23:28 ` Noam Postavsky
2022-02-25 21:57 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-25 23:00 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-02-26 16:26 ` Augusto Stoffel
2022-02-27 12:58 ` Lars Ingebrigtsen
2022-02-27 22:58 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=87tucmft64.fsf@sturm.com.au \
--to=bug-gnu-emacs@gnu.org \
--cc=29592@debbugs.gnu.org \
--cc=alex.branham@gmail.com \
--cc=ben@sturm.com.au \
/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.