From: kj on


This is a question _for Emacs users_ (the rest of you, go away :) ).

How do you do Python code-folding in Emacs?

Thanks!

~K
From: Peter on
On Jul 16, 2:45 am, kj <no.em...(a)please.post> wrote:
> This is a question _for Emacs users_ (the rest of you, go away :)  ).
>
> How do you do Python code-folding in Emacs?
>
> Thanks!
>
> ~K

I don't - when I first looked at folding-mode (I assume this is what
you are referring too?) I couldn't be bothered putting the {{{ }}}
strings into the code comments - maybe somebody else has had better
success with it? But I just couldn't be bothered. Although if you use
a template generating system such as ELSE, you could probably work it
into the code templates and have them generated automatically. I must
admit that I started to modify my code templates once upon a time to
provide this but lost interest part way through and just put up with
splitting the window and "hiding" the intervening code that way.

Personally I think something like "folding" would be better worked
into the major mode and performed on a syntactic scan basis i.e. the
elisp must understand where the code blocks begin and end and make
folding decisions based on where point is located in relation to
surround code blocks.

Actually, it might be possible now that pymacs is available (well, I
say "now" - even though pymacs has been available for quite some time,
I looked at folding mode even earlier!) i.e. call a Python helper
program that would provide the syntactic scanning of the buffer
contents and return appropriate markers into the buffer for the
folding mode code to work with. One day when I have run out of other
(programming) things to do I might investigate this :-)

Anybody else now of any better ideas or whatever? Now that I think
about it, I wouldn't mind using folding mode if I could make it
"easier" to use myself! :-)

Peter



From: thebjorn on
On Jul 15, 10:34 pm, Peter <peter.milli...(a)gmail.com> wrote:
> On Jul 16, 2:45 am, kj <no.em...(a)please.post> wrote:
>
> > This is a question _for Emacs users_ (the rest of you, go away :)  ).
>
> > How do you do Python code-folding in Emacs?
>
> > Thanks!
>
> > ~K
>
[...]
> Anybody else now of any better ideas or whatever? Now that I think
> about it, I wouldn't mind using folding mode if I could make it
> "easier" to use myself! :-)
>
> Peter

I gave up too :-(

Komodo from ActiveState has Emacs bindings and folding, and is
generally a good editor and environment for when you want such a
thing. It also has an out-of-process debugger that has helped me solve
some nasty bugs.

Still, I keep going back to Emacs, it's just snappier(*) and
easier(**) to work with... Instead of folding I either split the
window or create a new Frame (Ctrl 5 2) for the content I wish to
refer to.

-- bjorn


(*) ha!
(**) ...I know...
From: ernest on
On 15 Jul, 18:45, kj <no.em...(a)please.post> wrote:
> This is a question _for Emacs users_ (the rest of you, go away :)  ).
>
> How do you do Python code-folding in Emacs?
>
> Thanks!
>
> ~K

I tried the outline-mode and it seemed to work. It can
collapse different blocks of code, such as functions,
classes, etc.

However, I never got used to it because of the bizarre
key bindings.

Bye.

Ernest
From: Andreas Waldenburger on
On Fri, 16 Jul 2010 06:29:46 -0700 (PDT) ernest <nfdisco(a)gmail.com>
wrote:

> On 15 Jul, 18:45, kj <no.em...(a)please.post> wrote:
> > This is a question _for Emacs users_ (the rest of you, go away :)
> >  ).
> >
> > How do you do Python code-folding in Emacs?
> >
> > Thanks!
> >
> > ~K
>
> I tried the outline-mode and it seemed to work. It can
> collapse different blocks of code, such as functions,
> classes, etc.
>
> However, I never got used to it because of the bizarre
> key bindings.
>
Yeah, that's Emacs for ya ...

Like, BURRRN!


....

OK, I'll move along.
/W

--
INVALID? DE!