Changing the default folder in Emacs

You can type the 'cd' emacs command. ( M-x cd ) to change the default folder as a one off.


I've put

(cd "c:/cvsroot/")

in my .emacs and it did the job


I think the line you need to add to your .emacs is is

(setq default-directory "C:/Documents and Settings/USER NAME/Desktop/" )

Emacs will start in your desktop that way, unless you have a file open. It will usually start in the same directory as the file in your current buffer otherwise.


You didn't say so, but it sounds like you're starting Emacs from a Windows shortcut.

The directory that you see with c-x c-f is the cwd, in Emacs terms, the default-directory (a variable).

When you start Emacs using an MS Windows shortcut, the default-directory is initially the folder (directory) specified in the "Start In" field of the shortcut properties. Right click the shortcut, select Properties, and type the path to your desktop in the Start In field.

If you're using Emacs from the command line, default-directory starts as the directory where you started Emacs (the cwd).

This approach is better than editing your .emacs file, since it will allow you to have more than one shortcuts with more than one starting directory, and it lets you have the normal command line behavior of Emacs if you need it.

CWD = current working directory = PWD = present working directory. It makes a lot more sense at the command line than in a GUI.