Open PHP files with non-standard extensions in Espresso

I’ve been playing with the new Espresso text editor from Mac Rabbit a bit for the last few days, not sure that I’ll be switching from Textmate yet, but for a 1.0 release Espresso is looking very promising. And visually a hell of a lot more appealing than Textmate.

I edit a lot of Drupal php files which have non standard extensions like .module, and .test after about 5 minutes of working with these files in Espresso and having to manually change the language for each file every time I opened it I was about to tear my hair out. I couldn’t find a way to change the default set of extensions that Espresso opens as PHP files via the UI, or googling. So after a bit of poking around here is the solution I came up with.

Navigate to your /Applications directory and locate Espresso. Right click on the Espresso package and select “Show Package Contents” from the menu. This should open a new Finder window. In the new window go to Contents/Shared Resources/Sugars and double click the PHP.sugar file to open it up in Espresso.

Edit the Languages.xml file in the PHP.sugar bundle. Near the top of the file, in the section called detectors you should see something like this.

<extension casesensitive="false">php</extension>

Below the existing extension tags add in a new line for each of the extensions you would like to have opened as PHP files. Mine looks like this.

<extension casesensitive="false">php</extension> <extension casesensitive="false">phps</extension> <extension casesensitive="false">inc</extension> <extension casesensitive="false">html</extension> <extension casesensitive="false">phtml</extension> <extension casesensitive="false">module</extension> <extension casesensitive="false">test</extension>

Save your changes, and restart Espresso. Try opening a file and make sure it worked.

The downside, anytime you update Espresso these changes will be lost. If anyone knows a way that this can be done via the UI I would love to know.

Now if I could only figure out how to jump to line number n within Espresso I would be a happy(er) camper.