From unknown Sat Aug 16 21:17:30 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#72750 <72750@debbugs.gnu.org> To: bug#72750 <72750@debbugs.gnu.org> Subject: Status: 29.3; indent-region changes semantics of python code Reply-To: bug#72750 <72750@debbugs.gnu.org> Date: Sun, 17 Aug 2025 04:17:30 +0000 retitle 72750 29.3; indent-region changes semantics of python code reassign 72750 emacs submitter 72750 Michael Arndt severity 72750 normal tag 72750 wontfix notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 21 14:08:07 2024 Received: (at submit) by debbugs.gnu.org; 21 Aug 2024 18:08:07 +0000 Received: from localhost ([127.0.0.1]:36300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sgpkc-0003Rf-Q6 for submit@debbugs.gnu.org; Wed, 21 Aug 2024 14:08:07 -0400 Received: from lists.gnu.org ([209.51.188.17]:54174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sgpkY-0003RT-VV for submit@debbugs.gnu.org; Wed, 21 Aug 2024 14:08:06 -0400 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 1sgpjp-0006Gr-Hj for bug-gnu-emacs@gnu.org; Wed, 21 Aug 2024 14:07:17 -0400 Received: from hognose1.porkbun.com ([35.82.102.206]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sgpjj-0002Mi-Dz for bug-gnu-emacs@gnu.org; Wed, 21 Aug 2024 14:07:15 -0400 Received: from [192.168.178.20] (cust-116-160-209-31.ip-customer.net [31.209.160.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: michael@rndt.dev) by hognose1.porkbun.com (Postfix) with ESMTPSA id 747A944A82 for ; Wed, 21 Aug 2024 18:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rndt.dev; s=default; t=1724263619; bh=/Hrn/nuD1/KHDVv308HW4Rrvo31fXgj9A97E+PyPh2s=; h=Date:To:Subject:From; b=vxYfYWmkot5ODN7bLjBPfMyZYCZfc7ZDiZb8rNplk2fqwi7pMne7yL8LYJn0RPphh QGWvbZjSWphmGWSHEozsmzzVROPGvgq3NHrF3dUaGDi0FI0T2dX1m2toBM2+pFaoRs vRm7sKxD8ja20BGj6KmjD9Z8Cq2F+rIr3s7ac4C0= Message-ID: Date: Wed, 21 Aug 2024 20:06:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: bug-gnu-emacs@gnu.org Subject: 29.3; indent-region changes semantics of python code Content-Language: en-US From: Michael Arndt Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=35.82.102.206; envelope-from=michael@rndt.dev; helo=hognose1.porkbun.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi, I have a problem when indenting python files. There seems to be a case when using indent-region changes the semantics of the python code. When there is no blank line after an if-statement, the next line becomes part of the if statement. The problem can be reproduced by the following steps: 1. Start emacs -Q 2. Create a python file with the following contents: if False:      print("output1") print("output2") 3. Use M-x mark-whole-buffer 4. Use M-x indent-region 5. The file contents change into: if False:      print("output1")      print("output2") The problem can be avoided by adding a blank line after the if statement. Because I use a custom indentation function that calls (indent-region (point-min) (point-max)) this can happen pretty quickly. Is this a limitation of python-indent-region? Greetings Michael In GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.33, cairo version 1.18.0) of 2024-04-02 built on titan Repository revision: ae8f815613c2e072e92aa8fe7b4bcf2fdabc7408 Repository branch: HEAD Windowing system distributor 'The X.Org Foundation', version 11.0.12101011 System Description: Debian GNU/Linux trixie/sid Configured using: 'configure CFLAGS=-O3 --with-json --with-native-compilation --without-xinput2 --with-modules --prefix=/usr/local --with-tree-sitter' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XPM GTK2 ZLIB Important settings: value of $LC_TIME: de_DE.UTF-8 value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs comp comp-cstr warnings icons subr-x rx cl-seq cl-macs gv cl-extra help-mode bytecomp byte-compile cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 77191 7214) (symbols 48 7170 0) (strings 32 19723 1946) (string-bytes 1 598864) (vectors 16 15710) (vector-slots 8 328515 15479) (floats 8 39 46) (intervals 56 242 0) (buffers 984 12)) From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 23 14:53:44 2024 Received: (at submit) by debbugs.gnu.org; 23 Aug 2024 18:53:44 +0000 Received: from localhost ([127.0.0.1]:40133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1shZPr-00015q-Sv for submit@debbugs.gnu.org; Fri, 23 Aug 2024 14:53:44 -0400 Received: from lists.gnu.org ([209.51.188.17]:54124) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1shZPq-00015h-30 for submit@debbugs.gnu.org; Fri, 23 Aug 2024 14:53:42 -0400 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 1shZP4-0001jS-6x for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2024 14:52:54 -0400 Received: from mout.kundenserver.de ([217.72.192.74]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1shZP2-00037J-CZ for bug-gnu-emacs@gnu.org; Fri, 23 Aug 2024 14:52:53 -0400 Received: from [192.168.178.61] ([89.247.171.232]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MEVBc-1st7q50mxm-0052pE for ; Fri, 23 Aug 2024 20:52:43 +0200 Content-Type: multipart/alternative; boundary="------------jFMtlo9f8xBo4GW0LmqgNSEx" Message-ID: Date: Fri, 23 Aug 2024 20:52:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#72750: 29.3; indent-region changes semantics of python code To: bug-gnu-emacs@gnu.org References: Content-Language: en-US From: =?UTF-8?Q?Andreas_R=C3=B6hler?= In-Reply-To: X-Provags-ID: V03:K1:PyBhimlrjcAKtazyxoWG2g0MRyJ2pn9E34jB6O7oRtP6u4e6rwd RvJdFlnh7qUQfgYFo96SIKYnt/qhzWCRHb3VZLjANUnoVdSyGEX9xzDDq0tug9OdR+NJzXm FmAavCeZACRcvQBbE63qZqRNAKgngRKOnXJuohAWfSRS6R3cMP/4Q6Y93tP/WWEGSZcWc4n FWhCzXIaZY6tkeC7nmcXQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:rVKeBCmwH/k=;BIMrxAi1QxZj3jvUMIZwi6ggpHR iYVkagf/eEh0QslwALvrYwLTN5Jbs7mS0RUZaHc1PlVA1vAIV0nWnZz2ZDIJ4SdECW+fqiKkh ER8kcMVU7Jzax5r5nAqi3hHKZO2/DAepL7WSMbbAuKKvIAwHxUqv9t5aHmWxda26IKmT6XeGd oSZ0qway7AFzLIBLvRYn2IhyqQWYcoIF5Fr8r8cAt5DMY4QqueQZuZt/bpA+iuKdv+SJjit3u hjzz/MOkX0DaQARIEWU/kvbL/PhnCMwMHbNVBBvbomQtGganOmtpwIVnixKcCXGDkzWgL9+SV uL7RnJdcWXxzBwfvxw0Y6qwNnutwLMJzvqzfXD4mSwe/u6OUE7Nu52keI8gYkZnT+cxjr8F4v hiiqABOVEVDSb+y1W2IOSbVCant44zvThW0xtdKtonVS3EI5idzazr+GXm/bSDiDjabcBxQGV Qj0E/VgCQzShX8n2NTouYK0/h0hTJu0yz1azeOKfTHgRj3pmvUQOO7MK1IuqTJ2tYzf7kaBhF 46GtkHFmas7neUZVTiqHYmXlK0fLd7Hsal6TxdZp8wkU+5KtmBGX+OLbSUlRBef+LjX0B2Et2 /aKW89Dy9l4rU+9z3LQHaVDnEsqWvo8G673YW8u7dw8cuit2D62+aS3qZqpwya6zZuyNWG2+R 1sfqGLYVMT8ce0ZSVItv79jxrpFN5WuG9ENbg0vNrkb2AlB+q+Vwfi6l7Dmo/Lfv6OzZsDbFi LSVI1XOzAnTZv+ylJUobNUW7KBcf5Mf1g== Received-SPF: pass client-ip=217.72.192.74; envelope-from=andreas.roehler@easy-emacs.de; helo=mout.kundenserver.de X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 2.2 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Am 21.08.24 um 20:06 schrieb Michael Arndt via Bug reports for GNU Emacs, the Swiss army knife of text editors: > Hi, > > I have a problem when indenting python files. There seems to be a case > when [...] Content analysis details: (2.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [209.51.188.17 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [89.247.171.232 listed in zen.spamhaus.org] 0.0 HTML_MESSAGE BODY: HTML included in message X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Am 21.08.24 um 20:06 schrieb Michael Arndt via Bug reports for GNU Emacs, the Swiss army knife of text editors: > Hi, > > I have a problem when indenting python files. There seems to be a case > when [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [89.247.171.232 listed in zen.spamhaus.org] -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [209.51.188.17 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 HTML_MESSAGE BODY: HTML included in message -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager This is a multi-part message in MIME format. --------------jFMtlo9f8xBo4GW0LmqgNSEx Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Am 21.08.24 um 20:06 schrieb Michael Arndt via Bug reports for GNU Emacs, the Swiss army knife of text editors: > Hi, > > I have a problem when indenting python files. There seems to be a case > when using indent-region changes the semantics of the python code. When > there is no blank line after an if-statement, the next line becomes part > of the if statement. > > The problem can be reproduced by the following steps: > > 1. Start emacs -Q > 2. Create a python file with the following contents: > > if False: >      print("output1") > print("output2") > > 3. Use M-x mark-whole-buffer > 4. Use M-x indent-region > 5. The file contents change into: > > if False: >      print("output1") >      print("output2") > > The problem can be avoided by adding a blank line after the if statement. > Because I use a custom indentation function that calls (indent-region > (point-min) (point-max)) this can happen pretty quickly. Is this a > limitation of python-indent-region? > > Greetings > Michael > > Hi Michael, I'm not maintaining the related code, just a comment: as indent might by syntax at Python, there is not way for auto-formatting - unless you are happy with the outmost reasonable indent. |Best,| |Andreas | --------------jFMtlo9f8xBo4GW0LmqgNSEx Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


