eRuby revisited

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

eRuby revisited

Tim Pope-2
After much thought, I've finally implemented the changes necessary to
allow eRuby to be mixed with arbitrary filetypes.  The syntax file,
indent plugin, and ftplugin all integrate their own settings with
settings from the ruby filetype and other filetype.  The system works
surprisingly well, so I have decided to hold off on a separate "rhtml"
filetype.  The ftdetect file has also been updated to recognize a .erb
extension.

The other filetype (hereafter referred to as the subtype) is detected
based on the current filename.  The algorithm used is to look at the
extension of the file, after stripping off an optional ".erb".  For
"foo.html.erb", the subtype would be html.  A few extensions are
mapped to other filetypes (rhtml to html for instance), but by and
large this extension is used as is.  If no extension is present after
removing ".erb", the default is html.

It would of course be nice to hook the remaining filename into the
much smarter filetype detection system provided by Vim but this
doesn't appear feasible.  For more unusual contructs like
"foo.pl.erb", the nonexistant "pl" filetype will be used.  This can be
overridden by the user if so desired:

  autocmd BufNewFile,BufRead *.pl.erb let b:eruby_subtype='perl'|set ft=eruby

Unfortunately, the resetting of the filetype is necessary unless this
autocmd is defined before filetype detection is enabled.

One final note about the filetype determination.  The detection
algorithm is duplicated in both the syntax file and ftplugin.  This
means two places to update, but the ftplugin needs it because it runs
first, and the syntax file needs it because of the (typically
uninformed) users who have enabled syntax highlighting but not
filetype plugins.  I didn't bother duplicating it in the indent plugin
because it runs fast, and I figure most users enable at least one of
the two others.

Other than documentation, and perhaps a way to override the global
default subtype, I consider the transition to the new system largely
complete.  Please let me know of any issues.

Doug, my understanding is you don't do a lot with eRuby anyways, so I
have listed myself as the maintainer of the other two eRuby files.
Feel free to claim them back if you feel I'm encroaching on your turf.

Cheers,
Tim
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: eRuby revisited

Doug Kearns
On 4/21/07, Tim Pope <[hidden email]> wrote:
> After much thought, I've finally implemented the changes necessary to
> allow eRuby to be mixed with arbitrary filetypes.  The syntax file,
> indent plugin, and ftplugin all integrate their own settings with
> settings from the ruby filetype and other filetype.  The system works
> surprisingly well, so I have decided to hold off on a separate "rhtml"
> filetype.

A rare victory for purity over practicality? ;-)

<snip>

> Doug, my understanding is you don't do a lot with eRuby anyways, so I
> have listed myself as the maintainer of the other two eRuby files.
> Feel free to claim them back if you feel I'm encroaching on your turf.

All yours mate! Thanks.

Regards,
Doug
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel