Q for Emacs users: code-folding (hideshow)

Peter peter.milliken at gmail.com
Thu Jul 15 16:34:22 EDT 2010


On Jul 16, 2:45 am, kj <no.em... at 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






More information about the Python-list mailing list