diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index 4c1bf295..30b4fcdf 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -25,6 +25,9 @@ module Linguist if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) } result = disambiguate_cl(data, languages) end + if languages.all? { |l| ["M", "Matlab", "Mathematica", "Mercury", "Objective-C"].include?(l) } + result = disambiguate_m(data, languages) + end return result end end @@ -88,6 +91,15 @@ module Linguist matches end + def self.disambiguate_m(data, languages) + matches = [] + if (/@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data)) + matches << Language["Objective-C"] + end + # TODO add matchers for "M", "Matlab", "Mathematica", "Mercury" + matches + end + def self.active? !!ACTIVE end