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: Fri, 23 Feb 2024 12:00:27 +0100 Message-ID: <7150E568-B07D-4D92-8073-979387553394@gmail.com> References: <6BAFD8BF-8F18-4D9F-9DB3-A185AEF2EBCA@gmail.com> <8B4172D0-FC31-4437-99C4-683C892C5F86@gmail.com> <3A206D3C-E193-4240-A6DB-D3EC7DAAE7C2@gmail.com> <16E39FDF-5F8E-4C1B-8BCD-A0147B97F2B8@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18047"; 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 Fri Feb 23 12:02:59 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 1rdTKV-0004Xy-L7 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Feb 2024 12:02:59 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdTKD-0006UE-3s; Fri, 23 Feb 2024 06:02: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 1rdTKB-0006Ty-Jw for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 06:02:39 -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 1rdTKB-00077i-8V for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 06:02:39 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rdTKY-0005ew-Gq for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 06:03:02 -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: Fri, 23 Feb 2024 11:03:02 +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.170868612221616 (code B ref 68559); Fri, 23 Feb 2024 11:03:02 +0000 Original-Received: (at 68559) by debbugs.gnu.org; 23 Feb 2024 11:02:02 +0000 Original-Received: from localhost ([127.0.0.1]:59367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rdTJY-0005cF-VM for submit@debbugs.gnu.org; Fri, 23 Feb 2024 06:02:02 -0500 Original-Received: from mail-lf1-f54.google.com ([209.85.167.54]:61779) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rdTJW-0005bs-TK for 68559@debbugs.gnu.org; Fri, 23 Feb 2024 06:01:59 -0500 Original-Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-512cc3ea7a5so183463e87.3 for <68559@debbugs.gnu.org>; Fri, 23 Feb 2024 03:01:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708686029; x=1709290829; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=Bd3vIYFsuU5DsA5DzTlbtA5AxNtXZmS98TBTwLy3K30=; b=mkSto2NJQ1TnaYssnyi6FRaBjK0vfPCBvskpgrEzGI8dDUQtpX3TxIaTysU0E5ZsSk Ux8jG6cJAuLtAyGbs8SnqTtGAwdIDgdnvFv3KGMggDgxGfjxb22y6+zHldwvmeCMpwTM 8iARmu+Q9M0DBKPTiStGkLVMBvNjaCsDab2fmTFeaWOED36EH4sP0kqZGllT/y7otS89 BR2qR8WvU/AMFBRraUmuGtiwWsrWfgJzntrSMM4AWwzaWsxdSGEqRgEbdHTinYKo9SKv Kn8Bgp5QKMa16O6ZAM6jvGLt9zkaMtmdoOvWwhtQLqF5sthx2HHqHBiX0uuTqZHjCblK 3C+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708686029; x=1709290829; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Bd3vIYFsuU5DsA5DzTlbtA5AxNtXZmS98TBTwLy3K30=; b=JX2Lo2cRaxsir3PF96kLtKBwz2FurbG0fP1Q48Vee6cX9EQ346mncVYiajO4GGL8IK MZIYOL/uHap7d5m7XYmnMcX/zO8qAUPPsaMchvvCc9VH4P6iQO4QbjFVSVXLgjcbwQLv 7ryPSd/Z2oHjh0FZoayYrVSUqo1RRaMk2gm0yRR6nGHwTs0uK7nhxIu7KpdIJaDq3TAs ysmKVQW5mbLE7/AzMMGm3oGtFyRhOpl0tmLtdANcKwCFO9dsb9El/thPPHoRlOmYTdcz TCEArVAsHf7W/EA+8PK18a7GBuA9VOfvrYgRJV7yOBDYIlO5sygd2+Y0qtzPJBMgttOc e7Mw== X-Forwarded-Encrypted: i=1; AJvYcCUspWYNxzcffb5mWFYgwABRHx3Vk+TDxHvznN2DeLHNajSQmcF9Jq9GjyeezxWwHiABvszWr7SpTbNNUZ7jMDJSyvtaI68= X-Gm-Message-State: AOJu0Yxicjz6rnLnB8i44OeyVei/BEFOpwNi+YSEvJ11JEZJE3FlI/3Z Xojqq32fParUW4MBFPdniYJ+sd6R1/nqAnR4Aw8Ged0FZ0QsOPXE X-Google-Smtp-Source: AGHT+IFTfcNmkydNTlu2Tulq9PhKM7Se6oEmL1Z1BMYiQc9X+RK4MmE3rW0XJWDlJWB6480XvGtGAA== X-Received: by 2002:a05:6512:124c:b0:512:d7e8:7046 with SMTP id fb12-20020a056512124c00b00512d7e87046mr1421127lfb.42.1708686029021; Fri, 23 Feb 2024 03:00:29 -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 cf7-20020a056512280700b00512d814ffffsm799360lfb.15.2024.02.23.03.00.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2024 03:00:28 -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:280490 Archived-At: 22 feb. 2024 kl. 17.15 skrev kobarity : >> 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)? >=20 > No, not exactly, but I don't think it is related to terminal settings. Well it must be something. I'll see if I can make sense of it. > I think this difference in behavior is the reason why Native > completions does not work with libedit. Thanks for explaining. > Personally, I think this patch would be fine. Thank you, now pushed to master. > I think we can also improve Non-native completions. Current > implementation sends the definition of __PYTHON_EL_get_completions() > every time. However, sending it once during initialization should be > sufficient. Worse, if the number of characters sent exceeds > `comint-max-line-length', it will be sent via file. This is happening > in your environment. Here is the log you presented. >=20 > Test python-completion-at-point-1 backtrace: > json-parse-string("__PYTHON_EL_eval_file(\"/var/folders/qy/zstv16390 >=20 > Thanks to the echo back, we can see __PYTHON_EL_eval_file() was used. Right. (The need for a file is just an artefact of Comint limitations, = isn't it?) > I am not opposed to this approach, but as you wrote, it is very > different from the current inferior Python implementation. > Jupyter-emacs's approach may be similar to some extent. It uses zmq > as the communication channel. Thank you, yes, in a sense it's a (small) step towards a more = notebook-like interaction model, but Comint already has some of that. = This problem is not unique to Python: other REPLs have to solve the = problem of multi-line input as well, and it would serve the user if they = all worked in the same way (as far as the language differences allow). In Python's case, it would liberate us from the constraints of the = standard terminal REPL.