From 71f099b9728fdd2f0507ba3e7471ea2deb2dac04 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 18 Oct 2014 00:29:08 -0400 Subject: Add command magit-stage-file-intent --- lisp/init-git.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lisp') diff --git a/lisp/init-git.el b/lisp/init-git.el index d78655d..3c84931 100644 --- a/lisp/init-git.el +++ b/lisp/init-git.el @@ -40,6 +40,24 @@ This is useful for commit IDs in files and log messages." '(lambda () (magit-show-commit it)))) (projectile-switch-project)))) +(defun km/magit-stage-file-intent (file) + "Stage FILE but not its content. +With a prefix argument or when there is no file at point ask for +the file to be staged. Otherwise stage the file at point without +requiring confirmation. +\n(git add -N FILE)" + ;; Modified from `magit-stage-file'. + (interactive + (let* ((atpoint (magit-section-when (file))) + (current (magit-file-relative-name)) + (choices (magit-untracked-files)) + (default (car (member (or atpoint current) choices)))) + (list (if (or current-prefix-arg (not default)) + (magit-completing-read "Stage file" choices + nil t nil nil default) + default)))) + (magit-run-git "add" "-N" file)) + (defun km/magit-push-all () "Push all branches." (interactive) @@ -115,6 +133,8 @@ START-POINT set to the current branch. ;; my binding for `km/zsh-ansi-term-other-window'. (define-key magit-mode-map (kbd "C-x 4 a") nil) + (define-key magit-mode-map "N" 'km/magit-stage-file-intent) + (magit-define-popup-action 'magit-commit-popup ?u "Auto commit" 'km/magit-auto-commit) (magit-define-popup-action 'magit-push-popup -- cgit v1.2.3