Setting custom variables in `.dir-local.el`
Trying to set custom variables in the .dir-local.el file instead of init.el or config.el.
Steps:
- Create dir test
- Initiate test dir with
git init - Add remote git url
- Create
.dir-local.elfile - add
git-auto-commit-modecustom variables:
((nil . ((eval git-auto-commit-mode 1)
(gac-automatically-push-p . t)
(gac-automatically-add-new-files-p . t))))
- Create files with text inside
After the steps above I expect all files to be staged and committed to git, but that doesn't happen.
My system: macOS 10.14.6 with default Doom emacs config
I also tried:
((nil . ((eval git-auto-commit-mode 1))))
((nil . ((gac-automatically-push-p . t))))
((nil . ((gac-automatically-add-new-files-p . t))))
but got the same result.
Hey! Thanks for reporting this issue. I've tried doing this locally and I think I need some more information.
Your original .dir-locals.el is correct, the second attempt (from your comment) wouldn't work.
- When you added the remote git url, did you specify that it is the upstream of your local branch? Because
git-auto-commit-modejust tries to dogit pushwengac-automatically-push-pis non-nil. If it's not set up correctly, it will just fail. - Do you get any error messages in your
*Messages*buffer after you save the file? - Do the files you've created get staged, what's the output of
git statusafter you save and it fails?
I think I may be running in the the same issue, I get this when I try to set the dir-local variable:
Ignoring unsafe file local variable: gac-automatically-push-p [2 times]
Looks like this is a doom-emacs thing -- for other doom users, just add (setq-default enable-local-variables t) to your config.el