GNU bug report logs - #15163
24.3; python-mode, electric colon bug

Previous Next

Package: emacs;

Reported by: Alexis Roda <alexis.roda.villalonga <at> gmail.com>

Date: Thu, 22 Aug 2013 16:18:01 UTC

Severity: normal

Fixed in version 24.3

Done: fgallina <at> gnu.org (Fabián Ezequiel Gallina)

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 15163 in the body.
You can then email your comments to 15163 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#15163; Package emacs. (Thu, 22 Aug 2013 16:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alexis Roda <alexis.roda.villalonga <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 22 Aug 2013 16:18:02 GMT) Full text and rfc822 format available.

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

From: Alexis Roda <alexis.roda.villalonga <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; python-mode, electric colon bug
Date: Thu, 22 Aug 2013 18:17:25 +0200
Electric colon don't indent when used in conjunction with
newline-and-indent in some nested statements.

To reproduce:

emacs -Q /tmp/bugtest.py

and type:

 i f SPC a : C-j i f SPC b : C-j p a s s C-j e l s e : C-j p a s s C-j 
e l s e :

you'll get:

if a:
    if b:
        pass
    else:
        pass
        else:

The last 'else' isn't indented properly.


In GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.4.2)
 of 2013-08-17 on superjul
Windowing system distributor `The X.Org Foundation', version 11.0.11300000
System Description:	Ubuntu 12.04.2 LTS

Configured using:
 `configure '--prefix=/opt/emacs/24.3''

Important settings:
  value of $LANG: ca_ES.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Python

Minor modes in effect:
  hi-lock-mode: t
  show-paren-mode: t
  global-hl-line-mode: t
  display-time-mode: t
  shell-dirtrack-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  autopair-global-mode: t
  autopair-mode: t
  outline-minor-mode: t
  diff-auto-refine-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<down> <down> <down> C-SPC <down> <down> <down> <down>
<down> <down> C-w i f SPC a : <return> p a s s <tab>
<return> e l s e : <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> i f <backspace> <backspace>
<backspace> i f SPC b : <tab> <return> p a s s <tab>
<return> e l s e : <tab> <return> e l s e : <return>
p a s s <tab> <return> <down-mouse-1> <mouse-1> <down>
C-SPC <down> <down> <down> <down> <down> <down> C-w
i f SPC a : C-j i f SPC b : C-j p a s s C-j e l s e
: C-j p a s s C-j e l s e : C-j p a s s C-j M-x r e
p o <tab> r <tab> <return>

