Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#2 Indentation cycling, in the style of emacs haskell-mode

closed
None
5
2004-10-20
2004-07-15
John Fouhy
No

Currently, <tab> indents to the deepest valid level.
This is not always desirable.

The haskell functional programming language also uses
indentation to mean stuff. The emacs haskell mode
deals with this by having the <tab> key cycle through
the various possible indentations.

I think this would be a really groovy feature :-)

example:

def foo(x, y):
if x > y:
print 'Zow!'
|

The cursor is now at the position indicated by |. What
I'd like is for <tab> to move the cursor back 4 chars,
to the next-innermost valid indentation. A second
<tab> would move the cursor back again, to the
outermost valid indentation. A third <tab> would start
the cycle again, moving the cursor to the innermost level.

This is an improvement which would definitely enhance
my python-programming experience.

Discussion

  • John Fouhy
    John Fouhy
    2004-07-15

    Logged In: YES
    user_id=1084032

    Hmm, sourceforge squashes whitespace.

    Try again with underscores...

    def foo(x, y):
    ____if x > y:
    ________print 'Zow!'
    ________|

     
  • Skip Montanaro
    Skip Montanaro
    2004-10-15

    Logged In: YES
    user_id=44345

    A colleague at work who is more-or-less switching from vim
    to Emacs asked
    me about this today. Given this (again, using underscores
    to represent
    spaces and | to represent the cursor):

    ____self.mama_mia(|

    C-J results in

    ____self.mama_mia(
    ________|

    OTOH, if you enter the first parameter before the newline,
    the cursor
    is lined up under it:

    ____self.mama_mia(first,
    __________________|

    James would like to be able to get to

    ____self.mama_mia(first,
    ________|

    I was thinking about adding a flag that would affect this
    particular
    behavior (indenting after entering the first parameter of a
    list-like
    construct) but think rotating indentation might be better.

     
  • Skip Montanaro
    Skip Montanaro
    2004-10-15

    Logged In: YES
    user_id=44345

    Please try the attached patch...

     
  • Skip Montanaro
    Skip Montanaro
    2004-10-15

     
    Attachments
  • Skip Montanaro
    Skip Montanaro
    2004-10-20

    • status: open --> closed
     
  • Skip Montanaro
    Skip Montanaro
    2004-10-20

    Logged In: YES
    user_id=44345

    Checked in as python-mode.el v 4.63

     
  • Skip Montanaro
    Skip Montanaro
    2004-10-20

    • assigned_to: nobody --> montanaro