Skip to content

Instantly share code, notes, and snippets.

@kattrali
Created May 26, 2012 19:32
Show Gist options
  • Save kattrali/2795060 to your computer and use it in GitHub Desktop.
Save kattrali/2795060 to your computer and use it in GitHub Desktop.
redcar/plugins/edit_view_swt/lib/edit_view_swt.rb
#how grammar is set
def update_grammar(new_mirror)
title = new_mirror.title
contents = new_mirror.read
first_line = contents.to_s.split("\n").first
# @mate_text is a MateText object (see javamateview project)
grammar_name = @mate_text.set_grammar_by_first_line(first_line) if first_line
unless grammar_name
grammar_name = @mate_text.set_grammar_by_filename(title)
end
grammar_name ||= "Plain Text"
@model.set_grammar(grammar_name)
end
@loveybot
Copy link

Yay Ruby!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment