unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* 23.0.60; python-mode indents try...except...finally incorrectly
@ 2008-03-23 21:33 Phil Sung
  2008-04-23  3:34 ` Phil Sung
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Sung @ 2008-03-23 21:33 UTC (permalink / raw)
  To: emacs-pretest-bug

In GNU Emacs 23.0.60.1 (i486-pc-linux-gnu, GTK+ Version 2.12.8)
 of 2008-03-01 on palmer, modified by Debian
 (emacs-snapshot package, version 1:20080228-1ubuntu1)
configured using `configure  '--build' 'i486-linux-gnu' '--host'
'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib'
'--libexecdir=/usr/lib' '--localstatedir=/var'
'--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/23.0.60/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.0.60/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.0.60/leim'
'--with-x=yes' '--with-x-toolkit=gtk' '--enable-font-backend'
'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu'
'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g
-Wl,--as-needed' 'CPPFLAGS=''


In python-mode, if you attempt to type the following...

def f():
    try:
        foo
    except:
        bar
    finally:
        baz

it gets incorrectly indented as shown below. Emacs tries to put
"finally:" in the first column.

def f():
    try:
        foo
    except:
        bar
finally:
    baz

"finally:" is allowed after an "except:" at the same level in Python
2.5 and later. The patch below fixes python.el to allow that
construct.

--Phil


    progmodes/python.el (python-block-pairs): Allow "finally:" at the same
    level as, and following, an "except:". (try... except... finally blocks are
    allowed in Python 2.5 and later.)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index e9f3daf..cca0bb0 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -749,7 +749,7 @@ Set `python-indent' locally to the value guessed."
   '(("else" "if" "elif" "while" "for" "try" "except")
     ("elif" "if" "elif")
     ("except" "try" "except")
-    ("finally" "try"))
+    ("finally" "try" "except"))
   "Alist of keyword matches.
 The car of an element is a keyword introducing a statement which
 can close a block opened by a keyword in the cdr.")




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

* 23.0.60; python-mode indents try...except...finally incorrectly
  2008-03-23 21:33 23.0.60; python-mode indents try...except...finally incorrectly Phil Sung
@ 2008-04-23  3:34 ` Phil Sung
  0 siblings, 0 replies; 2+ messages in thread
From: Phil Sung @ 2008-04-23  3:34 UTC (permalink / raw)
  To: emacs-devel

I reported this bug (and provided a patch, below) about a month ago,
but received no reply. I hope it should be fairly easy to determine
whether this fix is the right thing or not.

Thanks in advance.

--Phil Sung


---------- Forwarded message ----------
From: Phil Sung <psung@mit.edu>
Date: Sun, Mar 23, 2008 at 5:33 PM
Subject: 23.0.60; python-mode indents try...except...finally incorrectly
To: emacs-pretest-bug@gnu.org


In GNU Emacs 23.0.60.1 (i486-pc-linux-gnu, GTK+ Version 2.12.8)
  of 2008-03-01 on palmer, modified by Debian
  (emacs-snapshot package, version 1:20080228-1ubuntu1)
 configured using `configure  '--build' 'i486-linux-gnu' '--host'
 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib'
 '--libexecdir=/usr/lib' '--localstatedir=/var'
 '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/23.0.60/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.0.60/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.0.60/leim'
 '--with-x=yes' '--with-x-toolkit=gtk' '--enable-font-backend'
 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu'
 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g
 -Wl,--as-needed' 'CPPFLAGS=''


 In python-mode, if you attempt to type the following...

 def f():
    try:
        foo
    except:
        bar
    finally:
        baz

 it gets incorrectly indented as shown below. Emacs tries to put
 "finally:" in the first column.

 def f():
    try:
        foo
    except:
        bar
 finally:
    baz

 "finally:" is allowed after an "except:" at the same level in Python
 2.5 and later. The patch below fixes python.el to allow that
 construct.

 --Phil


    progmodes/python.el (python-block-pairs): Allow "finally:" at the same
    level as, and following, an "except:". (try... except... finally blocks are
    allowed in Python 2.5 and later.)

 diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
 index e9f3daf..cca0bb0 100644
 --- a/lisp/progmodes/python.el
 +++ b/lisp/progmodes/python.el
 @@ -749,7 +749,7 @@ Set `python-indent' locally to the value guessed."
   '(("else" "if" "elif" "while" "for" "try" "except")
     ("elif" "if" "elif")
     ("except" "try" "except")
 -    ("finally" "try"))
 +    ("finally" "try" "except"))
   "Alist of keyword matches.
  The car of an element is a keyword introducing a statement which
  can close a block opened by a keyword in the cdr.")




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

end of thread, other threads:[~2008-04-23  3:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-23 21:33 23.0.60; python-mode indents try...except...finally incorrectly Phil Sung
2008-04-23  3:34 ` Phil Sung

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).