Created
October 26, 2014 17:10
-
-
Save tungd/fbc3532a507ec2ff2af3 to your computer and use it in GitHub Desktop.
Some add-ons for vc-git.el. The code is mostly from: https://snarfed.org/emacs-vc-git-tweaks, I only added the `amend` command.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-package vc | |
:defer t | |
:config | |
(progn | |
(setq vc-follow-symlinks t) | |
(defun td/vc-git-command (verb fn) | |
(let* ((args (vc-deduce-fileset nil t)) | |
(backend (car args)) | |
(files (nth 1 args))) | |
(if (eq backend 'Git) | |
(progn | |
(funcall fn files) | |
(message (concat verb " " | |
(number-to-string (length files)) | |
" file(s)."))) | |
(message "Not in a vc git buffer.")))) | |
(defun td/vc-git-add (&optional revision args comment) | |
(interactive "P") | |
(td/vc-git-command "Staged" 'vc-git-register)) | |
(defun td/vc-git-reset (&optional revision args comment) | |
(interactive "P") | |
(td/vc-git-command | |
"Unstaged" | |
(lambda (files) (vc-git-command nil 0 files "reset" "-q" "--")))) | |
(defun td/vc-git-amend (&optional revision args comment) | |
(interactive "P") | |
(td/vc-git-command | |
"Ammended" | |
(lambda (files) | |
(vc-git-command nil 0 files "commit" "--amend" "--reuse-message=HEAD")))) | |
(defadvice vc-dir-refresh | |
(after td/vc-hide-up-to-date-after-refresh activate) | |
(vc-dir-hide-up-to-date)) | |
(bind-keys :map vc-dir-mode-map | |
("r" . vc-revert-buffer) | |
("a" . td/vc-git-add) | |
("u" . td/vc-git-reset) | |
("A" . td/vc-git-amend)) | |
(bind-keys :map vc-prefix-map | |
("r" . vc-revert-buffer) | |
("a" . td/vc-git-add) | |
("u" . td/vc-git-reset)))) | |
(defun td/vc-projectile-root () | |
(interactive) | |
(vc-dir (projectile-project-root))) | |
(bind-key "C-c g" 'td/vc-projectile-root) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment