Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cd and setq default-directory in .spacemacs not working #16530

Closed
sid-kap opened this issue Aug 23, 2024 · 4 comments
Closed

cd and setq default-directory in .spacemacs not working #16530

sid-kap opened this issue Aug 23, 2024 · 4 comments

Comments

@sid-kap
Copy link
Contributor

sid-kap commented Aug 23, 2024

I tried adding

(cd "/Users/sidharthkapur/workspace")
(setq default-directory "/Users/sidharthkapur/workspace")

to dotspacemacs/user-config and to dotspacemacs/user-init but neither seems to work. I want ivy to default to the workspace folder when I do find-file (SPC f f).

It does work if I do SPC SPC and choose cd and type in /Users/sidharthkapur/workspace

@bcc32
Copy link
Contributor

bcc32 commented Aug 23, 2024

default-directory is a buffer-local variable in Emacs, and SPC f f will always start from the default-directory of the current buffer (e.g., the containing directory of the file you're looking at).

Are you trying to make SPC f f always start from a particular directory, no matter what file you're in?

Maybe what you're looking for is something like SPC p f instead, which finds files based on the root of the current project (such as a git repo)?

@sid-kap
Copy link
Contributor Author

sid-kap commented Aug 23, 2024

Thanks so much for explaining! My bad for not understanding this properly.

I wanted SPC f f to always open to ~/workspace just for the spacemacs home buffer, so before I've opened a file/entered a project.
Doesn't seem like a bug in spacemacs, so feel free to close

@bcc32
Copy link
Contributor

bcc32 commented Aug 24, 2024

You could probably do something like:

(add-hook 'spacemacs-buffer-mode-hook (lambda () (setq default-directory "~/workspace/")))

But indeed, I think this is up to your personal preference and not a bug in Spacemacs. (I don't have maintainer access to this repo so I can't close the issue for you, sorry)

@sid-kap
Copy link
Contributor Author

sid-kap commented Aug 24, 2024

This is really helpful, thanks so much!

@sid-kap sid-kap closed this as completed Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants