I installed emacs 23.3.1 in c:/emacs-23.3.
Following the hints in this page, I updated the site-start.el to set HOME environment variable.
(setenv "HOME" "c:/users/USER/emacs")
And I made c:/users/USER/.emacs (like I did in unix/mac) to write the code for using slime, but it doesn't seem to start slime correctly.
Is this a correct way of setting emacs in Windows 7? Where do I put the .emacs file?
You need to set HOME
in environment variables in Computer settings (if I remember correctly), or put init file to default directory (just start Emacs, and press C-x C-f ~/
to see what is actual directory).
And as I remember, on Windows, init file could be called _emacs
...
I am running emacs as a portable app and this works very well for me:
Create a batch file in the root of your emacs directory. For example, I created:
C:\Dropbox\PortableApps\emacs-24.3\run_emacs_portable.bat
Then, edit the file and put this text into it:
set HOME=.\
bin\runemacs.exe %*
Now, I just launch emacs via the run_emacs_portable.bat
file and my HOME folder always points to my emacs installation folder.
The %* allows you to pass arguments to the .bat file and have them forwarded to the runemacs.exe
Inside the home directory .emacs.d is created automatically, and you can make init.el as a startup file. Also refer to this question.
To setup Emacs home folder in your Windows User folder (C:\Users\User\.emacs.d) just add this code to your current init file and restart Emacs.
(when (eq system-type 'windows-nt)
(unless (getenv "Home")
(shell-command (format "setx \"%s\" \"%s\"" 'Home (getenv "UserProfile")))))
I liked Роман Захаров's answer which seems good for maintaining a cross-platform configuration, but it didn't work.
This is what finally worked for me.
(when (eq system-type 'windows-nt)
(setenv "Home" (getenv "UserProfile")))
you can start emacs, type M-x pwd
and that will show you where you are in the Windows file tree. You can put your .emacs
there.
On Windows, Emacs is started with some Properties defined, found when you right-click the executable on your windows system. There you can define the
execution-directory, e.g. "C:\Users\loggedin_user\" (in parantheses)
where emacs executes
and looks for the .xemacs (.emacs) directory, where it find its init.el.
And where you can define the startup instructions (like (setenv "HOME" "c:/Users/Username/") ) etc.
If you configure that, the next time, emacs starts from the directory, you defined, with the initialisation-file
If you want to use c:/users/USER/.emacs, you should have set your HOME variable to c:/users/USER, not c:/users/USER/emacs.