[Solved] Better language recognition please


#1

Hi!

I’m coming from jEdit and I am so used to how jEdit recognizes a files content, that I was quite astonished when atom considered “de.lang” to be a plain text file instead of a php file.

After all: The file starts with “<?php”…

Did I miss something or is atom really relying on extensions like the old DOS system?

Could atom utilize the unix-“file” command or at least something lige jEdit’s “first line glob” ("<?php*" for php)?


#2

Atom can recognize languages based on the first line of a file. Take a look at language-perl. You can compare that to the language-php grammar to see that language-php doesn’t implement that feature.

If you want to request that language-php match on a first line that contains <?php, you should open an issue at the GitHub repo explaining your use case.


#3

Thanks a lot. Will check and open an issue.


#4

Thanks to your help, @DamnedScholar, I figured out how to add the feature to my installation of atom.

So I forked language-php, implemented it and submitted a pull-request.


#5

So it seeems there is an issue with (my installation of) atom.

When I open a file with below content it is not recognized as a php file:

    <?php
	$t = array(
		'potcheck_name' => 'Port Check',
		'your_ip_address' => 'Deine IP Adresse',
		'common_ports' => 'Die häufigsten Ports',
		'port_is_open' => 'Port <strong>%d</strong> ist offen',
		'port_is_closed' => 'Port <strong>%d</strong> ist geschlossen',
	);

See: http://www.bilder-upload.eu/upload/f298c5-1516862218.png

I installed atom just this week (Tuesday I think) so it should be fairly new.

The snapshot was taken when I have started atom with --safe

$ atom --version
Atom    : 1.23.3
Electron: 1.6.15
Chrome  : 56.0.2924.87
Node    : 7.4.0

apm list:

[spoiler] $ apm list
Built-in Atom Packages (92)
├── atom-dark-syntax@0.28.0
├── atom-dark-ui@0.53.0
├── atom-light-syntax@0.29.0
├── atom-light-ui@0.46.0
├── base16-tomorrow-dark-theme@1.5.0
├── base16-tomorrow-light-theme@1.5.0
├── one-dark-ui@1.10.8
├── one-light-ui@1.10.8
├── one-dark-syntax@1.8.0
├── one-light-syntax@1.8.0
├── solarized-dark-syntax@1.1.2
├── solarized-light-syntax@1.1.2
├── about@1.7.8
├── archive-view@0.64.1
├── autocomplete-atom-api@0.10.5
├── autocomplete-css@0.17.4
├── autocomplete-html@0.8.3
├── autocomplete-plus@2.40.0
├── autocomplete-snippets@1.11.2
├── autoflow@0.29.0
├── autosave@0.24.6
├── background-tips@0.27.1
├── bookmarks@0.44.4
├── bracket-matcher@0.88.0
├── command-palette@0.42.0
├── dalek@0.2.1
├── deprecation-cop@0.56.9
├── dev-live-reload@0.47.1
├── encoding-selector@0.23.7
├── exception-reporting@0.42.0
├── find-and-replace@0.215.0
├── fuzzy-finder@1.7.3
├── github@0.8.3
├── git-diff@1.3.6
├── go-to-line@0.32.1
├── grammar-selector@0.49.8
├── image-view@0.62.4
├── incompatible-packages@0.27.3
├── keybinding-resolver@0.38.1
├── line-ending-selector@0.7.4
├── link@0.31.3
├── markdown-preview@0.159.18
├── metrics@1.2.6
├── notifications@0.69.2
├── open-on-github@1.3.1
├── package-generator@1.1.1
├── settings-view@0.253.1-0
├── snippets@1.1.9
├── spell-check@0.72.5
├── status-bar@1.8.14
├── styleguide@0.49.8
├── symbols-view@0.118.1
├── tabs@0.109.1
├── timecop@0.36.0
├── tree-view@0.221.3 (disabled)
├── update-package-dependencies@0.12.0
├── welcome@0.36.6
├── whitespace@0.37.5
├── wrap-guide@0.40.2
├── language-c@0.58.1
├── language-clojure@0.22.4
├── language-coffee-script@0.49.3
├── language-csharp@0.14.3
├── language-css@0.42.7
├── language-gfm@0.90.2
├── language-git@0.19.1
├── language-go@0.44.3
├── language-html@0.48.5
├── language-hyperlink@0.16.3
├── language-java@0.27.6
├── language-javascript@0.127.6
├── language-json@0.19.1
├── language-less@0.33.0
├── language-make@0.22.3
├── language-mustache@0.14.4
├── language-objective-c@0.15.1
├── language-perl@0.38.1
├── language-php@0.42.2
├── language-property-list@0.9.1
├── language-python@0.45.5
├── language-ruby@0.71.4
├── language-ruby-on-rails@0.25.2
├── language-sass@0.61.1
├── language-shellscript@0.25.4
├── language-source@0.9.0
├── language-sql@0.25.8
├── language-text@0.7.3
├── language-todo@0.29.3
├── language-toml@0.18.1
├── language-typescript@0.2.2
├── language-xml@0.35.2
└── language-yaml@0.31.1

	Community Packages (5) /Users/shk/.atom/packages
	├── go-plus@5.7.2
	├── markdown-writer@2.7.3
	├── nuclide@0.278.0
	├── project-manager@3.3.5
	└── select-rectangle@1.0.2[/spoiler]

#6

Fixed in 1.24.0-beta3