stgit.el: make stgit-delete with prefix argument spill patch contents to index
authorGustav Hållberg <gustav@virtutech.com>
Thu, 26 Feb 2009 19:59:07 +0000 (20:59 +0100)
committerGustav Hållberg <gustav@virtutech.com>
Thu, 26 Feb 2009 19:59:07 +0000 (20:59 +0100)
Signed-off-by: Gustav Hållberg <gustav@virtutech.com>
Signed-off-by: Karl Hasselström <kha@treskal.com>
contrib/stgit.el

index 7c83a9e..3c8734c 100644 (file)
@@ -804,19 +804,29 @@ end of the patch."
            (substring patch 0 20))
           (t patch))))
 
-(defun stgit-delete (patchsyms)
+(defun stgit-delete (patchsyms &optional spill-p)
   "Delete the patches in PATCHSYMS.
-Interactively, delete the marked patches, or the patch at point."
-  (interactive (list (stgit-patches-marked-or-at-point)))
+Interactively, delete the marked patches, or the patch at point.
+
+With a prefix argument, or SPILL-P, spill the patch contents to
+the work tree and index."
+  (interactive (list (stgit-patches-marked-or-at-point)
+                     current-prefix-arg))
   (unless patchsyms
     (error "No patches to delete"))
   (let ((npatches (length patchsyms)))
-    (when (yes-or-no-p (format "Really delete %d patch%s? "
+    (when (yes-or-no-p (format "Really delete %d patch%s%s? "
                               npatches
-                              (if (= 1 npatches) "" "es")))
-      (stgit-capture-output nil
-       (apply 'stgit-run "delete" patchsyms))
-      (stgit-reload))))
+                              (if (= 1 npatches) "" "es")
+                               (if spill-p
+                                   " (spilling contents to index)"
+                                 "")))
+      (let ((args (if spill-p 
+                      (cons "--spill" patchsyms)
+                    patchsyms)))
+        (stgit-capture-output nil
+          (apply 'stgit-run "delete" args))
+        (stgit-reload)))))
 
 (defun stgit-coalesce (patchsyms)
   "Coalesce the patches in PATCHSYMS.