Skip to content

Commit 9177357

Browse files
committed
Convert sink popup
Require a match when prompting for a patch.
1 parent 9e65ab4 commit 9177357

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

magit-stgit.el

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ one from the minibuffer, and move to the next line."
257257
["Stack"
258258
[("i" "Init" magit-stgit-init)
259259
("f" "Float" magit-stgit-float)
260-
("s" "Sink" magit-stgit-sink-popup)
260+
("s" "Sink" magit-stgit-sink)
261261
("a" "Goto" magit-stgit-goto-popup)]
262262
[("c" "Commit" magit-stgit-commit-popup)
263263
("C" "Uncommit" magit-stgit-uncommit-popup)
@@ -360,28 +360,33 @@ minibuffer."
360360
(read-from-minibuffer "New name: ")))
361361
(magit-run-stgit "rename" oldname newname))
362362

363-
(magit-define-popup magit-stgit-sink-popup
364-
"Popup console for StGit sink."
365-
'magit-stgit-commands
366-
:switches '((?k "Keep the local changes" "--keep"))
367-
:options '((?t "Sink patches below the target patch (else to bottom)"
368-
"--to="
369-
(lambda (prompt &optional default) (magit-stgit-read-patch prompt t))))
370-
:actions '((?s "Sink" magit-stgit-sink))
371-
:default-action #'magit-stgit--float)
363+
(transient-define-prefix magit-stgit-sink ()
364+
"Move a set of patches toward the bottom of the stack."
365+
:man-page "stg-sink"
366+
["Arguments"
367+
("-k" "Keep the local changes" "--keep")
368+
("-t" "Sink patches below target" "--to="
369+
:reader (lambda (_prompt _initial-input _history)
370+
(magit-stgit-read-patch "Sink below" t)))]
371+
["Actions"
372+
("s" "Sink" magit-stgit--sink)])
372373

373374
;;;###autoload
374-
(defun magit-stgit-sink (patches &rest args)
375-
"Sink StGit PATCHES deeper down the stack.
376-
Use ARGS to pass additional arguments."
377-
(interactive (list (magit-stgit-read-patches t t t t "Sink patch")
378-
(magit-stgit-sink-arguments)))
379-
(when (and (called-interactively-p 'any)
380-
(not magit-current-popup))
381-
(let ((target (magit-stgit-read-patch "Target patch (default is bottom)")))
382-
(when target
383-
(setq args (append args (list "-t" target))))))
384-
(magit-run-stgit-and-mark-remove patches "sink" args "--" patches))
375+
(defun magit-stgit--sink (&optional patches &rest args)
376+
"Invoke `stg sink ARGS... PATCHES...'.
377+
378+
If PATCHES is nil, sink the current patch.
379+
380+
If called interactively, sink the patches around point or read
381+
one from the minibuffer. Read the target patch from the
382+
minibuffer as well."
383+
(interactive (cons (magit-stgit-read-patches t t t t "Sink patch")
384+
(transient-args 'magit-stgit-sink)))
385+
(let ((target (and (called-interactively-p 'any)
386+
(not transient-current-prefix)
387+
(magit-stgit-read-patch "Sink below" t))))
388+
(magit-run-stgit-and-mark-remove
389+
patches (and target (list "-t" target)) "sink" args patches)))
385390

386391
(magit-define-popup magit-stgit-commit-popup
387392
"Popup console for StGit commit."
@@ -667,7 +672,7 @@ the To, Cc, and Bcc fields for all patches."
667672
"---"
668673
["Float patch" magit-stgit-float
669674
:help "Float StGit patch to the top"]
670-
["Sink patch" magit-stgit-sink-popup
675+
["Sink patch" magit-stgit-sink
671676
:help "Sink StGit patch deeper down the stack"]
672677
"---"
673678
["Refresh patch" magit-stgit-refresh-popup

0 commit comments

Comments
 (0)