0

I have multiple installations of emacs on my Windows 7 computer, each configured slightly differently. Let's say installation1 and installation2, where installation1 is the main emacs, and installation2 is subsidiary.

I would like to maintain two sets of .emacs files and .emacs.d. directories, such that installation1 looks for it in the default HOME or %appdata% directory (C-x C-f ~/.emacs RET), but that installation2 cannot find the .emacs file in these directories at all. That is, I would like installation2 to not look in the HOME or %appdata% locations for the .emacs.d directory or .emacs file. Ideally, this would be implemented by redefining the ~ expansion for installation2.

I guess I could have a (add-to-list 'load-path "C:/installation2-location/.emacs.d/lisp/") and save it to a .emacs file in the same directory as the installation2 emacs executable, but I am not sure that this is a robust solution.

Suggestions welcome.

tchakravarty
  • 10,736
  • 12
  • 72
  • 116
  • Is this complete separation really necessary? You know you can set the site and user init files from the command line? And you could set up the `.emacs` file to select one out of several base configurations depending on e.g. an environment variable (not too useful on Windoze I guess), a command-line argument, etc. – tripleee Nov 24 '12 at 08:05
  • @tripleee Could you break it down a little more -- I don't think I fully understand what you are suggesting. You are saying that I start emacs from the command line with something like `> runemacs --init-file=.emacs-installation1 --init-directory=C:/installation1-location/.emacs.d` (I am not sure those switches exist -- `emacs --help` does not show such options, but something like that probably exists)? I am not at all sure what your suggestion about environments means, but as you mention, that is probably because I am on Windows (best OS ever, btw). ;) – tchakravarty Nov 24 '12 at 08:30
  • Windows has environment variables like `%home%` but they don't behave like on Unix-like systems and hence you're perhaps better off with some native mechanism -- the registry comes to mind but it's global AFAICT and I don't know how hard or easy it is to access from Elisp. – tripleee Nov 24 '12 at 08:49
  • If you have a separate user then `emacs -u him` runs his Emacs profile instead of yours. You might prefer `emacs -q -l a:\files\config.el` or even `emacs -Q` as the "clean slate". See further http://linux.die.net/man/1/emacs – tripleee Nov 24 '12 at 09:18
  • I'm not sure exactly why you want two different configs and why you have two different installations and why you specifically want to use one config with one installation and the other config with the other installation. Could you give some details? Depending on precisely what you want, the solution might be clean and simple, or it might be rather complex and unreliable. – Stefan Nov 24 '12 at 15:04
  • @stefan Although it is not the main reason, suppose that I want to maintain a subsidiary installation to try out new stuff before I move it to my main installation. Or suppose that I want to experiment with both `python.el` and `python-mode.el` simultaneously. I am learning emacs so it is great to have the ability to play around without the fear of breaking stuff. – tchakravarty Nov 24 '12 at 17:39
  • @fgnu: you don't need a separate installation for that. Just put the files you're playing with in some directory of yours and add that dir at the beginning of your `load-path`. – Stefan Nov 25 '12 at 15:44

1 Answers1

1

Well you can use the system-type variable. From the Emacs help

system-type is a variable defined in `C source code'. Its value is darwin

Documentation: The value is a symbol indicating the type of operating system you are using. Special values: gnu' compiled for a GNU Hurd system.gnu/linux' compiled for a GNU/Linux system.
gnu/kfreebsd' compiled for a GNU system with a FreeBSD kernel. darwin' compiled for Darwin (GNU-Darwin, Mac OS X, ...).
ms-dos' compiled as an MS-DOS application.windows-nt'
compiled as a native W32 application. `cygwin' compiled using the Cygwin library. Anything else (in Emacs 24.1, the possibilities are: aix, berkeley-unix, hpux, irix, usg-unix-v) indicates some sort of Unix system.

Or use system-name to determine discriminate between machines of the same of.

Finally you can make a function to load what you want in installation-1 and another to load what you want in installation-2. But I can't see any valid reason as to why you would want to maintain different emacs.d in the same machine.

PuercoPop
  • 6,707
  • 4
  • 30
  • 40