aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2008-04-09 18:53:16 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2008-04-09 18:53:16 +0200
commit974d1193d2d0c039ba4d89d776218bf3a2fbe564 (patch)
treea824f3cfe39fdf1548431b71cb2737892b9b2fdb
parentd7cf26f54387a0018ed7577be6ea0567aff0f820 (diff)
downloadgitsum-974d1193d2d0c039ba4d89d776218bf3a2fbe564.tar.gz
gitsum-974d1193d2d0c039ba4d89d776218bf3a2fbe564.tar.xz
gitsum-974d1193d2d0c039ba4d89d776218bf3a2fbe564.zip
Make kill more intuitive
-rw-r--r--gitsum.el20
1 files changed, 19 insertions, 1 deletions
diff --git a/gitsum.el b/gitsum.el
index 54ed03b..fcc9262 100644
--- a/gitsum.el
+++ b/gitsum.el
@@ -15,6 +15,7 @@
'(("A" . gitsum-amend)
("c" . gitsum-commit)
("g" . gitsum-refresh)
+ ("k" . gitsum-kill-dwim)
("P" . gitsum-push)
("R" . gitsum-revert)
("s" . gitsum-switch-to-git-status)
@@ -63,7 +64,24 @@ A numeric argument serves as a repeat count."
(insert diff)
(goto-char (point-min))
(delete-matching-lines "^index \\|^diff --git ")))
- (set-buffer-modified-p nil)))
+ (set-buffer-modified-p nil)
+ (goto-char (point-min))
+ (forward-line 4)))
+
+(defun gitsum-kill-dwim ()
+ "Kill the current hunk or file depending on point."
+ (interactive)
+ (let ((inhibit-read-only t))
+ (if (looking-at "^---\\|^\\+\\+\\+")
+ (diff-file-kill)
+ (diff-hunk-kill)
+ (save-excursion
+ (when (or (looking-at "^--- ")
+ (eobp))
+ (let ((here (point)))
+ (forward-line -2)
+ (when (looking-at "^--- ")
+ (delete-region here (point)))))))))
(defun gitsum-commit ()
"Commit the patch as-is, asking for a commit message."