Monday, June 05, 2017

Launch Emacs for Windows with Batch File using Emacs Configuration from Cygwin

I maintain a shared Emacs configuration under Linux and Cygwin. In Windows, I wanted to easily launch Emacs from the Desktop with the following goals.

  • Create a shortcut in the taskbar that launches Emacs for Windows
  • Have Emacs for Windows obey the Emacs configuration from Cygwin
  • Avoid opening extra console windows

Some prerequisites,


I created a file called c:\cygwin64\emacs.bat with the following contents.
c:\cygwin64\bin\run bash.exe -c ~/dotfiles/bin/emacs.sh

The file ~/dotfiles/bin/emacs.sh is a shell script that sits in my Cygwin directory. It is a wrapper script that calls Emacs for Windows if I'm running Cygwin.

It is assumed that the default Emacs configuration sits in the ~/.emacs file under Cygwin.

Pin the c:\cygwin64\emacs.bat script to your task bar. See below if you do not know how to do this. Clicking on it will open Emacs for Windows without any intervening console windows.

References

No comments: