From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:4ea1::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id gHs4MGf0zGFpRwAAsNZ9tg (envelope-from ); Wed, 29 Dec 2021 23:51:03 +0000 Received: from out2.migadu.com ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id YEVGLWf0zGFy0wAAG6o9tA (envelope-from ); Thu, 30 Dec 2021 00:51:03 +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=1640821863; 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=hYRhACyC4qoZzAsYt/dpdMZGhSvDsutP1c1S4CrD6BM=; b=YbZ6ERrxdglSOEYXsUG+EMv0C8PKnxiuTeCbgJs5X4HLy6Yjv6j4sPYTZOp6cOh0K3dzhF BpQVRh2VJIvv2pbReezCG23D3e6vDT2bNyJ9JlCEEqGkKuql6orGXcPM5H0Kba9SQ4OAbx n5uhCdYLpmC/DZiURCkxIQUI/jnd7lJFF5iPDz/yMMDMEpf+jI2PHbbiV01mOuqdfGFvkB 6HktjHbRD0Qiuh7e41QpTaHVOpL6qxh+kvSxMcBwwaHpIzkkULaUGZCPRrX0SV/IMSAtc+ IWjqDTh9VQRMY2kqZkiDUg/SOOjwX6kQLRWxXKvOmta46ycamiR5DAsQPk2gVQ== From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [RFC PATCH 06/14] edit patch: Inject values via interactive arguments Date: Wed, 29 Dec 2021 18:50:28 -0500 Message-Id: <20211229235036.372313-7-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: Cjwy1yXCrEbp piem-edit stores values in buffer-local variables that piem-edit-patch-am then uses in a non-interactive call to piem-am. That works, but the caller doesn't have access to piem-am's toggle-worktree argument. And this functionality gap will grow bigger when an upcoming commit moves transition piem-am to a transient, moving the current piem-am to a suffix. Instead teach piem-am--arguments how to pull the mbox and coderepo from these buffer-local values so that piem-edit-patch-am can just call piem-am interactively. --- piem.el | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/piem.el b/piem.el index 6241cb1f..eea81a8e 100644 --- a/piem.el +++ b/piem.el @@ -933,9 +933,14 @@ (defun piem--git-am (mbox format dir) (magit-status-setup-buffer dir) (dired dir))) +(defvar-local piem-edit-patch--coderepo nil) +(defvar-local piem-edit-patch--format nil) + (defun piem-am--arguments () (pcase-let ((`(,mbox . ,format) - (or (piem-am-ready-mbox) + (or (and (derived-mode-p 'piem-edit-patch-mode) + (cons (current-buffer) piem-edit-patch--format)) + (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 @@ -944,7 +949,8 @@ (defun piem-am--arguments () (list (cons :interactive mbox) format (piem-extract-mbox-info mbox) - (piem-inbox-coderepo-maybe-read) + (or piem-edit-patch--coderepo + (piem-inbox-coderepo-maybe-read)) current-prefix-arg))) ;;;###autoload @@ -998,9 +1004,6 @@ (defun piem-am (mbox &optional format info coderepo toggle-worktree) ;;;;; Patch editing -(defvar-local piem-edit-patch--coderepo nil) -(defvar-local piem-edit-patch--format nil) - (defun piem-edit () "Edit an am-ready mbox before feeding it to `git am'." (interactive) @@ -1017,12 +1020,7 @@ (defun piem-edit () (defun piem-edit-patch-am () "Apply the patch that is currently edited." (interactive) - (let ((buf (current-buffer))) - (piem-am buf - piem-edit-patch--format - (piem-extract-mbox-info (current-buffer)) - piem-edit-patch--coderepo) - (kill-buffer buf))) + (call-interactively #'piem-am)) (defvar piem-edit-patch-mode-map (let ((map (make-sparse-keymap))) -- 2.34.0