Am 21.08.24 um 20:06 schrieb Michael Arndt via Bug reports for GNU Emacs, the Swiss army knife of text editors:
Hi,

I have a problem when indenting python files. There seems to be a case
when using indent-region changes the semantics of the python code. When
there is no blank line after an if-statement, the next line becomes part
of the if statement.

The problem can be reproduced by the following steps:

1. Start emacs -Q
2. Create a python file with the following contents:

if False:
     print("output1")
print("output2")

3. Use M-x mark-whole-buffer
4. Use M-x indent-region
5. The file contents change into:

if False:
     print("output1")
     print("output2")

The problem can be avoided by adding a blank line after the if statement.
Because I use a custom indentation function that calls (indent-region
(point-min) (point-max)) this can happen pretty quickly. Is this a
limitation of python-indent-region?

Greetings
Michael


Hi Michael,

I'm not maintaining the related code, just a comment:

as indent might by syntax at Python, there is not way for auto-formatting - unless you are happy with the outmost reasonable indent.

Best,

Andreas

--------------jFMtlo9f8xBo4GW0LmqgNSEx-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 21 07:58:16 2024 Received: (at 72750) by debbugs.gnu.org; 21 Sep 2024 11:58:16 +0000 Received: from localhost ([127.0.0.1]:37534 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srykh-0002ZA-Vq for submit@debbugs.gnu.org; Sat, 21 Sep 2024 07:58:16 -0400 Received: from mail-ed1-f47.google.com ([209.85.208.47]:58706) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srykg-0002Yt-AI for 72750@debbugs.gnu.org; Sat, 21 Sep 2024 07:58:15 -0400 Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-5c5b9d2195eso298776a12.1 for <72750@debbugs.gnu.org>; Sat, 21 Sep 2024 04:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726919808; x=1727524608; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=izibk0Z3j/qkyMUhk6u2sJMeft6Pv739RBvKEy6zs6g=; b=lPxz26DlWK0Wfyw6rTR0daxFd/ii2NZpQMpzS0lLnDdW+CPVHQQEZyyfpsjYQ///VQ +mHrR0TWjraHMFpRiN3ouPMbLmfSY+mkKVaA4G3lueLY1jTq5g76F49Sdvxgw3sGr9wv 842S4knA+S6k4Rgm6m2JRFiwtptW+UG3j68TJzsatFF6FDbMyPwMcOB2v+tWwd7A+hbb KAbatW1K2SUxA5fhNpPTAHZ47a5GtEbEQpOLXt3al6iwtoGGWzAvOaeE7gUBFJENf4wX WmPkNmrsEgrVcag4Frj3q1AruUzTrwujjW6ak1Id/FvcPfvBtxGSt1RoP1PcVfeAafM4 YHBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726919808; x=1727524608; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=izibk0Z3j/qkyMUhk6u2sJMeft6Pv739RBvKEy6zs6g=; b=DGaXPumasZJJTves+5krErGFZhns1eRJNZnZ1ms+rL2zRd035KozM0GUB+xoT+pcd0 vi71F8XsQ1B4v7lNxC8GZi+Iq/9qQ9CJZOZCoysDl6xhCreqgfXZWYqYjvq3HK9Cs2h2 opaJHlh4nYc16jXPjJPT9S8kYLOLEbLfom4juUaTE5idu0wbH7k0N9FyJAMZBLXk2U3h +d2u3OaH1CY/HuN6fOoEzchiufCPZH8pd1cSNxaupJqf4bvmCFzG4BON2Yix3wAt+fJL JeufH/Z+CcoUuh84UxgWzVVwv347d+y7ENTJuuu4uIUfduCd4KsqgAizYMGYb31Dg54j yG6A== X-Forwarded-Encrypted: i=1; AJvYcCX3lucCznI2SU98IAPAoOo3oYkzsZrAd4eYAipGcyGs7Fusqn9oVFkao67k1bTltQHuJVHpPA==@debbugs.gnu.org X-Gm-Message-State: AOJu0YwJJjW9ZSaWf1s3zz4/lJ+Zo7Ced0xuhAwsIjpCQUMekNSP0u4K wDUC/qgTkEab1Rj6wsm8b/NMcYNA1WNdeV2CnWG13y23dl4ipCoiCuBnVWPGBkxolnaSXxJcIis YQYxajZzImSsH4uIKLuY2LoOL99h/1A== X-Google-Smtp-Source: AGHT+IF5e72AeQ/Tw8e7StlgSamUDakbwHM3VsLQUY+30uICEzXDGrovFvLFLK+N26eZXZK6WvmT26i+tNHOa+2aIRc= X-Received: by 2002:a05:6402:3596:b0:5c4:2e48:6c3 with SMTP id 4fb4d7f45d1cf-5c464db0705mr4565272a12.4.1726919808149; Sat, 21 Sep 2024 04:56:48 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 21 Sep 2024 07:56:47 -0400 From: Stefan Kangas In-Reply-To: References: MIME-Version: 1.0 Date: Sat, 21 Sep 2024 07:56:47 -0400 Message-ID: Subject: Re: bug#72750: 29.3; indent-region changes semantics of python code To: Michael Arndt , 72750@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 72750 Cc: kobarity X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael Arndt via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: > I have a problem when indenting python files. There seems to be a case > when using indent-region changes the semantics of the python code. When > there is no blank line after an if-statement, the next line becomes part > of the if statement. > > The problem can be reproduced by the following steps: > > 1. Start emacs -Q > 2. Create a python file with the following contents: > > if False: > =C2=A0=C2=A0=C2=A0=C2=A0 print("output1") > print("output2") > > 3. Use M-x mark-whole-buffer > 4. Use M-x indent-region > 5. The file contents change into: > > if False: > =C2=A0=C2=A0=C2=A0=C2=A0 print("output1") > =C2=A0=C2=A0=C2=A0=C2=A0 print("output2") > > The problem can be avoided by adding a blank line after the if statement. > Because I use a custom indentation function that calls (indent-region > (point-min) (point-max)) this can happen pretty quickly. Is this a > limitation of python-indent-region? I'm not sure that I see a bug here. I don't think one can generally expect `indent-region` to be able to avoid changing semantics in a language where indentation matters. I'm copying in kobarity, in case he has any comments. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 21 10:52:54 2024 Received: (at 72750) by debbugs.gnu.org; 21 Sep 2024 14:52:54 +0000 Received: from localhost ([127.0.0.1]:40133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ss1Th-0004XL-Tt for submit@debbugs.gnu.org; Sat, 21 Sep 2024 10:52:54 -0400 Received: from mail-pl1-f182.google.com ([209.85.214.182]:44134) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ss1Tf-0004X7-JH for 72750@debbugs.gnu.org; Sat, 21 Sep 2024 10:52:52 -0400 Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-208ccde82e6so24772715ad.0 for <72750@debbugs.gnu.org>; Sat, 21 Sep 2024 07:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726930285; x=1727535085; 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=VPHXe9LmSb5+bhYdc5xCBFROKmCNtkDK8DFHCuMvZvc=; b=SLqJK78CvlYmtRHfz2PsvUqNlRERv5QhNPsvdiPjV2JyCpqbkAtyaokmdJ1hPKYDmT NzCpbHJjdq4h2WUA7sNe+1zFOgXot7OqAtlj76GKZP/bCesr0/llhMWaGmMHTJAdW+41 osswtOm+smi+7Fwn2Jo7c5tU1ZlGtf666RF82ubTvSASWggRqKdGuldrcNhJT6D2r5K8 pZTDoPdQgJDgacQ8tarwdx8jcFKMSFh9FF3fbGKst53jqWloG0eJ+4HtDDBzvujDN7Ki Tce8Qt5AspLAfmdovwn82hFGZLxxibCARSEDWGiLPvj4fSChJby1eislPCVdeVxOfCod 8RDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726930285; x=1727535085; 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=VPHXe9LmSb5+bhYdc5xCBFROKmCNtkDK8DFHCuMvZvc=; b=c135SLdn8m1lGu3MUx82NZ5JXg/VB1tUp2L/E28MM2/EG9Jo9pTo3TcflopMYiEWEf JnZZJ14n93ppdXXgUjRbe8hEAWXjGjVbL4Pjka8JdL3yARM/A57SJyM1sDy2cjY3qoTK wiVDDGBmmSNRUp/ZgjRTwBCdNAJSJVKNMubLjdrucEQGD0jyprBElVzGV8FVy9E41PE1 lsxCuUgCea0HaHxfPucxmwLsxmfzIYz+dERKMgj+mnco/kKSei4LEz7avEar/TWbU5+e FBnMcMOrly1mXWmdICT8h79ynKcr8fLd/CpJ7K2miGkoonuOy1PTmvW1/lSGfIv3q0iS LEjg== X-Gm-Message-State: AOJu0YxOxTOpSpdrB1nL5RDaB38E387P4DgsHg8aDC0pzIQDGddEhQ+a Q5P+I1NBcmV1Ne6oodSfPvg1p6OoRsybrNIcGEEE1Jdqgs20JcKU X-Google-Smtp-Source: AGHT+IGumIYEQYkKILl4PFYZOyWVnunJ31ylKAhyR92UWMWm4IUj3JOA/punPPyUD3jEyabOwZusjQ== X-Received: by 2002:a17:902:f64e:b0:207:15f9:484a with SMTP id d9443c01a7336-208d8397d2fmr84891075ad.15.1726930285083; Sat, 21 Sep 2024 07:51:25 -0700 (PDT) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-207946010e4sm109990105ad.73.2024.09.21.07.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2024 07:51:24 -0700 (PDT) Date: Sat, 21 Sep 2024 23:51:00 +0900 Message-ID: From: kobarity To: Stefan Kangas , Michael Arndt Subject: Re: bug#72750: 29.3; indent-region changes semantics of python code In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/31.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) 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 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 72750 Cc: 72750@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Kangas wrote: > Michael Arndt via "Bug reports for GNU Emacs, the Swiss army knife of > text editors" writes: >=20 > > I have a problem when indenting python files. There seems to be a case > > when using indent-region changes the semantics of the python code. When > > there is no blank line after an if-statement, the next line becomes part > > of the if statement. > > > > The problem can be reproduced by the following steps: > > > > 1. Start emacs -Q > > 2. Create a python file with the following contents: > > > > if False: > > =A0=A0=A0=A0 print("output1") > > print("output2") > > > > 3. Use M-x mark-whole-buffer > > 4. Use M-x indent-region > > 5. The file contents change into: > > > > if False: > > =A0=A0=A0=A0 print("output1") > > =A0=A0=A0=A0 print("output2") > > > > The problem can be avoided by adding a blank line after the if statemen= t. > > Because I use a custom indentation function that calls (indent-region > > (point-min) (point-max)) this can happen pretty quickly. Is this a > > limitation of python-indent-region? >=20 > I'm not sure that I see a bug here. I don't think one can generally > expect `indent-region` to be able to avoid changing semantics in a > language where indentation matters. I agree. Even though `python-indent-region' can be improved to some extent, it seems to me that it is better to use an external tool like "black" to preserve the semantics and format the entire buffer. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 21 12:04:18 2024 Received: (at 72750) by debbugs.gnu.org; 21 Sep 2024 16:04:18 +0000 Received: from localhost ([127.0.0.1]:40233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ss2ao-00008u-CF for submit@debbugs.gnu.org; Sat, 21 Sep 2024 12:04:18 -0400 Received: from hognose1.porkbun.com ([35.82.102.206]:49882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ss2am-00008f-Bf for 72750@debbugs.gnu.org; Sat, 21 Sep 2024 12:04:17 -0400 Received: from [192.168.178.20] (cust-235-163-209-31.ip-customer.net [31.209.163.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: michael@rndt.dev) by hognose1.porkbun.com (Postfix) with ESMTPSA id 7C69944C21; Sat, 21 Sep 2024 16:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rndt.dev; s=default; t=1726934629; bh=jU0M1BZFw8MwKarlRmNapoYNZNVw+7l+c6emYLdLZGY=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=HwxJ8MluTypO17eSVbVQ1UrU2NYypt2TDKb/k/xOVvp7hjCMPjeo6vSnVbL1aB80l XuK2Gx2nKOYdliqz0KQwGw2LeMFcxUU8icaw9Y8h/uJ0hF8zm/d2nrGaNv0fakDnTo RDJjTRrg6zmL1EXSBtJMRo4pG60zV2e4odbEwfr4= Content-Type: multipart/alternative; boundary="------------P0ZyzxCEPjfTwZWOmDM9lwJ8" Message-ID: Date: Sat, 21 Sep 2024 18:03:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#72750: 29.3; indent-region changes semantics of python code To: kobarity , Stefan Kangas References: Content-Language: en-US From: Michael Arndt In-Reply-To: X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 72750 Cc: 72750@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) This is a multi-part message in MIME format. --------------P0ZyzxCEPjfTwZWOmDM9lwJ8 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 21.09.24 16:51, kobarity wrote: > I agree. Even though `python-indent-region' can be improved to some > extent, it seems to me that it is better to use an external tool like > "black" to preserve the semantics and format the entire buffer. That's fine for me too. I will use something like `eglot-format' to format my python files instead. Thank you. --------------P0ZyzxCEPjfTwZWOmDM9lwJ8 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
On 21.09.24 16:51, kobarity wrote:
I agree.  Even though `python-indent-region' can be improved to some
extent, it seems to me that it is better to use an external tool like
"black" to preserve the semantics and format the entire buffer.
That's fine for me too. I will use something like `eglot-format' to format my python files instead. Thank you.
--------------P0ZyzxCEPjfTwZWOmDM9lwJ8-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 21 21:07:23 2024 Received: (at 72750) by debbugs.gnu.org; 22 Sep 2024 01:07:23 +0000 Received: from localhost ([127.0.0.1]:40511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ssB4M-00042r-Qz for submit@debbugs.gnu.org; Sat, 21 Sep 2024 21:07:23 -0400 Received: from mail-ed1-f48.google.com ([209.85.208.48]:56509) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ssB4K-00042P-Ar for 72750@debbugs.gnu.org; Sat, 21 Sep 2024 21:07:21 -0400 Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5c50ea4419dso1656999a12.0 for <72750@debbugs.gnu.org>; Sat, 21 Sep 2024 18:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726967153; x=1727571953; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=fb0BfUtx0Do3zr7amlXcvgLqc568T8d8slJ7O794FCU=; b=mvHa3G00Bu55M0RYmnPrRpBIYvOIi29c1FdcSVJJrQVR5dYPVLQUOrPJCSVli1MfsU 3G4qvB/pzvg8WWcAO0TJIZBgpnN8UliSQ9xjyoYxXKu678Tt/C5jz7ZqylU2V7eEmf80 TYvA/y7M8hcVQNiUNgZzYCiNegNXoNQV3k/+QL6lJ6GgoKtB3t5W3iskqq7c/t7fWUc0 lhrFpo2MJ1LNI91+sZXlCGtWD2yZ5Yfjrg74tOA3ywLldmDCEQZOXdqhYBPgfGtyyzAN JMUHD/N/ellcLaMe/am3Swyx/pZX7TULUYQ9JfUTzwxZu5ujKDhzDj7/+KeUEg953ItS vBzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726967153; x=1727571953; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fb0BfUtx0Do3zr7amlXcvgLqc568T8d8slJ7O794FCU=; b=blbtKgTBbg/yccGJPDOSYS+BZY4MQEBCUuLz6XFPuF+LuHlkeqOHnNK1GS2m3C9VMD 3eys6hejPmK4dwgt7pIlXSVKGDPdNUtEX/2CitsD7cv/dTzt6MBvAUoC70wz5kQvyO3k W+Qy5gyH9alRcuYzN7x8/1tLCdzDaJJzrpNGGjpmO3X2XK1IU0EzO79JIfr59MIE/xUX /Mx1+WO11Mjk5WTGXC6qNYQ2ooIPZ8rv2sMGDW60R8G4fA5GR8gTR92XMsGmETA2E9Hz ELTvdCjWT/WL5ms1NNB1hXuejwuQEVPASQQQ4FCItLaGD0P9wcCrFmTihTFRi88bdE08 pgdQ== X-Gm-Message-State: AOJu0YxYzOD95S+Iww3Eh5sDctkd0O35stmUhf1QhA+g7J1VoqGOqRvm zzOmB4og9Cq3DGTVJXGSNpzZmlBCszmmCSFDm1ZvSW42ZXKOinD/Kodi6PHmUkMbt7FDDfXh12X rhKMZDpmsT82Kz4lwsVr1dqOmDApN/g== X-Google-Smtp-Source: AGHT+IE6iqWCBGVnVFf976oxd7qGF3ZPyN61kxerdx66aqxptUhxEBZH56pIKazFA7nD2rTs4k37YoOnRJ5wtCQjdpE= X-Received: by 2002:a05:6402:c4a:b0:5c3:2440:856f with SMTP id 4fb4d7f45d1cf-5c464dea4damr6153416a12.27.1726967153141; Sat, 21 Sep 2024 18:05:53 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 21 Sep 2024 18:05:52 -0700 From: Stefan Kangas In-Reply-To: References: MIME-Version: 1.0 Date: Sat, 21 Sep 2024 18:05:52 -0700 Message-ID: Subject: Re: bug#72750: 29.3; indent-region changes semantics of python code To: Michael Arndt , kobarity Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 72750 Cc: 72750@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 72750 + notabug wontfix close 72750 thanks Michael Arndt writes: > On 21.09.24 16:51, kobarity wrote: >> I agree. Even though `python-indent-region' can be improved to some >> extent, it seems to me that it is better to use an external tool like >> "black" to preserve the semantics and format the entire buffer. > That's fine for me too. I will use something like `eglot-format' to > format my python files instead. Thank you. You could also try the package `blacken`: https://github.com/pythonic-emacs/blacken I'm closing this bug report. From unknown Sat Aug 16 21:17:30 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 20 Oct 2024 11:24:11 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator