threads / patch / 16092

patch, 3 partsstgit.el: Added undo command

Subject: [StGit PATCH 1/3] stgit.el: Added undo command

## tl;dr

6 messages between Oct 30, 2008 and Oct 30, 2008. Diffs are folded; open one to read it.

replies: 5people: 2as markdown or json

David Kågedal· Oct 30, 2008, 09:52 UTC · lore

[StGit PATCH 0/3] stgit.el patches

These three patches updates stgit.el. They don't depend on each other and can be applied independently.

---
David Kågedal (3):
      stgit.el: Adapt to new output from stg series.
      stgit.el: Added numeric prefix argument to push and pop commands.
      stgit.el: Added undo command
 contrib/stgit.el |   36 ++++++++++++++++++++++++++----------
 1 files changed, 26 insertions(+), 10 deletions(-)
-- 
Signature
David Kågedal· Oct 30, 2008, 09:52 UTC · re: David Kågedal · lore
Bound it to the two standard bindings C-/ and C-_.
Signed-off-by: David Kågedal <davidk@lysator.liu.se>
---
 contrib/stgit.el |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
Show changes to contrib/stgit.el +13 −1
diff --git a/contrib/stgit.el b/contrib/stgit.el
index aafefaf..e6b7d70 100644
--- a/contrib/stgit.el
+++ b/contrib/stgit.el
@@ -165,7 +165,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.
@@ -408,4 +410,14 @@ Commands:
   (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)
Karl Hasselström· Oct 30, 2008, 11:57 UTC · re: David Kågedal · lore

Re: [StGit PATCH 1/3] stgit.el: Added undo command

On 2008-10-30 10:52:48 +0100, David Kågedal wrote:
> Bound it to the two standard bindings C-/ and C-_.
> +  (define-key stgit-mode-map [(control ?/)] 'stgit-undo)
> +  (define-key stgit-mode-map "\C-_" 'stgit-undo))
Hmm, why do you spell control in two different ways?
-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
David Kågedal· Oct 30, 2008, 14:57 UTC · re: Karl Hasselström · lore

Re: [StGit PATCH 1/3] stgit.el: Added undo command

Karl Hasselström <kha@treskal.com> writes:
Show 8 quoted lines
> On 2008-10-30 10:52:48 +0100, David Kågedal wrote:
>
>> Bound it to the two standard bindings C-/ and C-_.
>
>> +  (define-key stgit-mode-map [(control ?/)] 'stgit-undo)
>> +  (define-key stgit-mode-map "\C-_" 'stgit-undo))
>
> Hmm, why do you spell control in two different ways?

I usually use the "\C-x" syntax, but for some reason that didn't work with "\C-/", so I used another syntax. I'm not sure how compatible that is with XEmacs, though.

-- 
David Kågedal
David Kågedal· Oct 30, 2008, 09:52 UTC · re: David Kågedal · lore

[StGit PATCH 2/3] stgit.el: Added numeric prefix argument to push and pop commands.

By using a numerical prefix (or simply C-u) it is possible to push or pop more than one patch.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
---
 contrib/stgit.el |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
Show changes to contrib/stgit.el +11 −8
diff --git a/contrib/stgit.el b/contrib/stgit.el
index e6b7d70..9907952 100644
--- a/contrib/stgit.el
+++ b/contrib/stgit.el
@@ -276,16 +276,19 @@ Commands:
   (stgit-capture-output nil (stgit-run "uncommit" "-n" (number-to-string arg)))
   (stgit-refresh))
 
-(defun stgit-push-next ()
-  "Push the first unapplied patch"
-  (interactive)
-  (stgit-capture-output nil (stgit-run "push"))
+(defun stgit-push-next (npatches)
+  "Push the first unapplied patch.
+With numeric prefix argument, push that many patches."
+  (interactive "p")
+  (stgit-capture-output nil (stgit-run "push" "-n"
+                                       (number-to-string npatches)))
   (stgit-refresh))
 
-(defun stgit-pop-next ()
-  "Pop the topmost applied patch"
-  (interactive)
-  (stgit-capture-output nil (stgit-run "pop"))
+(defun stgit-pop-next (npatches)
+  "Pop the topmost applied patch.
+With numeric prefix argument, pop that many patches."
+  (interactive "p")
+  (stgit-capture-output nil (stgit-run "pop" "-n" (number-to-string npatches)))
   (stgit-refresh))
 
 (defun stgit-applied-at-point ()
David Kågedal· Oct 30, 2008, 09:52 UTC · re: David Kågedal · lore

[StGit PATCH 3/3] stgit.el: Adapt to new output from stg series.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
---
 contrib/stgit.el |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Show changes to contrib/stgit.el +2 −1
diff --git a/contrib/stgit.el b/contrib/stgit.el
index 9907952..d0f19c3 100644
--- a/contrib/stgit.el
+++ b/contrib/stgit.el
@@ -131,7 +131,8 @@ Argument DIR is the repository path."
                  (when (memq patchsym stgit-marked-patches)
                    (replace-match "*" nil nil nil 2)
                    (setq marked (cons patchsym marked)))))
-              ((looking-at "stg series: Branch \".*\" not initialised")
+              ((or (looking-at "stg series: Branch \".*\" not initialised")
+                   (looking-at "stg series: .*: branch not initialized"))
                (forward-line 1)
                (insert "Run M-x stgit-init to initialise")))
         (forward-line 1))

← back to recent threads