zzamboni.org

Making Cygwin, Windows and Emacs Understand the Same Symlinks

Today I ran into the problem that symlinks created under cygwin using “ln -s” are not understood by Windows, and of course Windows shortcuts are seen by cygwin as regular files. Happily, this is a (semi-)solved problem. For reference, this is what needs to be done:

  1. Add ”winsymlinks” to your CYGWIN environment variable. For example, in my .bashrc I have the following:

    export CYGWIN=”nodosfilewarning winsymlinks”

    This makes cygwin create symlinks differently, in a form that is understood both by it and by Windows.
    This is the main step, and the only one if you just need access from the shell and from the Windows explorer. However, emacs still sees those symlinks as regular .lnk files. To fix this, follow the next step.

  2. Install the w32-symlinks.el package, and add the following to your .emacs file:

    (require ‘w32-symlinks)

  3. Run M-x customize-option and enter w32-symlinks-handle-shortcuts as the variable to customize. Turn it on, save it for future sessions, and you are all set. The new symlinks should be properly understood by the cygwin shell, Windows explorer, and emacs. Of course, you will have to re-create any symlinks or shortcuts that you created prior to setting the winsymlinks option, for them to be created in the new format.

    Update: so this doesn’t quite work on my system. I am using Emacs 23.1, and apparently w32-symlinks does not work properly in this version. If you have an older version (I hear Emacs 21 works well), then this might work for you.