GNU bug report logs - #59009
python mode indentation behavior fix

Previous Next

Package: emacs;

Reported by: Randomneo <rostislav9999 <at> gmail.com>

Date: Fri, 4 Nov 2022 04:58:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59009 in the body.
You can then email your comments to 59009 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#59009; Package emacs. (Fri, 04 Nov 2022 04:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Randomneo <rostislav9999 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 04 Nov 2022 04:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Randomneo <rostislav9999 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: python mode indentation behavior fix
Date: Thu, 3 Nov 2022 18:41:42 +0300
[Message part 1 (text/plain, inline)]
This patch will fix this bug #42513
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=42513>.
Also problems with same behaviour with pair of statements when one of them
is multiline with prantaces like https://pastebin.com/Z1yFbMtp.

with best regards Misiura Rostislav
[Message part 2 (text/html, inline)]
[0001-python.el-Opening-block-search-fix.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59009; Package emacs. (Sun, 06 Nov 2022 08:20:02 GMT) Full text and rfc822 format available.

Message #8 received at 59009 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Randomneo <rostislav9999 <at> gmail.com>, kobarity <kobarity <at> gmail.com>
Cc: 59009 <at> debbugs.gnu.org
Subject: Re: bug#59009: python mode indentation behavior fix
Date: Sun, 06 Nov 2022 10:18:35 +0200
> From: Randomneo <rostislav9999 <at> gmail.com>
> Date: Thu, 3 Nov 2022 18:41:42 +0300
> 
> This patch will fix this bug #42513.
> Also problems with same behaviour with pair of statements when one of them is multiline with prantaces like
> https://pastebin.com/Z1yFbMtp.
> 
> with best regards Misiura Rostislav
> 
> From 91b310d1412366340b6deeff65519e248d87a10f Mon Sep 17 00:00:00 2001
> From: Rostyslav Misiura <rostislav9999 <at> gmail.com>
> Date: Thu, 3 Nov 2022 18:27:38 +0300
> Subject: [PATCH] python.el: Opening block search fix
> 
> ---
>  lisp/progmodes/python.el | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index cec0d54a44..3ca8e49f2b 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -5373,16 +5373,16 @@ likely an invalid python file."
>                                    (apply #'min collected-indentations)))
>                             ;; There must be no line with indentation
>                             ;; smaller than `indentation' (except for
> -                           ;; blank lines) between the found opening
> -                           ;; block and the current line, otherwise it
> -                           ;; is not an opening block.
> +                           ;; blank lines and comments) between the found
> +                           ;; opening block and the current line,
> +                           ;; otherwise it is not an opening block.
>                             (save-excursion
>                               (forward-line)
>                               (let ((no-back-indent t))
>                                 (save-match-data
>                                   (while (and (< (point) cur-line)
>                                               (setq no-back-indent
> -                                                   (or (> (current-indentation) indentation)
> +                                                   (or (>= (current-indentation) indentation)
>                                                         (python-info-current-line-empty-p)
>                                                         (python-info-current-line-comment-p))))
>                                     (forward-line)))
> -- 
> 2.38.1

kobarity, any comments on this patch?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59009; Package emacs. (Mon, 07 Nov 2022 13:59:02 GMT) Full text and rfc822 format available.

Message #11 received at 59009 <at> debbugs.gnu.org (full text, mbox):

From: kobarity <kobarity <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 59009 <at> debbugs.gnu.org, Randomneo <rostislav9999 <at> gmail.com>
Subject: Re: bug#59009: python mode indentation behavior fix
Date: Mon, 07 Nov 2022 22:57:48 +0900
[Message part 1 (text/plain, inline)]
Eli Zaretskii wrote:
> > From: Randomneo <rostislav9999 <at> gmail.com>
> > 
> > This patch will fix this bug #42513.
> 
> kobarity, any comments on this patch?

Hello,

Unfortunately, the presented patch breaks the ERT
python-indent-electric-colon-4.

I think the problem lies in the forward-line after block-start
detection.  The while loop is used to detect indentation inside the
block, so if block-start spans multiple lines, it should start at the
next line.  To address this issue, I propose to add
python-nav-end-of-statement before forward-line.  Attached is the
patch with an ERT.

Regards,
[0001-Fix-indentation-for-multi-line-block-start-in-Python.patch (application/octet-stream, attachment)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 10 Nov 2022 10:27:02 GMT) Full text and rfc822 format available.

Notification sent to Randomneo <rostislav9999 <at> gmail.com>:
bug acknowledged by developer. (Thu, 10 Nov 2022 10:27:02 GMT) Full text and rfc822 format available.

Message #16 received at 59009-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: kobarity <kobarity <at> gmail.com>
Cc: 59009-done <at> debbugs.gnu.org, rostislav9999 <at> gmail.com
Subject: Re: bug#59009: python mode indentation behavior fix
Date: Thu, 10 Nov 2022 12:26:48 +0200
> Date: Mon, 07 Nov 2022 22:57:48 +0900
> From: kobarity <kobarity <at> gmail.com>
> Cc: Randomneo <rostislav9999 <at> gmail.com>,
> 	59009 <at> debbugs.gnu.org
> Unfortunately, the presented patch breaks the ERT
> python-indent-electric-colon-4.
> 
> I think the problem lies in the forward-line after block-start
> detection.  The while loop is used to detect indentation inside the
> block, so if block-start spans multiple lines, it should start at the
> next line.  To address this issue, I propose to add
> python-nav-end-of-statement before forward-line.  Attached is the
> patch with an ERT.

Thanks, installed.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 08 Dec 2022 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 272 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.