From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#68559: [PATCH] Improve Python shell completion Date: Wed, 21 Feb 2024 19:20:08 +0100 Message-ID: <16E39FDF-5F8E-4C1B-8BCD-A0147B97F2B8@gmail.com> 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 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_BC7C9796-F23F-4145-BAAD-6B06DA8CEBD9" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39961"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Liu Hui , Eli Zaretskii , 68559@debbugs.gnu.org To: kobarity Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 21 19:23: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 1rcrFD-000ACP-QY for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 21 Feb 2024 19:22:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcrDx-0008Px-Qb; Wed, 21 Feb 2024 13:21:41 -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 1rcrDv-0008OE-V5 for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 13:21:40 -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 1rcrDv-0003Mp-Li for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 13:21:39 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcrEH-0008Sy-MF for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2024 13:22:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Feb 2024 18:22: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.170853970532519 (code B ref 68559); Wed, 21 Feb 2024 18:22:01 +0000 Original-Received: (at 68559) by debbugs.gnu.org; 21 Feb 2024 18:21:45 +0000 Original-Received: from localhost ([127.0.0.1]:59585 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcrE0-0008SR-QN for submit@debbugs.gnu.org; Wed, 21 Feb 2024 13:21:45 -0500 Original-Received: from mail-lj1-f172.google.com ([209.85.208.172]:54751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcrDu-0008S9-T5 for 68559@debbugs.gnu.org; Wed, 21 Feb 2024 13:21:43 -0500 Original-Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2d23d301452so11488171fa.1 for <68559@debbugs.gnu.org>; Wed, 21 Feb 2024 10:21:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708539610; x=1709144410; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=hWPIRiilO24q0vyvoYczr145JiBLNtlPIzFwyYkYRIQ=; b=ApAz70oqssR+B+Ts1RhyZYjRcebNh9pYhTUCgf6dYgWRsnAvIvdHZsG5bR5chPxzdc DenC9+cRO8pRenBgokSr351N/OkE5XKmT3CjRvMN39pjN2YbQm+wBvSikfquLUYw/vE1 EmCTQ6PCz4eknFuK8bQDCRS+yp1C3XH/NNVPg50jK8PYQcIB5Qq7WJSruEkbb20QkPoW 03Hjv/qVWAc+3GVp+2hjqi0i+rqN9a29/lTWgltiboyDKEFYR1m8xeari5E7Fawe+l95 7XnIUdlRUsTJaoluqQApraVGWbx8ZdFUqziQHGY/CBctWyzr/IwsbxPbv5GHKeX/gO9K VGIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708539610; x=1709144410; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hWPIRiilO24q0vyvoYczr145JiBLNtlPIzFwyYkYRIQ=; b=wwcqFvwh7S31ms0bRmx9wJMukiDcRvtXddrhsnTQ2Yxe31cQf37EMlLxIBRHJMp+MG lOLEHV4NMFlvMQL9jsFJCKwhB0jLqXWhB+wBsx4GTy6KlmiS869LbxdK2zrJhXGQ8V5q pUZ4eMzOP+5JPEKKXLu/MGnRiXXc4/RnGKbUJAO+Lr4bHEXnTppmqUKQ0l0PQyeZ0nkP hEifXiVQdkPMSL6WNiRdm9fMbQC1PC8JMvoN9tB8PIpJRLvHa03eIYSMQ2hTHf9DI3bx xDXK0D6Zqugux9fvDWrProxTZ6mC38qVvApwuAc7WlfJMaqlKvruee5aHuhcSn6KeyuL iOBQ== X-Forwarded-Encrypted: i=1; AJvYcCUnegLgky3A3FHVKxZuD9Qf+i5f5GrxIjQGnZSC1+pufHY5LcXi48+5nr63CV8r1QiWkkn0sG3ipkQbM9zKpKO5ZQWRpoE= X-Gm-Message-State: AOJu0Yz1/F//8fbsyxedm4/UjMAag+WIEgmJ+08wlpLNAEYRSq6fCQ3i ZZKh75g1eKh7ykcKxNp0/zPvrFajqcVpZPW6mUn/W9Yo3mbClm1y X-Google-Smtp-Source: AGHT+IFT9/IEn98jLfTK6cC3T3nQzvOfYazg//8BBmLtjdYw07v4Bg1Q/MzrGLO0fj7LIJrI4s2RvA== X-Received: by 2002:a2e:a7c3:0:b0:2d2:43f4:45b5 with SMTP id x3-20020a2ea7c3000000b002d243f445b5mr5685864ljp.52.1708539609868; Wed, 21 Feb 2024 10:20:09 -0800 (PST) Original-Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id f23-20020a2e3817000000b002d11e504744sm2004330lja.56.2024.02.21.10.20.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2024 10:20:09 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) 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:280412 Archived-At: --Apple-Mail=_BC7C9796-F23F-4145-BAAD-6B06DA8CEBD9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 21 feb. 2024 kl. 14.13 skrev kobarity : > As far as I have tried, native completions cannot be enabled for > libedit-based readline package, even on Linux. Did you find out why? Python responds nicely to TAB if run from a = terminal, so what is it that we do in Emacs that prevents it from doing = so? A TTY setting, or an environment variable (the TERM=3Ddumb)? > 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. Preferably neither. Emacs should adapt to the system environment, and in = particular not warn about the default environment. A warning is an = indication of a possible risk or other problem, and there is none here. At most, python-mode could show a calm notice on the echo line but even = that is a stretch. What do you think about this rough patch? --Apple-Mail=_BC7C9796-F23F-4145-BAAD-6B06DA8CEBD9 Content-Disposition: attachment; filename=nowarn.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="nowarn.diff" Content-Transfer-Encoding: 7bit diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 5501926e69d..bedc61408ef 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4536,18 +4536,11 @@ python-shell-completion-native-turn-on-maybe ((python-shell-completion-native-setup) (when msg (message "Shell native completion is enabled."))) - (t (lwarn - '(python python-shell-completion-native-turn-on-maybe) - :warning - (concat - "Your `python-shell-interpreter' doesn't seem to " - "support readline, yet `python-shell-completion-native-enable' " - (format "was t and %S is not part of the " - (file-name-nondirectory python-shell-interpreter)) - "`python-shell-completion-native-disabled-interpreters' " - "list. Native completions have been disabled locally. " - "Consider installing the python package \"readline\". ")) - (python-shell-completion-native-turn-off msg)))))) + (t + (when msg + (message (concat "Python does not use GNU readline;" + " no completion in multi-line commands."))) + (python-shell-completion-native-turn-off nil)))))) (defun python-shell-completion-native-turn-on-maybe-with-msg () "Like `python-shell-completion-native-turn-on-maybe' but force messages." --Apple-Mail=_BC7C9796-F23F-4145-BAAD-6B06DA8CEBD9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > I think the protocol between python.el and inferior Python process is > already platform independent. Protocol violations are echo back. No, I meant a protocol that allows Emacs to act as a first-class Python = front-end, not simulate a terminal, send keystrokes, use heuristics to = determine what in the output stream is a prompt, REPL value, error, = completion etc. For example, it's a bit silly to input multi-line code in the REPL as a = sequence of individual single-line commands, when we actually are inside = a text editor that can edit multi-line Python code without a problem. (I'm not suggesting that you or anybody in particular should do this; = just that it's feasible. It would clearly be quite some work!) >> Thanks for your patches. I suggest we apply your set-tty-raw patch on = master 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? >=20 > Yes, please. Done! --Apple-Mail=_BC7C9796-F23F-4145-BAAD-6B06DA8CEBD9--