diff options
authorChristian Neukirchen <chneukirchen@gmail.com>2008-04-10 21:39:53 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2008-04-10 21:39:53 +0200
commitbba2d3125969b1cb7c3490fac9e6cd354949cf99 (patch)
parent1cbc163485d516c2927f2f3b9d9a19e3897de352 (diff)
Make "s" in git-status acknowledge the currently marked files
1 files changed, 13 insertions, 3 deletions
diff --git a/gitsum.el b/gitsum.el
index 299f5fa..f7578f6 100644
--- a/gitsum.el
+++ b/gitsum.el
@@ -38,7 +38,7 @@ This mode is meant to be activated by `M-x gitsum' or pressing `s' in git-status
;; When git.el is loaded, hack into keymap.
(when (boundp 'git-status-mode-map)
- (define-key git-status-mode-map "s" 'gitsum))
+ (define-key git-status-mode-map "s" 'gitsum-switch-from-git-status))
;; Undo doesn't work in read-only buffers else.
(defun gitsum-undo ()
@@ -50,7 +50,7 @@ A numeric argument serves as a repeat count."
(let ((inhibit-read-only t))
-(defun gitsum-refresh ()
+(defun gitsum-refresh (&optional arguments)
"Regenerate the patch based on the current state of the index."
(let ((inhibit-read-only t))
@@ -58,7 +58,7 @@ A numeric argument serves as a repeat count."
(insert "# Directory: " default-directory "\n")
(insert "# Use n and p to navigate and k to kill a hunk. u is undo, g will refresh.\n")
(insert "# Edit the patch as you please and press 'c' to commit.\n\n")
- (let ((diff (shell-command-to-string "git diff")))
+ (let ((diff (shell-command-to-string (concat "git diff " arguments))))
(if (zerop (length diff))
(insert "## No changes. ##")
(insert diff)
@@ -156,6 +156,16 @@ A numeric argument serves as a repeat count."
(git-status default-directory))
+(defun gitsum-switch-from-git-status ()
+ "Switch to gitsum, resticting diff to marked files if any."
+ (interactive)
+ (let ((marked (git-get-filenames
+ (ewoc-collect git-status
+ (lambda (info) (git-fileinfo->marked info))))))
+ (gitsum)
+ (when marked
+ (gitsum-refresh (mapconcat 'identity marked " ")))))
(defun gitsum ()
"Entry point into gitsum-diff-mode."