+Integration with emacs
+======================
+If you're an emacs user, here is some code you could put into your
+.emacs file to have "nogit sync" called automatically for you for any
+nogit-controlled files whenever you open one, begin editing it, or
+save it:
+
+ ; Run "nogit sync" if there is a .noggit directory here.
+ ;
+ ; Note: There is an important protection built into this implementation:
+ ;
+ ; We bind 'in-nogit-sync and test whether it's bound to avoid
+ ; infinite recursion. This could otherwise come about because
+ ; the revert-buffer function could trigger the find-file-hook
+ ; and recurse.
+ (defun nogit-sync-if-configured ()
+ (interactive)
+ (if (and
+ (buffer-file-name)
+ (file-exists-p (format "%s/../.nogit" (buffer-file-name)))
+ (not (boundp 'in-nogit-sync))
+ )
+ (let ((in-nogit-sync t))
+ (message (substring (shell-command-to-string "nogit sync") 0 -1))
+ (revert-buffer nil t)
+ )
+ )
+ )
+
+ ; Arrange to run "nogit sync" when the user loads a nogit-controlled file,
+ ; starts editing it for the first time, or saves it.
+ (add-hook 'find-file-hook 'nogit-sync-if-configured)
+ (add-hook 'first-change-hook 'nogit-sync-if-configured)
+ (add-hook 'after-save-hook 'nogit-sync-if-configured)
+
+Preparing git repositories for use with nogit
+=============================================