summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-01-09 23:58:28 +0100
committerGravatar Tom Willemsen2012-01-09 23:58:28 +0100
commit59c97f2adace2960c0db271300bb1fc2b2e49faf (patch)
tree1bcfea39aa0126aec8605d412df701fbf728bb02
downloadgit-auto-commit-mode-59c97f2adace2960c0db271300bb1fc2b2e49faf.tar.gz
git-auto-commit-mode-59c97f2adace2960c0db271300bb1fc2b2e49faf.zip
Initial commit
-rw-r--r--git-auto-commit-mode.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/git-auto-commit-mode.el b/git-auto-commit-mode.el
new file mode 100644
index 0000000..12c3c63
--- /dev/null
+++ b/git-auto-commit-mode.el
@@ -0,0 +1,13 @@
+(defun git-auto-commit ()
+ "Commit `buffer-file-name` to git"
+ (let ((filename (buffer-file-name)))
+ (shell-command (concat "git add " filename
+ " && git commit -m '" filename "'"))))
+
+(define-minor-mode git-auto-commit-mode
+ "Automatically commit any changes made when saving with this mode
+turned on"
+ :lighter "ga"
+ (if git-auto-commit-mode
+ (add-hook 'after-save-hook 'git-auto-commit t t)
+ (remove-hook 'after-save-hook 'git-auto-commit t)))