I have written about about using emacs in cygwin and how to launch emacs from cygwin, but I had some problems with the batch file approach in that emacs’ path differ from bash’s. Then ack fails to work from within emacs which makes me sad.
After googling around a bit, I saw a few suggestion that trie to fix the path in emacs, but I think a better approach is to launch emacs from within bash so it inherits the bash environment.
Here is my attempt using vbscript:
Dim WinScriptHost
Set WinScriptHost = CreateObject("WScript.Shell")
strCmd = "C:\cygwin\bin\bash --login -c '/usr/local/bin/emacsclient -c -a /usr/local/bin/emacs.exe"
If WScript.Arguments.Count = 1 Then
'strCmd = strCmd & " " &"""" & WScript.Arguments(0) & """'"
wScript.Echo strCmd
else
strCmd = strCmd & "'" 'close single quote
End If
WinScriptHost.Run strCmd,0
Set WinScriptHost = Nothing
Save that script somewhere and then make a Windows Shortcut to it but incle the wscript.exe in the target:
My business’s accounting program, which I’ll call Canopus, has issues. One of which is that it assumes wordpad.exe will be in c:windows. As far as I know, Microsoft moved wordpad.exe’s default location away from c:windows about 20 years ago. Canopus live in hope that it will be there so installing Canopus always requires one to copy wordpad.exe to c:windows
The other problem with Canopus is that it does not fork when launching wordpad.exe, so you can’t continue using it until you close wordpad. This is stupid as most likely you need the information in wordpad to do further work in Canopus.
So a long time ago I came up with a solution. With the help of a friend (well, he wrote it for me in Delphi) I developed a small program called wordpad.exe which reads a config.ini file to configure which editor to open. It makes a copy of the file in $1 and launches whatever editor you specify in the config.ini with $1 as its parameter.
This worked well and everyone was happy until I decided to use cygwin emacs instead of the native win32 compiled emacs.
The problem is that cygwin emacs expects paths to be of the unix flavour (/home/jason/whatever) rather than the dos flavour (c:usersjasonwhatever). And so the rabbit hole needed and extension.
I didn’t want to have to modify my wordpad.exe program as that would require me to get the lazarus (open source delphi replacement) toolchain working again, so I decided to write a shell script wrapper to do it.
launchemacs.sh:
Update: See my other post, launching emacs from cygwin
There are a few tricks to installing emacs in cygwin. Here’s what I do.
Installing cygwin
First, install cygwin.
Then, install the very nice tool apt-cyg which makes package management much easier in cygwin.
Then to save yourself lots of agony of trying to work out which cygwin packages you need to install to be able to compile emacs, here is the list of all the packages I have installed. It may be a little bit of overkill but it will save you time. I obtained the list like this:
gitclonegit://git.savannah.gnu.org/emacs.gitcdemacs./configure--with-w32# to ditch gtk and the concomitant gtk bug, thanks jlfmake
If make is successful, test the build by running emacs from the src directory:
src/emacs-Q
If that worked ok, you can:
makeinstall
Setting up your home
I like my cygwin home directory to be the same as windows %USERPROFILE% so I set the environment variable HOME=%USERPROFILE%.
Set up a shortcut to launch emacs
Make a shortcut to c:cygwinbinrun.exe on your desktop, and rename it to emacs.
Edit the shortcut to:
Target: C:cygwinbinrun.exe /usr/local/bin/emacsclient "-c" "-a" "/usr/local/bin/emacs.exe" #
Start in: %USERPROFILE%
The target part makes sure emacs launches a new window whether or not its already running. If it is already running and as a server, it will create a new frame connected to the server.
The start in part makes sure the new instance’s default-directory is your home directory which I think makes most sense for when you are launching from a shortcut.
Drop the shortcut onto your start menu. You should now be able to launch emacs from the start menu, or by pressing the Windows key and typing emacs.