Skip to content

Instantly share code, notes, and snippets.

@SeanJA
Created May 16, 2012 19:51
Show Gist options
  • Select an option

  • Save SeanJA/2713425 to your computer and use it in GitHub Desktop.

Select an option

Save SeanJA/2713425 to your computer and use it in GitHub Desktop.
php.sublime-build
{
"cmd": ["php", "-f", "$file"],
/* what is this for? */
"file_regex": ".* in (.*?) on line ([0-9]*)",
"selector": "source.php"
}
@SeanJA

SeanJA commented May 17, 2012

Copy link
Copy Markdown
Author

Seriously... what is the file_regex thing for?

@ravisorg

Copy link
Copy Markdown

Beginning of string
Followed by zero or more spaces (weird syntax on that, btw)
Followed by: File "
Followed by two or more characters (even weirder syntax)
Followed by: ", line
Followed by a number

...so, it's looking for a PHP error message / warning etc. in the output, and then matching the file name and line number, presumably so it can highlight it in the editor.

Slightly more readable would be:

^ *File \"(.{2,}?)\", line ([0-9]*)

@SeanJA

SeanJA commented May 27, 2012

Copy link
Copy Markdown
Author

Well... it doesn't have anything to do with php (I copied it from the python one) here is the one for ruby: "file_regex": "^(...*?):([0-9]*):?([0-9]*)", which is different apparently... If I knew what it was for, I would probably change it

I think you may be on to something with this "highlighting in the output" thing: https://gist.github.com/1481511

@SeanJA

SeanJA commented May 27, 2012

Copy link
Copy Markdown
Author

I changed it so it better matches the output from php... I guess?

@ravisorg

Copy link
Copy Markdown

Speaking of not understanding regex, I forgot the ?.. :P

Edited comment above to add ? and remove insult to former writer of the regex ;)

@ravisorg

Copy link
Copy Markdown

Right, yes, your version does look better.

@SeanJA

SeanJA commented May 27, 2012

Copy link
Copy Markdown
Author

It still doesn't seem to affect anything from what I can see

@SeanJA

SeanJA commented May 27, 2012

Copy link
Copy Markdown
Author

Doh... rtfm http://sublimetext.info/docs/en/reference/build_systems.html

It totally does something, just not when the file is only one line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment