origami.el
origami.el copied to clipboard
Add ruby support
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
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?
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.
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.
Just curious, would something like SMIE help at all? I'm pretty sure it supports ruby-mode
at least.
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!
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.