Skip to contentSkip to conversation

stgit.el patches

PATCH In review David Kågedal 2 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

cover 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 · 1 line
Signature
#1 lore raw

PATCH 1/3 stgit.el: Added undo command

Bound it to the two standard bindings C-/ and C-_.

---
 contrib/stgit.el |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
contrib/stgit.el +13 -1
index aafefaf..e6b7d70 100644
@@ -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)
#2 lore raw

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

contrib/stgit.el Argument DIR is the repository path." · line 170

Quoted 4 lines · David Kågedal

Bound it to the two standard bindings C-/ and C-_.

contrib/stgit.el +2 -0
+  (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?

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#3 lore raw

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

Quoted 8 lines · Karl Hasselström

contrib/stgit.el Argument DIR is the repository path." · line 170

Quoted 4 lines · David Kågedal

Bound it to the two standard bindings C-/ and C-_.

contrib/stgit.el +2 -0
+  (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.

Signature · 1 line
David Kågedal
#4 lore raw

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

In reply to David Kågedal

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

---
 contrib/stgit.el |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
contrib/stgit.el +11 -8
index e6b7d70..9907952 100644
@@ -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 ()
#5 lore raw

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

In reply to David Kågedal
---
 contrib/stgit.el |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
contrib/stgit.el +2 -1
index 9907952..d0f19c3 100644
@@ -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))