0

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.

0

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 '18 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 '18 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 '18 at 21:23
  • Hmm, are you sure you don't have two installations of emacs? – npostavs Jan 27 '18 at 21:39
  • Yes, absolutely. – Adam Jan 31 '18 at 14:25
0

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))
      (progn
        (setq load-path
              (append
               (loop for dir in (directory-files my-lisp-dir)
                     unless (string-match "^\\." dir)
                     collecting (expand-file-name dir))
               load-path)))))

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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