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.

Adam
  • 241
  • 2
  • 7

3 Answers3

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

Adam
  • 241
  • 2
  • 7
  • 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 00: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 00: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
  • Famous last words! Well, I have only one installation of Windows emacs. And I thought that was what I was using in cygwin too - but I just realised that would be contradictory. If cygwin was launching the Windows emacs, then I wouldn't need the cygwin version of the path in my .emacs. So I double-checked, and yes I have installed emacs-nox via the cygwin package manager. – Adam Jan 31 '18 at 14:30
  • Consider adding these paths conditionally depending on the value of `system-type`. I haven't tried it, but Emacs might try to look for elisp files in these directories and throw errors when it can't open them, because they don't exist. –  Oct 24 '18 at 18:35
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)

chen bin
  • 4,781
  • 18
  • 36
0

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

phils
  • 48,657
  • 3
  • 76
  • 115