stgit.el: Add undo command
authorDavid Kågedal <davidk@lysator.liu.se>
Thu, 6 Nov 2008 07:34:37 +0000 (08:34 +0100)
committerKarl Hasselström <kha@treskal.com>
Thu, 6 Nov 2008 07:35:00 +0000 (08:35 +0100)
Bound it to the two standard bindings C-/ and C-_.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
contrib/stgit.el

index c7ad447..d0f19c3 100644 (file)
@@ -166,7 +166,9 @@ Argument DIR is the repository path."
   (define-key stgit-mode-map "P"   'stgit-push-or-pop)
   (define-key stgit-mode-map "G"   'stgit-goto)
   (define-key stgit-mode-map "="   'stgit-show)
-  (define-key stgit-mode-map "D"   'stgit-delete))
+  (define-key stgit-mode-map "D"   'stgit-delete)
+  (define-key stgit-mode-map [(control ?/)] 'stgit-undo)
+  (define-key stgit-mode-map "\C-_" 'stgit-undo))
 
 (defun stgit-mode ()
   "Major mode for interacting with StGit.
@@ -412,4 +414,14 @@ With numeric prefix argument, pop that many patches."
   (interactive)
   (describe-function 'stgit-mode))
 
+(defun stgit-undo (&optional arg)
+  "Run stg undo.
+With prefix argument, run it with the --hard flag."
+  (interactive "P")
+  (stgit-capture-output nil
+    (if arg
+        (stgit-run "undo" "--hard")
+      (stgit-run "undo")))
+  (stgit-refresh))
+
 (provide 'stgit)