Recent messages:
[yas] Loading for `python-mode', just-in-time: (yas--load-directory-1 
/home/alex/emacslib/shared/yasnippets/snippets/python-mode (quote 
python-mode) (quote (text-mode)))!
[yas] Loading compiled snippets from 
/home/alex/emacslib/shared/yasnippets/snippets/python-mode
Mark set
Closes if a: [2 times]
Closes if b:
Closes if a:
Auto-saving...done
Mark activated
Closes if b:
Making completion list...

Load-path shadows:
~/emacslib/site-lisp/rst hides 
/opt/emacs/24.3/share/emacs/24.3/lisp/textmodes/rst

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mail-utils hi-lock cus-edit uniquify
warnings paren hl-line time cus-start cus-load rainbow-mode color
css-mode buffer-move windmove todo todo-util python-pep8 tramp
tramp-compat auth-source eieio byte-opt bytecomp byte-compile cconv
gnus-util mm-util mail-prsvr password-cache tramp-loaddefs cl-macs gv
shell pcomplete format-spec flymake compile pydoc-info info-look info
arv-py yasnippet edmacro kmacro help-mode w3m-load template sql
thingatpt he-utils etags hippie-exp python rx comint ansi-color deft
autopair noutline outline pymacs psvn advice help-fns advice-preload
wid-edit cl cl-lib log-edit ring pcvs-util add-log diff-mode easy-mmode
easymenu multiple-cursors-autoloads rainbow-mode-autoloads
smart-operator-autoloads solarized-theme-autoloads package find-dired
dired time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win
x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15163; Package emacs. (Fri, 23 Aug 2013 06:35:01 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#15163: 24.3; python-mode, electric colon bug
Date: Fri, 23 Aug 2013 08:35:49 +0200
Am 22.08.2013 18:17, schrieb Alexis Roda:
> Electric colon don't indent when used in conjunction with
> newline-and-indent in some nested statements.
>
> To reproduce:
>
> emacs -Q /tmp/bugtest.py
>
> and type:
>
>   i f SPC a : C-j i f SPC b : C-j p a s s C-j e l s e : C-j p a s s C-j e l s e :
>
> you'll get:
>
> if a:
>      if b:
>          pass
>      else:
>          pass
>          else:
>
> The last 'else' isn't indented properly.
>
>

IMO 'else' shouldn't be indented at all here, as an "if" can't have two "else"-clauses

May confirm the bug with

GNU Emacs 24.3.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10) of 2013-07-06

Andreas





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15163; Package emacs. (Fri, 23 Aug 2013 11:19:01 GMT) Full text and rfc822 format available.

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

From: Alexis Roda <alexis.roda.villalonga <at> gmail.com>
To: 15163 <at> debbugs.gnu.org
Subject: Re: bug#15163: 24.3; python-mode, electric colon bug
Date: Fri, 23 Aug 2013 13:17:55 +0200
Reading the bugreport afterwards looks like it lacks the final point. I 
meant: I'd expect the last "else" to be aligned with the outermost "if".





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15163; Package emacs. (Tue, 27 Aug 2013 03:01:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Fabián E. Gallina <fabian <at> anue.biz>
Cc: 15163 <at> debbugs.gnu.org
Subject: Re: bug#15163: 24.3; python-mode, electric colon bug
Date: Mon, 26 Aug 2013 23:00:10 -0400
> if a:
>     if b:
>         pass
>     else:
>         pass
>         else:

> The last 'else' isn't indented properly.

Fabián, could you look into it?
When tracing through python-indent-electric-colon, I see that
python-info-closing-block-message returns nil, so we indent back to the
original indentation.
And while you're looking at this code, could you add a comment
explaining why you do

      (python-info-closing-block-message)
      (when (> indentation calculated-indentation)
        (save-excursion
          (indent-line-to calculated-indentation)
          (when (not (python-info-closing-block-message))
            (indent-line-to indentation)))))))

instead of (say)
      
      (when (and (python-info-closing-block-message)
                 (> indentation calculated-indentation))
        (save-excursion
          (indent-line-to calculated-indentation)))


-- Stefan




Reply sent to fgallina <at> gnu.org (Fabián Ezequiel Gallina):
You have taken responsibility. (Wed, 09 Jul 2014 03:59:02 GMT) Full text and rfc822 format available.

Notification sent to Alexis Roda <alexis.roda.villalonga <at> gmail.com>:
bug acknowledged by developer. (Wed, 09 Jul 2014 03:59:03 GMT) Full text and rfc822 format available.

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

From: fgallina <at> gnu.org (Fabián Ezequiel Gallina)
To: 15163-done <at> debbugs.gnu.org
Subject: 24.3; python-mode, electric colon bug
Date: Wed, 09 Jul 2014 00:58:14 -0300
Fixed in revno 117366.


Cheers,
Fabián




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15163; Package emacs. (Wed, 09 Jul 2014 04:02:01 GMT) Full text and rfc822 format available.

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

From: fgallina <at> gnu.org (Fabián Ezequiel Gallina)
To: 15163-done <at> debbugs.gnu.org
Subject: Re: 24.3; python-mode, electric colon bug
Date: Wed, 09 Jul 2014 01:01:43 -0300
(emacs-24 branch)




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 06 Aug 2014 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 291 days ago.

Previous Next


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