Emacs, Ruby, and Fode Colding :)

Long time no see, oh Ruby T. list. I have a question to any of you
out
there who are emacs users. (And yes, this is after searching the web
for 2+
days AND archives of mailing lists/newsgroups)

Does anyone out there who uses emacs have a good solution to code
folding?
vim kicks the proverbial bum when it comes to code folding. I’d really
like
that functionality in Ruby.

I’ve tried vim and emacs, and emacs is coming to me with more ease. I’m
using ruby-mode. I figured this was probably the best place to ask the
question since if you’re here, you’re probably using Ruby :wink:

Thanks!

Samantha

http://www.babygeek.org/

“Beware when the great God lets loose a thinker on this planet. Then all
things are at risk.”
–Ralph Waldo Emerson

Quoth Samantha:

question since if you’re here, you’re probably using Ruby :wink:

Thanks!

Samantha

http://www.babygeek.org/

“Beware when the great God lets loose a thinker on this planet. Then all
things are at risk.”
–Ralph Waldo Emerson

While we’re on the subject, how DO you use code folding in vim?

Gracias,

Not sure if you were asking how Samantha uses it or how to use it in
general.

:help folding in vim

should give you something to chew on for a while.

Check out this site:
http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/

The main text deals w/ a quick and dirty way that uses a couple of
commands to hide all the function bodies (class ones too i would
assume), leaving you w/ just the signature line and the end line. Also,
there are some links in the first paragraph to some emacswiki pages.
I’m not sure which particular folding mode you like from vim, but the
folding-mode link takes you to a minor mode page that describes how to
setup emacs to use something very much akin to vim’s marker folding
mode.

Anyways, check 'em out, it looks like there are a number of options.

Looks like the questions about vim code folding were answered - as for
emacs, I was able to find something the other day to do what I needed to
do. I like indentation based code folding as opposed to mark based.

So, I made my searches a little more specific in regards to indentation
based folding. I found something geared for python that someone put
into
their .emacs file and just placed it in mine, but adapted for Ruby.
(There
wasn’t much adaptation to do)

Thanks for all the answers, though!


Samantha

http://www.babygeek.org/

“Beware when the great God lets loose a thinker on this planet. Then all
things are at risk.”
–Ralph Waldo Emerson

Konrad M. wrote:

While we’re on the subject, how DO you use code folding in vim?

For Ruby I’m using:

http://eigenclass.org/hiki/simplefold

Excellent folding with easy setup (= do not need to understand almost at
all to ‘:h folding’)
In combination with http://vim-taglist.sourceforge.net/ which is somehow
related.

Regards,
m.

On 9/22/07, Samantha [email protected] wrote:

Looks like the questions about vim code folding were answered - as for
emacs, I was able to find something the other day to do what I needed to
do. I like indentation based code folding as opposed to mark based.

So, I made my searches a little more specific in regards to indentation
based folding. I found something geared for python that someone put into
their .emacs file and just placed it in mine, but adapted for Ruby. (There
wasn’t much adaptation to do)

Samantha,

I was just going to post about this very technique, so just for
completeness
and to benefit future readers. Here is a very simple way to get some
folding
(or outlining) in emacs for ruby

Adding this to my .emacs

;;; enables outlining for ruby
;;; You may also want to bind hide-body, hide-subtree, show-substree,
;;; show-all, show-children, … to some keys easy folding and unfolding
(add-hook 'ruby-mode-hook
'(lambda ()
(outline-minor-mode)
(setq outline-regexp " *\(def \|class\|module\)")))

This adds the outline-minor-mode to your ruby buffers. You will also
most
likely want to bind some hide and show functions to appropriate keys if
you
don’t like the defaults (or they conflict with others).

More details are here
http://www.emacswiki.org/cgi-bin/wiki/OutlineMode
http://www.emacswiki.org/cgi-bin/wiki/EasyCodeOutline

hide-body, hide-subtree, show-subtree, show-all, show-children and the
other
hide* and show* methods are what you will use to collapse or expand, so
you
may want to bind them to convenient keys if the default bindings don’t
work
for you.

Blessings,

Jeff

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs