As per the Emacs docs, every time you open a file, Emacs changes default-directory
to the directory containing that file.
Then, if the cursor is in that buffer and you (for example) start SLIME, it uses default-directory
as the current working directory for SLIME. If you try to open a new file, it opens the file with default-directory
as your starting point.
I want to be able to M-x cd
or otherwise cd
to a directory, and then never have Emacs change my current working directory to anything but that directory until I tell it otherwise. I want this to be global across all buffers, so that any time I'm doing something involving the current working directory, I know what it's set to regardless of where my cursor is at the moment. Is there a way to do this?
You could try using something like this:
(add-hook 'find-file-hook
(lambda ()
(setq default-directory command-line-default-directory)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With