Opening files in Emacs using drag and drop from Windows Explorer
Facts - Editor: emacs
Monday, 07 March 2011 20:35

This note is for Emacs 23.2.1, Windows XP and Cygwin 1.7.8-1. This is a comparison between the Emacs port that installs with Cygwin and the Emacs windows binaries provided by the Gnu Emacs team.

I installed Emacs from the Cygwin setup program. I hoped that I would be able to use interactive shells with Tramp from Emacs. I had read somewhere that only the Cygwin version provides nice remote interactive shells via tramp, and so far I had not been able to get this working with the plain Emacs Compiled for Windows.

It turned out that with both Emacs ports, both using the Emacs version 23.2.1, remote interactive shells using tramp are working just fine. In both Emacs ports I can just open the remote file system using Ctrl-x Ctrl-f /myuser@remotehost: and then do META-x shell. Of course I had set up password less authentication using putty and pageant, with plink.exe in the path.

Before I was able to try all this I had another problem. Before, with Gnu Emacs Compiled for Windows, I used to open files within Emacs by dragging them to the Emacs window. With the Cygwin Emacs port this is not possible.

Since I am using this feature a lot I can not use Emacs installed with the cygwin setup program.

In the Cygwin Emacs port dragging a file to the Emacs window just drags the file name to the Emacs Window. And this file name contains backslashes. I copied this file name, started a file find (Ctrl-x Ctrl-f) and then pressed TAB. With Gnu Emacs Compiled for Windows the backslashes are replaced with forward slashes when you press TAB there. Unfortunately the Cygwin port of Emacs does not do these replacements, but they are still necessary to open the file. So when opening files in the cygwin port of Emacs I would often end up manually replacing back slashes with forward slashes.

By the way: Emacs Compiled for Windows can be run inside cygwin as well, see below. I have tried it and I wonder the benefits are. It seems that the terminal settings need some improvements if you run a shell in emacs started from cygwin.

dos> C:\cygwin\bin\bash.exe --login -c "env HOME=\" `cygpath '%APPDATA%'`\" /cygdrive/c/emacs/emacs-23.2/bin/runemacs.exe"

A last note: dragging and dropping files to Cygwin Emacs for X11 (not XEmacs) does not have any effect, not even the file name is inserted in the destination buffer.