Discarding items.

* magit.el (magit-discard-item): New.
(magit-mode-map): Bind it to 'k'.
This commit is contained in:
Marius Vollmer 2008-08-21 02:41:43 +03:00
parent 909c793cf2
commit 52abed7629

View file

@ -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 "v") 'magit-revert-commit)
(define-key map (kbd "x") 'magit-reset-head) (define-key map (kbd "x") 'magit-reset-head)
(define-key map (kbd "X") 'magit-reset-working-tree) (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 "RET") 'magit-visit-item)
(define-key map (kbd "b") 'magit-checkout) (define-key map (kbd "b") 'magit-checkout)
(define-key map (kbd "B") 'magit-create-branch) (define-key map (kbd "B") 'magit-create-branch)
@ -1062,6 +1063,16 @@ Please see the manual for a complete description of Magit.
nil ".gitignore") nil ".gitignore")
(magit-update-status (magit-find-status-buffer))))))) (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 () (defun magit-visit-item ()
(interactive) (interactive)
(let ((item (magit-get-item))) (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-ending item)
(magit-item-info item)))) (magit-item-info item))))
(provide 'magit) (provide 'magit)