1

Can I perhaps add a hook via local variables in the file header?

tarsius
  • 25,685
  • 4
  • 70
  • 109
Lenar Hoyt
  • 1,173
  • 7
  • 25

2 Answers2

1

Here is what I use to auto-commit files in 2 directories (for my notes):

(defun egh:maybe-git-auto-commit-mode ()
  (let* ((bfn (buffer-file-name))
         (root (and bfn (vc-git-root bfn)))
         (full-root (and root (expand-file-name root))))
    (if (or (string-equal full-root "/home/egh/c/notes/h/")
            (string-equal full-root "/home/egh/c/notes/w/"))
        (git-auto-commit-mode +1))))
(add-hook 'org-mode-hook #'egh:maybe-git-auto-commit-mode)
(setq-default gac-automatically-push-p t)

This will commit org files when the git root is /home/egh/c/notes/{c,w}.

tarsius
  • 25,685
  • 4
  • 70
  • 109
Erik Hetzner
  • 765
  • 3
  • 6
0

With this project you can do it easily per-file or per-directory.

If you’re using Emacs 24 or newer you should set an eval file-local variable:

;; -*- eval: (git-auto-commit-mode 1) -*-

If you’re using an older version of Emacs, that should be:

;; -*- mode: git-auto-commit -*-

See https://github.com/ryuslash/git-auto-commit-mode

djangonaut
  • 125
  • 5