Direct answer to your question:
(setq-default default-directory "~/Desktop/mag")
Reading the documentation for the variable ( Ch v default-directory RET ), you will see:
Automatically becomes buffer-local when installed in any way. This variable is safe as a local variable file if its value satisfies the stringp predicate.
Thus, opening the file automatically sets default-directory to the file path ...
So, if you always want find-file run in this directory, you can use this:
(global-set-key (kbd "Cx Cf") 'my-find-file) (defun my-find-file () "force a starting path" (interactive) (let ((default-directory "~/scratch/")) (call-interactively 'find-file)))
This question may be a duplicate. Prevent automatic changes to the default directory . Although itβs hard to say.
Trey jackson
source share