<p dir="auto">There's a pretty obscure coding language out there called Sourcepawn, and I've recently released a <a href="https://atom.io/packages/language-sourcepawn" rel="nofollow">language package</a> for it.  The only problem now is that both Sourcepawn and PHP use the <code class="notranslate">.inc</code> file type.  I didn't include a <code class="notranslate">firstLineMatch</code> for the Sourcepawn package because there's really no telling what someone will decide to put for the first line (they could immediately start with the code, or maybe a comment, or maybe a preprocessor...).  Since neither PHP nor Sourcepawn can definitively claim the file as its own, it seems like PHP then takes precedence simply because it comes before Sourcepawn in the alphabet (I haven't tested this, but it seems pretty plausible).</p>
<p dir="auto">So, is there any way that the auto-detection of grammar could be improved by, say, looking at the regex in each language and seeing which one lines up better?</p>
<p dir="auto">I will explain this issue referring to a third–party package, although the problem <em>might</em> be realted to atom's grammar auto detection feature:</p>
<p dir="auto">Cucumber package for Gherkin syntax and step definitons (<a href="https://github.com/edda/cucumber-atom/">https://github.com/edda/cucumber-atom/</a>) defines two grammars:</p>
<ol dir="auto">
<li>Gherkin (file types: <code class="notranslate">feature</code>)</li>
<li>Cucumber Steps (file type: <code class="notranslate">steps.rb</code>)</li>
</ol>
<p dir="auto">Whilst the first grammar is set correctly on files with the extension <code class="notranslate">*.feature</code>, the second grammar is not detected and instead will set grammar to "Ruby" for files <code class="notranslate">*_steps.rb</code>.</p>
<p dir="auto">Any ideas please?</p>
<h2 dir="auto"></h2>
<p dir="auto">/cc: <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/izuzak/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/izuzak">@izuzak</a></p>