unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56742: 29.0.50; Python indendation problem after comment
@ 2022-07-24 15:42 Stephen Berman
  2022-07-26 12:51 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Berman @ 2022-07-24 15:42 UTC (permalink / raw)
  To: 56742

[-- Attachment #1: Type: text/plain, Size: 1626 bytes --]

0. emacs -Q
1. C-x b test RET
2. Insert the following into buffer "test":

def test(n):
    if n < 0:
        return -1
    # test
    else:
        return 0

2. M-x python-mode RET (with buffer "test" current)
3. Put point on the line containing "else:" and type TAB
=> "else:" is dedented to column 0 and remains there on typing TAB
again (and again).

If the line containing "# test" is deleted and point put back on the
line containing "else:", then typing TAB indents "else:" to column 4
(where it was before being wrongly dedented) and remains there on typing
TAB again (as it should).

The same behavior happens with "elif" lines preceded by a comment line.

The attached patch prevents the wrong dedenting, but I'm not familiar
enough with the python.el code to be confident it's the correct fix.


In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6)
 of 2022-07-22 built on strobelfs2
Repository revision: 8434396fa362c6644ff23e1f48acace7b85ffe8f
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Linux From Scratch r11.0-165

Configured using:
 'configure --with-xinput2 --with-xwidgets 'CFLAGS=-Og -g3'
 PKG_CONFIG_PATH=/opt/qt5/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM
XINPUT2 XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: python.el patch --]
[-- Type: text/x-patch, Size: 890 bytes --]

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index f31832fec9..01b6693f94 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -5168,7 +5168,8 @@ python-info-dedenter-opening-block-positions
                                  (while (and (< (point) cur-line)
                                              (setq no-back-indent
                                                    (or (> (current-indentation) indentation)
-                                                       (python-info-current-line-empty-p))))
+                                                       (python-info-current-line-empty-p)
+                                                       (python-info-current-line-comment-p))))
                                    (forward-line)))
                                no-back-indent)))
                   (setq collected-indentations

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-27 18:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-24 15:42 bug#56742: 29.0.50; Python indendation problem after comment Stephen Berman
2022-07-26 12:51 ` Lars Ingebrigtsen
2022-07-27  3:27   ` kobarity
2022-07-27  9:39     ` Lars Ingebrigtsen
2022-07-27 18:01       ` Stephen Berman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).