origami.el icon indicating copy to clipboard operation
origami.el copied to clipboard

Add ruby support

Open Trevoke opened this issue 9 years ago • 6 comments

I am not very familiar with elisp yet, and I wasn't sure, based on the existing examples, how I could make a parser work for Ruby (either using ruby-mode or enhanced-ruby-mode, though I use the latter one).

So I opened a question: http://emacs.stackexchange.com/questions/10860/origami-folding-package-create-parser-for-ruby

Trevoke avatar Apr 22 '15 17:04 Trevoke

I've answered your initial questions. Sorry the documentation is so lacking. I'll see if I can get something basic working. Ruby isn't the easiest of languages to parse. Maybe you can take what I write and improve on it?

gregsexton avatar Apr 25 '15 14:04 gregsexton

It's also worth mentioning the lisp-parser. This takes a different strategy and uses functions provided by the mode to navigate and build the structure. It's simpler and less error-prone than actually writing a parser. You may be able to take a similar strategy with ruby, depending on what enhanced-ruby-mode provides.

gregsexton avatar Apr 25 '15 14:04 gregsexton

I've written a parser that works based on indentation. This is now the default when there isn't a parser configured for a major-mode. Hopefully this will work to some extent while I take a look at writing a ruby-specific parser.

gregsexton avatar Apr 26 '15 14:04 gregsexton

Just curious, would something like SMIE help at all? I'm pretty sure it supports ruby-mode at least.

PythonNut avatar Jan 07 '16 05:01 PythonNut

What's SMIE?

Also, @gregsexton - finally came back to folding, the indentation-based parser is working well enough for my purposes for now so I'm gonna start using origami. Just need to figure out what bindings I want.

By the way - I really like the functions you've made available. Thanks for creating and maintaining this!

Trevoke avatar Feb 12 '16 04:02 Trevoke

I write ruby and use origami and as long as you keep your indentation decent (you should be doing this anyway) it works like a charm.

@gregsexton if you get braces, brackets, parens, and do..end working, you'll have covered probably 50% of ruby. The rest would be def..end, class..end, module..end, etc.

calebmeyer avatar Mar 08 '16 21:03 calebmeyer