[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Changing the default directory in which emacs save the files
From: |
Drew Adams |
Subject: |
RE: Changing the default directory in which emacs save the files |
Date: |
Wed, 16 Jul 2008 15:10:24 -0700 |
> I have GNU Emacs installed in my computer on both windows
> and linux operative systems, and I have been looking for
> a way that allows me to change the directory in which emacs
> saves the files that I am working with. That is, is there a
> way to "tell" emacs to save a file in a directory other
> than, for instance, C:\Programs\emacs\bin (the default) in
> windows, by using the command C-x C-s (save-buffer)?
At any time (in any buffer), there is a default directory, whose full name is
the value of variable `default-directory'. Many operations that use file names
interpret a file whose name you enter, by default, as belonging to the current
default directory.
So when you use `C-x C-s', for instance, if the current buffer is not already
associated with a file, then you are prompted for a file in the default
directory, which appears in the minibuffer: "File to save in: c:/toto/titi/".
You can change the default directory at any time, using command `cd' - e.g.,
`M-x cd RET', then enter the directory at the prompt "Change default directory:
".
When you start Emacs, `default-directory' is, by default, the directory where
the Emacs executable is located - e.g. c:\emacs\bin\. On Windows, you can set
the Emacs start-up directory to be something different, as follows:
1. Create a shortcut to the Emacs exectutable file runemacs.exe.
2. Right click the shortcut, and choose Properties.
3. Put the directory you want in the field "Start in:"
- e.g., c:\my\directory.
4. (Optional) If you want Emacs to open in Dired on that directory,
then also append it, within double quotes, to the "Target:" value
- e.g., c:\emacs\bin\runemacs.exe "c:\my\directory".
Then, to open Emacs, just double-click the shortcut.
Alternatively, and for Linux also, you can set environment variable `PWD' to the
directory you want Emacs to start in (that is, the default value of
`default-directory').