From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.devel Subject: Re: About commands to manage Python imports Date: Sat, 1 Jul 2023 21:23:12 +0200 Message-ID: References: <83pm5bpols.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000ef599a05ff71dd11" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21007"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jul 01 21:24:38 2023 Return-path: Envelope-to: ged-emacs-devel@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 1qFgD0-0005KU-OC for ged-emacs-devel@m.gmane-mx.org; Sat, 01 Jul 2023 21:24:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFgBt-00022g-9W; Sat, 01 Jul 2023 15:23:29 -0400 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 1qFgBr-000227-AQ for emacs-devel@gnu.org; Sat, 01 Jul 2023 15:23:27 -0400 Original-Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFgBp-0006B9-IT; Sat, 01 Jul 2023 15:23:27 -0400 Original-Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-986d8332f50so363437666b.0; Sat, 01 Jul 2023 12:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688239403; x=1690831403; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JQR4zFojGhQyCtOHNI2heZCz7VPwK59212zKRVaHLuc=; b=D+8rrvp8WFhKyo9M/Mq7ci2vidtITauGnZT50wZ7dWlE+L9UVn6QvGL3T9/3UFZPsV NBgwW9RaAD1/OHOTzN1NEz8eIb74WixaSqpoZ5P9DewMp+ZnUY9AMn34QVpUdpP0eT8x SAEhdcpVrDS8OJ74jY/PqKEASUMY1hyYYdikT2ur4mG2NXH5etumbG+PMFiBsJRT+3he vwTJUPmOu2Otdl9sogdDH1bdKiydkueevtgk8Q/eYzz9CY3NQYR/wDQ9T4B2DTw+zdDz dYJADOqSxYiTbeck90E7zXqsoBpDqxju6s8tRmy7sFdogLTiDXX72W4frq2F6XRp96Dv bgsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688239403; x=1690831403; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JQR4zFojGhQyCtOHNI2heZCz7VPwK59212zKRVaHLuc=; b=Qi7ao6xi0Gk4cnatioK6SrjQ5/zOwD+BHmVO7wUjiMaS4sYHrgOfc/UuGd6U5QkT3r 9PXllyTEXequrmarwJ6NHbmKMMl/EpwRCDlIimYfGBD6u+WB3DP3pD645Fa2fhy0aE1e ph86QdtE0gfBHX8D+nLyA6faITC70nuw1T9EPtQcb8DF2zpY7V4xCH6zcrNY3o/7VzTQ wp/Y/TYxnb1WzdhRhMhsTZ0Tx25LVdtLi5pAUUb8ayHFWntAcEImocb127sxMK1GeXGr zHTo6afz72UvITAn7t7LNhCjqlGa77CUVBoose7vDC02SntzN71SlPDkVRXR9Ht2jnd6 qvAQ== X-Gm-Message-State: ABy/qLZQ+3wjbGxzbI8kYfOt+IAAKxi8apwYgbK1rxTiBj2xiO3Xr9Uq MPSbmWbaMpU66iu8kaDQwiXy+tnEX78vF4cLZbPiRlNNapuY+w== X-Google-Smtp-Source: APBJJlHDijwCU7X/cDlkxFTXeSIbHII55AyRpA/ttqn7Xbq41+C/jRiYr6AH0VTF81skBg0xlXJd7ymXw2iG946LkiQ= X-Received: by 2002:a17:906:f196:b0:96f:d345:d0f7 with SMTP id gs22-20020a170906f19600b0096fd345d0f7mr3918945ejb.62.1688239403390; Sat, 01 Jul 2023 12:23:23 -0700 (PDT) In-Reply-To: <83pm5bpols.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=orontee@gmail.com; helo=mail-ej1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307336 Archived-At: --000000000000ef599a05ff71dd11 Content-Type: text/plain; charset="UTF-8" > > > If I read the logs correctly, commands python-add-import, > python-fix-imports, etc. will be introduced > > with Emacs 29. I am surprised there's no NEWS item related to those > commands. Are the menu > > entries considered enough? > > It's an omission. Feel free to write a NEWS entry and post it. > Here is a proposal: diff --git a/etc/NEWS b/etc/NEWS index 9e6f0c16bcd..f9621ef9164 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -3056,6 +3056,12 @@ Without a prefix argument, the kind of shell (buffer-dedicated, project-dedicated or global) is specified by the new 'python-shell-dedicated' user option. +*** New commands to manage Python imports. +'python-add-import', 'python-import-symbol-at-point', +'python-remove-import', 'python-fix-imports', 'python-sort-imports'. +The implementation relies on the Python library isort in version at +least 5.7.0. + ** Ruby Mode --- > > --- a/lisp/progmodes/python.el > > +++ b/lisp/progmodes/python.el > > @@ -6420,7 +6420,7 @@ python--list-imports > > (mapcar #'file-local-name source))))) > > lines) > > (unless (eq 0 status) > > - (error "%s exited with status %s (maybe isort is missing?)" > > + (error "%s exited with status %s (maybe isort>=5.7.0 is > missing?)" > > python-interpreter status)) > > (goto-char (point-min)) > > (while (not (eobp)) > > @@ -6465,7 +6465,7 @@ python--do-isort > > "-m" "isort" "-" args)) > > (tick (buffer-chars-modified-tick))) > > (unless (eq 0 status) > > - (error "%s exited with status %s (maybe isort is > missing?)" > > + (error "%s exited with status %s (maybe isort>=5.7.0 is > missing?)" > > Thanks, but the "isort>=5.7.0" part is quite cryptic. Can we do > better? > Yes, I'll work on it. I'll report a bug and send a patch there. -- Matthias --000000000000ef599a05ff71dd11 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> If I read the logs correctly, commands python-add-import, python-fix-i= mports, etc. will be introduced
> with Emacs 29. I am surprised there's no NEWS item related to thos= e commands. Are the menu
> entries considered enough?

It's an omission.=C2=A0 Feel free to write a NEWS entry and post it.

Here is a proposal:

diff --git a/etc/NEWS b/etc/NEWS
index 9e6f0c16bcd..f9621ef9164 = 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3056,6 +3056,12 @@ Withou= t a prefix argument, the kind of shell (buffer-dedicated,
=C2=A0project-= dedicated or global) is specified by the new
=C2=A0'python-shell-ded= icated' user option.
=C2=A0
+*** New commands to manage Python im= ports.
+'python-add-import', 'python-import-symbol-at-point&= #39;,
+'python-remove-import', 'python-fix-imports', = 9;python-sort-imports'.
+The implementation relies on the Python lib= rary isort in version at
+least 5.7.0.
+
=C2=A0** Ruby Mode
=C2= =A0
=C2=A0---
=C2=A0
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -6420,7 +6420,7 @@ python--list-imports
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (mapcar #'file-local-n= ame source)))))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0lines)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (eq 0 status)
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "%s exited with status= %s (maybe isort is missing?)"
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "%s exited with status= %s (maybe isort>=3D5.7.0 is missing?)"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0py= thon-interpreter status))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (goto-char (point-min))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (while (not (eobp))
> @@ -6465,7 +6465,7 @@ python--do-isort
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"-m" "isort&= quot; "-" args))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (tick (b= uffer-chars-modified-tick)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (eq 0 status)<= br> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "%s exit= ed with status %s (maybe isort is missing?)"
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (error "%s exit= ed with status %s (maybe isort>=3D5.7.0 is missing?)"

Thanks, but the "isort>=3D5.7.0" part is quite cryptic.=C2=A0 = Can we do
better?

Yes, I'll work on it.=C2=A0= I'll report a bug and send a patch there.
--
Matthias
--000000000000ef599a05ff71dd11--