I'm using emacs as a bog-standard program in Windows, and also from the command line in cygwin.

They both use the same installation of emacs.

I just grabbed yaml-mode.el off the net but I can't get it to load at start-up. Where should I put it?

Initially I thought I'd put it in the emacs installation directory emacs/site-lisp/ but then I noticed there's also an emacs/25.3/site-list/.

Neither of those works for emacs from the cygwin command line. It complains at startup due to the lisp in my .emacs.

I also put it in ~/.emacs.d but that didn't work either.

Ideally I would like to have it one place so that it works in Windows and cygwin, and is in a directory on my Microsoft One Drive (because that's the only place on my workstation which gets backed up).

I can make pointers to wherever I need to, which work for the .emacs file.


3 Answers 3


The way I managed it seems slightly clunky, but ain't it always like that:

(add-to-list 'load-path "/cygdrive/c/Users/adam/OneDrive/.emacs.d")
(add-to-list 'load-path "c:/Users/adam/OneDrive/.emacs.d")

So I entered it twice, once with Windows10 format file path, once with cygwin.

Thanks @Drew for the comment

  • You said "They both use the same installation of emacs", so shouldn't Emacs understand both kinds of path regardless of whether you start it from cmd.exe or cygwin bash (i.e., one of those entries should not be needed)?
    – npostavs
    Jan 27, 2018 at 0:22
  • 1
    By the way, it's not recommended to add ~/.emacs.d to load-path because some config files there could then shadow elisp files (e.g., ~/.emacs.d/bookmarks gets loaded instead of the real bookmarks.el). If your ..../OneDrive/.emacs.d isn't ~/.emacs.d/ then ignore this.
    – npostavs
    Jan 27, 2018 at 0:25
  • re cygwin vs windows 10 - would need to investigate further but emacs in cygwin doesn't load the file if I only put the windows format path. re ~/.emacs.d - I'll change that then. Thanks.
    – Adam
    Jan 27, 2018 at 21:23
  • Hmm, are you sure you don't have two installations of emacs?
    – npostavs
    Jan 27, 2018 at 21:39
  • Yes, absolutely.
    – Adam
    Jan 31, 2018 at 14:25

I suppose your Window and Cygwin Emacs shares the same setup under ~/.emacs.d; If not, you need setup environment variable HOME in Windows, make it point to the parent directory of .emacs.d.

Insert below code into beginning of ~/.emacs or ~/.emacs.d/init.el:

(eval-when-compile (require 'cl))
(if (fboundp 'normal-top-level-add-to-load-path)
    (let* ((my-lisp-dir "~/.emacs.d/site-lisp/")
           (default-directory my-lisp-dir))
        (setq load-path
               (loop for dir in (directory-files my-lisp-dir)
                     unless (string-match "^\\." dir)
                     collecting (expand-file-name dir))

Then any sub-directory under ~/.emacs.d/site-lisp/ is automatically recognized by Emacs.

In your case, you only need create the directory of ~/.emacs.d/site-lisp/yaml-mode and place yaml-mode.el under the directory ~/.emacs.d/site-lisp/yaml-mode.

Please note the above code is copied from Steve Purcell's setup (https://github.com/purcell/emacs.d)


Once upon a time I used to do this:

Launch NTEmacs via Cygwin

If you want to launch NTEmacs via Cygwin (in order that it inherits your Cygwin environment variables – particularly useful if your bash profile does things like managing a ssh-agent), then you can use a shortcut like the following to enable this, while maintaining consistency with the standard (for NTEmacs) HOME directory:

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

-- https://www.emacswiki.org/emacs/NTEmacsWithCygwin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.