all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
To: 52380@debbugs.gnu.org
Cc: Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#52380: 28.0.50; [PATCH] run-python no longer focuses interpreter
Date: Thu, 09 Dec 2021 00:10:28 +0100	[thread overview]
Message-ID: <87pmq666cb.fsf@gmail.com> (raw)

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

Hi,

In Emacs 27.2, M-x run-python did two things that Emacs 28 no longer
does.  From emacs -Q:

(1) M-x run-python
    Problem 1: 27.2 makes the Python buffer current; 28 does not.

(2) Additional step for Emacs 28, to get to the *Python* buffer:
    C-x o

(3) M-x bury-buffer

(4) M-x run-python
    Problem 2: 27.2 raises the Python buffer; 28 does not.

(The latter might seem like a niche corner case; it's actually a very
convenient feature of python.el's C-c C-p, IMO)

The current code in python.el fails on two fronts, AFAICT:

(1) the set-buffer clause near the end of run-python is ineffectual,
    because, as the docstring says:

>               This function does not display the buffer, so its effect
> ends when the current command terminates.  Use ‘switch-to-buffer’ or
> ‘pop-to-buffer’ to switch buffers permanently.

(2) the (when show (display-buffer buffer)) form in
    python-shell-make-comint is not evaluated when the *Python* buffer
    already exists, because of it is guarded by (when (not
    (comint-check-proc proc-buffer-name)) …).

I've bisected this; the "faulty" commit (2020-11-09 "Make the SHOW
parameter work again in `run-python'" (0d9e2b80d8)) was itself fixing a
regression.  Trying to build on top of it, I propose the attached patch.
(No changelog entry, because I'm not sure it's the right way to solve
this)

WDYT?


In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.16.0)
 of 2021-12-06 built on amdahl30
Repository revision: 4434deaee2aa9d8c6b9631690c6376f78a9b057f
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101001
System Description: openSUSE Tumbleweed

Configured using:
 'configure --with-xwidgets --with-cairo --with-gconf --with-xinput2'

Configured features:
ACL CAIRO DBUS FREETYPE GCONF GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ
JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: run-python.patch --]
[-- Type: text/x-patch, Size: 845 bytes --]

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 47d8d1ce8e..aee89f6519 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2996,8 +2996,8 @@ python-shell-make-comint
                   (mapconcat #'identity args " ")))
             (with-current-buffer buffer
               (inferior-python-mode))
-            (when show (display-buffer buffer))
             (and internal (set-process-query-on-exit-flag process nil))))
+        (when show (pop-to-buffer proc-buffer-name))
         proc-buffer-name))))
 
 ;;;###autoload
@@ -3029,7 +3029,6 @@ run-python
          (python-shell-make-comint
           (or cmd (python-shell-calculate-command))
           (python-shell-get-process-name dedicated) show)))
-    (set-buffer buffer)
     (get-buffer-process buffer)))
 
 (defun run-python-internal ()

             reply	other threads:[~2021-12-08 23:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 23:10 Kévin Le Gouguec [this message]
2021-12-10 12:06 ` bug#52380: 28.0.50; [PATCH] run-python no longer focuses interpreter Lars Ingebrigtsen
2021-12-10 12:08   ` Lars Ingebrigtsen
2021-12-10 19:26     ` Kévin Le Gouguec
2021-12-10 20:09       ` bug#52380: ERT, buffers and windows (was: bug#52380: 28.0.50; [PATCH] run-python no longer focuses interpreter) Kévin Le Gouguec
2021-12-10 20:30         ` Eli Zaretskii
2021-12-10 20:58           ` bug#52380: ERT, buffers and windows Kévin Le Gouguec
2021-12-11 22:23     ` bug#52380: 28.0.50; [PATCH] run-python no longer focuses interpreter Kévin Le Gouguec
2021-12-12  6:40       ` Lars Ingebrigtsen
2021-12-12 14:03         ` bug#52380: 28.0.50; [PATCH v2] " Kévin Le Gouguec
2021-12-13  4:17           ` 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=87pmq666cb.fsf@gmail.com \
    --to=kevin.legouguec@gmail.com \
    --cc=52380@debbugs.gnu.org \
    --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 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.