From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id 4K48Kiycu2GnMwAAsNZ9tg (envelope-from ) for ; Thu, 16 Dec 2021 20:06:04 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id SH0UJiycu2HjCwAAB5/wlQ (envelope-from ) for ; Thu, 16 Dec 2021 20:06:04 +0000 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6EB8D14147 for ; Thu, 16 Dec 2021 21:06:00 +0100 (CET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4JFNQt2SG4zQjgj; Thu, 16 Dec 2021 21:05:58 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de From: sourcehut@relevant-information.com To: piem@inbox.kyleam.com Cc: Leo Subject: [PATCH] Add ability to edit patches before applying them Date: Thu, 16 Dec 2021 21:05:04 +0100 Message-Id: <20211216200504.31619-1-sourcehut@relevant-information.com> In-Reply-To: <87lf0q6ckn.fsf@kyleam.com> References: <87lf0q6ckn.fsf@kyleam.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1639685163; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dE98AiyfTtVIrBwMghFRcHGdpplUNGWJaTbKHz/m9eI=; b=HO5A6iYv8wGjiHjDcKN8wIna4XGTtZxW4eDZxp0dvn9WAF6jaD9fSblDZPY8YQKzDKLsLr TYTSOF0pBxVbFTMdsinA9ihluqA7zBWg3Rvht8PkbqE07BcpD9pqGTI2CuwX3tnvOiSKvC HVkEWPIHiZOkbGUnknvbyGLjem9P6v+GaIPUENeEKaSzLN5S+hfS+e+bCRILdd/mJlsMyf hbShi6l4OfOtdGJVUNfq4wSdI7oM/dktKJuZsqCQIJVmBhGebB1QGz1XV2558f4oR09DBs NNIP3Woj4XAWyVVW6lncR3oDJaTdKS+W+lSK2TPg34n/Zy3AoiqG/+2GuGRhAg== ARC-Seal: i=1; s=key1; d=kyleam.com; t=1639685163; a=rsa-sha256; cv=none; b=EP5/2K0PhEWwnK/mxzDhSP5TfVX+SV+sMX2ptgCQYjdn9sX0FkSBxfxF2mp8CKvhHZJCWz idNkyreyhpACrzB4WpmTqAdT9vWywxFJf9TFRxUlHAPgHnT78DUe9/2q7YSYMnbxsZY3ps ILiApJ2wMR0R3st5HawTWnX0fkZnViFjROb+LIqfVajLfxGSdKgGpNbsqq3Ue8tDhbXTDD oAMHJSoGQPNHTt494bdWvUcYvDIlGZo8lHxgglbq+X+5p78q38e4ZWza7DXyE0lVkJlmw5 HuX2aqn/k7pUUX9eoK6eUsE9txErLw1AMFN0Onny8FDuM/w8GhyA7dx84PzPog== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of sourcehut@relevant-information.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=sourcehut@relevant-information.com X-Migadu-Spam-Score: -0.81 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of sourcehut@relevant-information.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=sourcehut@relevant-information.com X-Migadu-Queue-Id: 6EB8D14147 X-Spam-Score: -0.81 X-Migadu-Scanner: scn0.migadu.com X-TUID: T0JHYmuIph4Q From: Leo Sometimes it is necessary to edit patches before applying them. These changes allows you to do that by providing a new command `piem-edit` that shows the buffer that is prepared by `piem-am-ready-mbox` to the user. --- Alright, here is the patch! piem.el | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/piem.el b/piem.el index afe6b7a..668f282 100644 --- a/piem.el +++ b/piem.el @@ -900,6 +900,40 @@ (defun piem-am-read-worktree (coderepo branch) (concat (file-name-nondirectory fname) "-" (replace-regexp-in-string "/" "-" branch)))))) +(defvar-local piem-edit-patch--coderepo nil) + +(defun piem-edit () + "Edit an am-ready mbox before feeding it to `git am'." + (interactive) + (pcase-let ((`(,mbox . ,_) + (or (piem-am-ready-mbox) + (user-error + "Could not find am-ready mbox for current buffer"))) + (coderepo (piem-inbox-coderepo))) + (progn + (switch-to-buffer mbox) + (piem-edit-patch-mode) + (setq piem-edit-patch--coderepo coderepo)))) + +(defun piem-edit-patch-am () + "Apply the patch that is currently edited." + (interactive) + (piem-am (current-buffer) + "mbox" + (piem-extract-mbox-info (current-buffer)) + piem-edit-patch--coderepo)) + +(defvar piem-edit-patch-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c C-c") #'piem-edit-patch-am) + map) + "Keymap for editing patches with piem.") + +(define-derived-mode piem-edit-patch-mode text-mode "piem-edit-patch" + "Major mode for editing patches with piem." + :group 'piem + :after-hook (buffer-enable-undo)) + ;;;###autoload (defun piem-am (mbox &optional format info coderepo toggle-worktree) "Feed an am-ready mbox to `git am'. base-commit: e519aa44d148d5b8f22d7fe8844dc566046b04c2 -- 2.34.1