git-auto-commit-mode icon indicating copy to clipboard operation
git-auto-commit-mode copied to clipboard

Setting custom variables in `.dir-local.el`

Open evb-gh opened this issue 3 years ago • 4 comments

Trying to set custom variables in the .dir-local.el file instead of init.el or config.el.

Steps:

  1. Create dir test
  2. Initiate test dir with git init
  3. Add remote git url
  4. Create .dir-local.el file
  5. add git-auto-commit-mode custom variables:
((nil . ((eval git-auto-commit-mode 1)
           (gac-automatically-push-p . t)
           (gac-automatically-add-new-files-p . t))))
  1. 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

evb-gh avatar Jun 14 '21 17:06 evb-gh

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.

evb-gh avatar Jun 15 '21 00:06 evb-gh

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.

  1. When you added the remote git url, did you specify that it is the upstream of your local branch? Because git-auto-commit-mode just tries to do git push wen gac-automatically-push-p is non-nil. If it's not set up correctly, it will just fail.
  2. Do you get any error messages in your *Messages* buffer after you save the file?
  3. Do the files you've created get staged, what's the output of git status after you save and it fails?

ryuslash avatar Jul 01 '21 20:07 ryuslash

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]

kelvie avatar Aug 14 '21 21:08 kelvie

Looks like this is a doom-emacs thing -- for other doom users, just add (setq-default enable-local-variables t) to your config.el

kelvie avatar Aug 14 '21 21:08 kelvie