1) Emacs most likely starts in console mode because no DISPLAY variable is set; set that environment variable, with a value which points to an X server able to accept clients, and you should find better results. You can also pass a display identifier via the --display
or -d
command line option to Emacs, which I'll do in the following example because I don't know how to set env vars in Windows batch files:
@echo off
chdir c:\LocalApp\cygwin\bin
start mintty.exe /usr/bin/emacs-X11.exe --display 127.0.0.1:0 %1
If necessary, which it probably isn't, replace the --display
value given here with something more suited for your X server configuration.
This will probably still display a console window, since you're using the Windows start command to spawn a mintty process which you then ask to launch Emacs. What you can do instead is use the Cygwin run command, which launches a given binary without a console window, and eliminate the redundant mintty process:
@echo off
chdir c:\LocalApp\cygwin\bin
run /usr/bin/emacs-X11.exe --display 127.0.0.1:0 %1
2) Finally, you need to find a way to pass the file path to Emacs in a form it can understand. Unfortunately, I'm pretty sure command interpolation is impossible in Windows batch language, so you can't do the equivalent of e.g. Bash $(cygpath -au %1)
. Perhaps your best option might be to have the Windows batch file run Cygwin Bash, passing the filename argument to a script which translates it and launches Emacs. For example, your batch file might be
@echo off
chdir C:\LocalApp\cygwin\bin
run sh /path/to/launch-emacs.sh %1
And then, in launch-emacs.sh, you might have something like:
#!/bin/sh
cd /cygdrive/c/LocalApp/cygwin/bin
/usr/bin/emacs-X11 --display 127.0.0.1:0 `cygpath -au $1`
which translates the path via cygpath
, then hands it off to Emacs, along with a display identifier as described above.
My only Windows box is at home, so I haven't had opportunity to test these exact scripts, but I do some pretty similar things with Emacs on that machine; assuming your X server is properly configured, the stuff in 1) will almost certainly work, and the rest should be OK modulo a superfluous console window about which you may or may not care. Let me know how it goes, and I'll see what further help I can offer.