From 52abed7629f23ebff56799c557a4ef0299df032c Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Thu, 21 Aug 2008 02:41:43 +0300 Subject: [PATCH] Discarding items. * magit.el (magit-discard-item): New. (magit-mode-map): Bind it to 'k'. --- magit.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/magit.el b/magit.el index 1c121128..a300ffb9 100644 --- a/magit.el +++ b/magit.el @@ -442,6 +442,7 @@ Many Magit faces inherit from this one by default." (define-key map (kbd "v") 'magit-revert-commit) (define-key map (kbd "x") 'magit-reset-head) (define-key map (kbd "X") 'magit-reset-working-tree) + (define-key map (kbd "k") 'magit-discard-item) (define-key map (kbd "RET") 'magit-visit-item) (define-key map (kbd "b") 'magit-checkout) (define-key map (kbd "B") 'magit-create-branch) @@ -1062,6 +1063,16 @@ Please see the manual for a complete description of Magit. nil ".gitignore") (magit-update-status (magit-find-status-buffer))))))) +(defun magit-discard-item () + (interactive) + (let ((item (magit-get-item))) + (if item + (case (magit-item-type item) + ((untracked-file) + (let ((file (magit-item-info item))) + (if (yes-or-no-p (format "Delete file %s? " file)) + (magit-run "rm" file)))))))) + (defun magit-visit-item () (interactive) (let ((item (magit-get-item))) @@ -1089,4 +1100,5 @@ Please see the manual for a complete description of Magit. (magit-item-ending item) (magit-item-info item)))) + (provide 'magit)