I have my config files in ~/config/emacs
which ~/.emacs
is symlinked to.
I'm trying to figure out how to make the default "emacs root directory" $HOME
in all contexts (unless overridden by a buffer-local variable), whether launching an ansi terminal, launching dired, or anything like that.
$ ls -al .emacs.d | perl -pe 's/^.*([.]emacs[.]d)/$1/'
.emacs.d -> ./config/emacs
My .emacs.d/init.el
file contains the following snippet in an attempt to force emacs open stuff like dired
and ansi-term
in my home directory.
(cd (getenv "HOME"))
How do I change the effective root directory for ansi-term
and everything else?
Here's a complete example that should reproduce the surprising behavior I'm talking about on OS X and Linux.
I have a directory ~/tmp/emacs
$ echo '(cd (getenv "HOME"))' > ~/tmp/emacs/cd.el
$ cd /tmp
$ emacs -q -l ~/tmp/emacs/cd.el
And then from inside emacs
,
Launch the ansi terminal and accept the default shell
M-x ansi-term C-m C-m
print the current working directory from inside the terminal
$ pwd
/tmp
I expected working directory to be $HOME
.
.emacs.d/init.el
file doesn't contain symlinks. I was actually kind of surprised that emacs considered~/.emacs.d/..
to be its root/home directory rather than just~
.setenv
-- e.g.,(setenv "HOME" "/private/tmp")
. I don't know if that helps any, but I just tried it in aneshell
buffer and was able tocd
to the new HOME directory by typingcd ~
after usingsetenv
. You can probably do that while launching Emacs -- there are ways to passelisp
while launching Emacs from the terminal.