From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: kobarity Newsgroups: gmane.emacs.bugs Subject: bug#68559: [PATCH] Improve Python shell completion Date: Wed, 21 Feb 2024 22:13:45 +0900 Message-ID: References: <6BAFD8BF-8F18-4D9F-9DB3-A185AEF2EBCA@gmail.com> <8B4172D0-FC31-4437-99C4-683C892C5F86@gmail.com> <3A206D3C-E193-4240-A6DB-D3EC7DAAE7C2@gmail.com> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32240"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: Liu Hui , Eli Zaretskii , 68559@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 21 16:24:00 2024 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 1rcoRz-00086C-QK for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Feb 2024 16:24:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcoNQ-0006y2-Go; Wed, 21 Feb 2024 10:19:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcoKe-0000wC-RO for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 10:16:27 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcmSm-0005wy-VT for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 08:16:40 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcmT7-00085a-UZ for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 08:17:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Feb 2024 13:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68559 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68559-submit@debbugs.gnu.org id=B68559.170852136231002 (code B ref 68559); Wed, 21 Feb 2024 13:17:01 +0000 Original-Received: (at 68559) by debbugs.gnu.org; 21 Feb 2024 13:16:02 +0000 Original-Received: from localhost ([127.0.0.1]:48026 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcmS9-00083r-P6 for submit@debbugs.gnu.org; Wed, 21 Feb 2024 08:16:02 -0500 Original-Received: from mail-pj1-f44.google.com ([209.85.216.44]:46259) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcmS4-00083N-Sv for 68559@debbugs.gnu.org; Wed, 21 Feb 2024 08:16:00 -0500 Original-Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-295c8b795e2so3867940a91.0 for <68559@debbugs.gnu.org>; Wed, 21 Feb 2024 05:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708521269; x=1709126069; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=z8jdS1zBlKJqYnqsWtEFLlT0lbjP1uJ5N4vsFM0wZxk=; b=iv6Wkr7ieo1BQhJicZdDJCtxhBipSK0MNxjOzVZNhsDy6X2iPkLKQcyCaM51nDEcTG nPwh35tsKBB0rsx7MGXf2IQIiBswj4pV5asCb7kHKJXMwsIW8XYrkj2qGPmmW1CXL1BG 8I85GWAZ2uLzko5aN7vIe+XRVutC0EOg5/ZcHVmXeSU17CAc1cPBZY2fcg429o1HvPCS KeqLMSNFoDiE0rAN/hkSP/YF4zrabb1LBYg1FO6UcwojNkk4YPDjy4IgP84oTpkGpxu1 pWJRIUNQfhjr3Q+ahaEkBORe9L4ozcCXSf/ECV3XrxkiNoyA5FLbHCGDiukLXCi31VTB zOBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708521269; x=1709126069; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=z8jdS1zBlKJqYnqsWtEFLlT0lbjP1uJ5N4vsFM0wZxk=; b=OdL3PT5dLTMq5TD5an9ZlNcMOJ0Pv4+dDZtSorlquGOsm3rfCbHm3zW1lvrX1B8v0T pX3NLgmxLSbDlz1Dze54YJ4cQwBNOmIV3XI8jm7R5PcXxOMJX+K9JyzFPvhQLqrLYufL aPLWDm2RLDzGCFiEvNhAB53P857OM219P+qmnlGmIQ1kUVlbnUGl1uIJCaVALoOlqDtA sBgGBdBmdGOjv42IX3erR9rw48IsWjeDatiQPOAA5+CvVWstXSJh/1U5pDnr6xpLssOd dgpy9K6BO7LXyyI0F3KS7TRJT2qwgA9jz2dToN9kahNmBq3MV1DPQh078hfdoyU9QbSs guyA== X-Forwarded-Encrypted: i=1; AJvYcCVmqoGlANybPeNnyFskLhAAZ6m0+gSPwbiapdUmEwmaFzqTrrowPBYDAzAi/eO+BFSZgMneDbW0kCuiK9WQ3hIjuespRY0= X-Gm-Message-State: AOJu0Yyk6zLU0rKCBUslR/liZ89uN0YjJ6XXZp0bg1rryOqtkRbM8INd 19k2mKZz+cVco3DrTs639rk5I0+IGv4dZoJY6lYVSyrpyxFs86Ju X-Google-Smtp-Source: AGHT+IH6UMBtAkUyRGYkIwugA/c6qSqsRRZ+6msUxNunMm01uUevQqvKW9XXywO9Otkj7TrSc9RB3Q== X-Received: by 2002:a17:90b:a44:b0:299:2434:e4b3 with SMTP id gw4-20020a17090b0a4400b002992434e4b3mr13178371pjb.39.1708521268508; Wed, 21 Feb 2024 05:14:28 -0800 (PST) Original-Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id sn6-20020a17090b2e8600b00299ef19177dsm1681474pjb.8.2024.02.21.05.14.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 05:14:27 -0800 (PST) In-Reply-To: <3A206D3C-E193-4240-A6DB-D3EC7DAAE7C2@gmail.com> 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280378 Archived-At: Mattias Engdeg=E5rd wrote: > 17 feb. 2024 kl. 14.33 skrev kobarity : > > On Mac, it might be better to set the default value of > > `python-shell-completion-native-enable' to nil. > Not sure why the inferior Python process doesn't act on a TAB being sent = to it. Is the tty somehow in a state that disables readline/libedit? Someth= ing that Emacs does when setting up the pty? On Mac, there are two independent problems. One problem, which existed before Liu's patch was applied, is that native completions cannot be enabled. The other problem is that the test now fails after applying Liu's patch. Suppressing echo back solves the latter, but not the former. Because of the former, leaving `python-shell-completion-native-enable' at the default setting of t will result in the warning. There are two completions methods, native and non-native. If native completions cannot be used, it falls back to non-native completions. Native completions is triggered by sending TAB character, while non-native completions is triggered by sending and evaluating __PYTHON_EL_get_completions(). As far as I have tried, native completions cannot be enabled for libedit-based readline package, even on Linux. So, there are two ways for Mac users to avoid the warning. One is to use gnureadline instead of libedit, and the other is to give up native completions and set `python-shell-completion-native-enable' to nil. This remains correct even with echo back disabled. > Of course from a software engineering point of view, it's silly to send w= hat essentially are edit keystrokes to Python and then screen-scrape the ou= tput. A proper interaction protocol would be the way to go, and would work = equally well on any platform including Windows. I think the protocol between python.el and inferior Python process is already platform independent. Protocol violations are echo back. > Thanks for your patches. I suggest we apply your set-tty-raw patch on mas= ter now since it cures the test failures without breaking anything else (on= Mac; I'm assuming no regression elsewhere). >=20 > Would you like me to do that for you? Yes, please. Thank you. I have no commit right.