From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:203:b4db::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id sGI6A2T0zGGdXQAAsNZ9tg (envelope-from ); Wed, 29 Dec 2021 23:51:00 +0000 Received: from out0.migadu.com ([2001:41d0:2:267::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id yFqUAmT0zGG0uAAA9RJhRA (envelope-from ); Thu, 30 Dec 2021 00:51:00 +0100 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1640821859; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iD3QUw9hVMu4DJKM2GyJaYQraQhzXkSFax/shLUz2n4=; b=b/1xueIz+ICEDtr1aW1pK6MlPabMZLu3hMevnzcVNwHAr9lFl3vV38btyR9TKNkjzkE+UM LPKGoQTBiJ8dn5tPi9PO8tBclq53IKIF4FaWKwmDFJKR7CaR3a9JiutHAgfETq48bw8Y0Q fDpEl0+A624GmvXQjfIgave5/KUPUfOeX7NVWhtgorOvMC8vwArTvlc06Yw4eR7i7+EFA7 IquGYVlo4A5WRzZGyQpfGcP9FAj4JZTxiq3UWImdPI0qFF7lK1BgMX6z9BYP9t2Av4AgMJ vYKO2iqDkVfI5B9zUjGkGxkBLtuD9KZ/DwFrLmec2xRz/kHV8DhXu3TywPleJg== From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [RFC PATCH 04/14] am: Add function for reading piem-am's arguments Date: Wed, 29 Dec 2021 18:50:26 -0500 Message-Id: <20211229235036.372313-5-kyle@kyleam.com> In-Reply-To: <20211229235036.372313-1-kyle@kyleam.com> References: <20211229235036.372313-1-kyle@kyleam.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: kyleam.com X-TUID: F0m36OoezvbD Another command will need to do very similar processing. --- piem.el | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/piem.el b/piem.el index 4b0457a2..dc93f89d 100644 --- a/piem.el +++ b/piem.el @@ -933,6 +933,20 @@ (defun piem--git-am (mbox format dir) (magit-status-setup-buffer dir) (dired dir))) +(defun piem-am--arguments () + (pcase-let ((`(,mbox . ,format) + (or (piem-am-ready-mbox) + (user-error + "Could not find am-ready mbox for current buffer")))) + ;; We're responsible for cleaning up the buffer created by + ;; `piem-am-ready-mbox'; sneak in an indication to let the + ;; downstream code know. + (list (cons :interactive mbox) + format + (piem-extract-mbox-info mbox) + (piem-inbox-coderepo-maybe-read) + current-prefix-arg))) + ;;;###autoload (defun piem-am (mbox &optional format info coderepo toggle-worktree) "Feed an am-ready mbox to `git am'. @@ -953,26 +967,10 @@ (defun piem-am (mbox &optional format info coderepo toggle-worktree) When prefix argument TOGGLE-WORKTREE is non-nil, invert the meaning of `piem-am-create-worktree'. With the default value, this triggers the creation of a new worktree." - (interactive - (pcase-let ((`(,mbox . ,format) - (or (piem-am-ready-mbox) - (user-error - "Could not find am-ready mbox for current buffer")))) - ;; We're responsible for cleaning up the buffer created by - ;; `piem-am-ready-mbox'; sneak in an indication to let the - ;; downstream code know. - (list (cons :interactive mbox) - format - (piem-extract-mbox-info mbox) - (piem-inbox-coderepo-maybe-read) - current-prefix-arg))) - (setq format (or format "mboxrd")) + (interactive (piem-am--arguments)) (let* ((default-directory (or coderepo default-directory)) (am-directory default-directory) - (use-worktree (xor piem-am-create-worktree toggle-worktree)) - (interactivep (eq (car-safe mbox) :interactive))) - (when interactivep - (setq mbox (cdr mbox))) + (use-worktree (xor piem-am-create-worktree toggle-worktree))) (let ((new-branch (let ((b (read-string "New branch (empty for detached): " (funcall piem-default-branch-function info)))) -- 2.34.0