{"action":"created","issue":{"url":"https://api.github.com/repos/github/linguist/issues/1528","labels_url":"https://api.github.com/repos/github/linguist/issues/1528/labels{/name}","comments_url":"https://api.github.com/repos/github/linguist/issues/1528/comments","events_url":"https://api.github.com/repos/github/linguist/issues/1528/events","html_url":"https://github.com/github/linguist/issues/1528","id":42766542,"number":1528,"title":"Many *.g and *.gd files are mis-recognized as GAP, how to handle it?","user":{"login":"fingolfin","id":241512,"avatar_url":"https://avatars.githubusercontent.com/u/241512?v=3","gravatar_id":"","url":"https://api.github.com/users/fingolfin","html_url":"https://github.com/fingolfin","followers_url":"https://api.github.com/users/fingolfin/followers","following_url":"https://api.github.com/users/fingolfin/following{/other_user}","gists_url":"https://api.github.com/users/fingolfin/gists{/gist_id}","starred_url":"https://api.github.com/users/fingolfin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fingolfin/subscriptions","organizations_url":"https://api.github.com/users/fingolfin/orgs","repos_url":"https://api.github.com/users/fingolfin/repos","events_url":"https://api.github.com/users/fingolfin/events{/privacy}","received_events_url":"https://api.github.com/users/fingolfin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/github/linguist/labels/Misidentified%20Language","name":"Misidentified Language","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2014-09-15T12:23:14Z","updated_at":"2015-03-04T18:31:12Z","closed_at":null,"body":"I just had a look at https://github.com/trending?l=gap and noticed that the top projects there are not using GAP at all, but rather are misdetected. They all seem to be using something called \"G-code\", see http://reprap.org/wiki/G-code -- format for RepRap 3D printers (it seems to essen\r\n\r\nSome concrete examples (randomly picked):\r\n* https://github.com/dmcc/bllip-parser/blob/master/first-stage/DATA/EN/ru.g\r\n* https://github.com/reprappro/RepRapFirmware/blob/master/SD-image-Ormerod-1/gcodes/duettest.g\r\n* https://github.com/reprappro/RepRapFirmware/blob/master/SD-image-Ormerod-1/gcodes/square.g\r\n* https://github.com/MakerGear/M2/blob/master/Sample%20Prints/Gcode/bracelet.g\r\n\r\nThe official extension for such files seem to be \".gco\", but clearly many people use \".g\"\r\n\r\nThis is a bit annoying. What can be done to fix this? One solution would be to add RepRap G-code to the list of \"languages\" detected by linguist. Note that this is not a general programming language, but rather a set of commands controlling the RepRap \"3D printer\". Still, it is some kind of machine code.\r\n\r\nShould one add a language entry for this, then? What would be the name of the \"language\", \"G-code\"? Or is there another way to deal with such misdetections?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/github/linguist/issues/comments/77216271","html_url":"https://github.com/github/linguist/issues/1528#issuecomment-77216271","issue_url":"https://api.github.com/repos/github/linguist/issues/1528","id":77216271,"user":{"login":"pchaigno","id":1764210,"avatar_url":"https://avatars.githubusercontent.com/u/1764210?v=3","gravatar_id":"","url":"https://api.github.com/users/pchaigno","html_url":"https://github.com/pchaigno","followers_url":"https://api.github.com/users/pchaigno/followers","following_url":"https://api.github.com/users/pchaigno/following{/other_user}","gists_url":"https://api.github.com/users/pchaigno/gists{/gist_id}","starred_url":"https://api.github.com/users/pchaigno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pchaigno/subscriptions","organizations_url":"https://api.github.com/users/pchaigno/orgs","repos_url":"https://api.github.com/users/pchaigno/repos","events_url":"https://api.github.com/users/pchaigno/events{/privacy}","received_events_url":"https://api.github.com/users/pchaigno/received_events","type":"User","site_admin":false},"created_at":"2015-03-04T18:31:12Z","updated_at":"2015-03-04T18:31:12Z","body":"> let me know if you need me to file a pull request for that\r\n\r\nThey can probably be removed in #1027.\r\n<br/>\r\n\r\n> I guess they are yet another attempt to workaround that fundamental issue I mentioned...\r\n\r\nNo, they would still be here even if we had a \"no a code\" option ;)\r\n<br/>\r\n\r\n> So... actually... how does one add a disambiguate heuristics rule for two language which generates the results \"neither of these languages match\" ?\r\n\r\nJust return nothing in the case where none of the language match. For instance:\r\n```ruby\r\ndisambiguate \"Hack\", \"PHP\" do |data|\r\n  if data.include?(\"<?hh\")\r\n    Language[\"Hack\"]\r\n  elsif /<?[^h]/.match(data)\r\n    Language[\"PHP\"]\r\n  end\r\nend\r\n```"}}