From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Newsgroups: gmane.emacs.bugs Subject: bug#52380: 28.0.50; [PATCH] run-python no longer focuses interpreter Date: Thu, 09 Dec 2021 00:10:28 +0100 Message-ID: <87pmq666cb.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39790"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen To: 52380@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 09 00:11:10 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mv65d-000AEo-UU for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Dec 2021 00:11:10 +0100 Original-Received: from localhost ([::1]:60084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mv65c-0004XS-OY for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Dec 2021 18:11:08 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mv65W-0004X3-Mx for bug-gnu-emacs@gnu.org; Wed, 08 Dec 2021 18:11:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mv65W-0002rf-En for bug-gnu-emacs@gnu.org; Wed, 08 Dec 2021 18:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mv65W-0005zM-AE for bug-gnu-emacs@gnu.org; Wed, 08 Dec 2021 18:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Dec 2021 23:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52380 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163900503822987 (code B ref -1); Wed, 08 Dec 2021 23:11:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Dec 2021 23:10:38 +0000 Original-Received: from localhost ([127.0.0.1]:41865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mv657-0005yg-S0 for submit@debbugs.gnu.org; Wed, 08 Dec 2021 18:10:38 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:33480) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mv654-0005yX-K8 for submit@debbugs.gnu.org; Wed, 08 Dec 2021 18:10:37 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mv654-0004VZ-G3 for bug-gnu-emacs@gnu.org; Wed, 08 Dec 2021 18:10:34 -0500 Original-Received: from [2a00:1450:4864:20::436] (port=38780 helo=mail-wr1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mv652-0002jl-Ds for bug-gnu-emacs@gnu.org; Wed, 08 Dec 2021 18:10:34 -0500 Original-Received: by mail-wr1-x436.google.com with SMTP id q3so6744366wru.5 for ; Wed, 08 Dec 2021 15:10:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version; bh=hXRqEYfc4fYUePT5VGlWMSsNoUZahZ3UX7VY12xoF44=; b=du468JwsXdtZycfjd+oPkWEK1MDKwo7f7TUziBJoHvR3rZLl4+u0u1Ic26jxuGv6mU i5xS1Bt6EuRFtulJK9isHDHb0dzgBX4gKg/nGrDQtdvS5tEOZG7qOc1zrmAKOzizSH40 62hIC6PJDXC3M8BCSXyzu4fL2wfPlZe+zWniGUTcSz3tIvdcNbjgslndFNpeaA1mAqtp hEhvrg7Wu94RBOmWOnbKw7hh3X0eraRk0Dd1FeiNVQuq/6gKSzDYQLqiRQ9KsNjuNjoq Pyj09mi6LEv4fVswvkzzQJleFGMAxipT408C4fA++cwRrP3RabMGcUQH1K0l/KvpBDj/ jByQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=hXRqEYfc4fYUePT5VGlWMSsNoUZahZ3UX7VY12xoF44=; b=vi3589x3FOFT36VbVN4cEqOafWmz18Zx9J8S8TsZzQBZ6zuC4fheeMnN4qPVPMmNFh mda9v3NPjedLBLCyvFoS8wgctD+AztQWtSEJIIRrBYPu2tgnMQAi+Lkh8aV9O4Tnk6PW bKW5JC9ywkg00cW26XFEGHohh+iFCmiT15H8Xtn7S5gPhfzhQ60+wwpXs9bSqxhF6Pz8 MHsIwEn6MSubdx6MgYQO2Ri0WBK0Q6dRi/nhDuR/CT6zUHwrWYZlsfp7EBq+wS/rMm7I wwwrzGUBjMv/1jPxQwUPS2BfjhH4V9DJP/pYCkbFlpxF2wS7/1hMmEm46P/iYi0NAytq LqjQ== X-Gm-Message-State: AOAM533LQC3jc+ZK9X9dJ/aGjdsNWagFLbBOX9PdtN7TFNZ7XtZDDL+G +1+ewDymrEIHObN9vyKvATE= X-Google-Smtp-Source: ABdhPJx58Tm+aCT2YpcizCAX2907MQgKbLGFtK/RG4L+/pHpQckw7ssHytNpJtLfrktY+++tNUOc3g== X-Received: by 2002:a05:6000:15c7:: with SMTP id y7mr2072130wry.424.1639005030370; Wed, 08 Dec 2021 15:10:30 -0800 (PST) Original-Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id e7sm5388199wrg.31.2021.12.08.15.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 15:10:29 -0800 (PST) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::436 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=kevin.legouguec@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:221961 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 =E2=80=98switch-to-buffer= =E2=80=99 or > =E2=80=98pop-to-buffer=E2=80=99 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)) =E2=80=A6). 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, c= airo 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=3Dlocal locale-coding-system: utf-8-unix --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=run-python.patch 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 () --=-=-=--