I know this has been posted many times, but the solutions are not working for me. I\'ve tried the following solutions from this post (Changing the default folder in Emacs):<
I've been suffering similar weirdness with Emacs 24.3.1 on Windows 10. The solution is even weirder : customize Emacs to inhibit the startup screen. This can be done through the startup customization buttons, so you end up with the following in your .emacs :
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(inhibit-startup-screen t))
With the startup screen in place (eg. change t to nil above) the Windows shortcut "Start in" field (set to "E:\Users\Rob\") dominates and Ctrl-x Ctrl-f yields E:\Users\Rob/ (note the weird slash directions).
With the startup screen inhibited (t above) the .emacs
(setq default-directory "E:/Users/Rob/me/")
dominates and Ctrl-x Ctrl-f yields E:/Users/Rob/me/ (all forward slashes).
Set your default-directory
last in your init file, if you expect that setting to be useful after the init file is loaded.
If you also need it set earlier in the init file (e.g., so that some of your init-file code gets the right value) , then set it earlier too. When you do stuff in your init file, that stuff can change the variable value.
You can also use (setq-default default-directory "C:/Documents and Settings/USER NAME/Desktop/")
(or whatever the directory name is), if you want that to be the default for every buffer.
I just tested and it behaved fine with regards to Default-Directory. My settings are as follows:
emacs.exe in c:\bin\emacs\bin
%PATH%
includes c:\bin\emacs\bin\
%HOME%
set to %USERPROFILE
(C:\Users\)
Direct from Run-box
Win+r
emacs -q
RET
(message "%s" default-directory)
=> "C:\Users\jonpe/"
From cmd.exe after changing directory
Win+r
cmd
RET
cd c:\users\public
RET
emacs -q
RET
(message "%s" default-directory)
=> "C:\Users\Public/"
Do you have emacs added to your %PATH%
variable?
If I try to launch emacs by browsing to it's location then launching the default directory is set to the executable location.
The problem for me was the Initial Start Up Screen of emacs.
It can be deactivated by:
;; no startup msg
(setq inhibit-startup-message t)
It seems that the default welcome screen of emacs (with the tutorial links) forces you to start in your $HOME
path.
After that you can either cd
or setq default-directory
like so:
(setq default-directory "~/")
or
(cd "~/")
From what you write, it sounds like you are running windows. Have you verified that emacs is actually finding and loading .emacs from the directory C:\Users\Lucas? If it is, that means Windows understands your home directory is C:\Users\Lucas. You can check that by looking at the environment variable HOME. In emacs, try:
(getenv "HOME")
In your .emacs file, you could then put:
(setq default-directory "~/")
I think you just need to use the right backslash (and escape them). This worked in my .emacs:
(setq default-directory "C:\windows")