Allow emacs to open file from shell.

Also, move function to where it makes sense.