I'm looking for a way not to move directories when I open files in Emacs. I've been using vim for a long time, and I've been trying Emacs (Spacemacs) recently, but I'm having trouble with this behavior that vim doesn't see.If you want to search for files under a project such as Thank you for your cooperation.
For example, if you open a subdirectory /path/to/myproject/src/foo.py
while working in the directory /path/to/myproject
, the current directory moves to /path/to/myproject/src
, but you want to stay in /path/to/myproject
.helm-grep-do-git-grep
, you have to go back to the original project directory.
How about using the .dir-locals.el
file?
/path/to/myproject/.dir-locals.el
((nil.((default-directory."/path/to/myproject"))))
I tried this environment (Emacs 25.1) and found that /path/to/myproject
all the following files work recursively.
Since command-line-default-directory
contains the startup default-directory
, how about reconfiguring default-directory
with that value in each hook?
(default my/restore-default-directory()
(setq default-directory command-line-default-directory))
(dolist(hook'(find-file-hook redirect-mode-hook redirect-after-readin-hook))
(add-hook hook#'my/restore-default-directory))
I don't know in any case, but when I just opened the file and opened the dead, the above alone worked. If there is a shortage, I think I can add a hook each time.
© 2024 OneMinuteCode. All rights reserved.