From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id 2JJMET2SsWE9RAAAsNZ9tg (envelope-from ) for ; Thu, 09 Dec 2021 05:21:01 +0000 Received: from out2.migadu.com ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 2BkQDT2SsWFfBQAAbx9fmQ (envelope-from ) for ; Thu, 09 Dec 2021 05:21:01 +0000 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=1639027261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=a8v7CVZ4B8avZAcy3K+nH01bI9bK9NfYOGznPo5ItMg=; b=XQPoslkTQet9vIngMqA18kQTFKuzSLBWa3FMvxf9fA0SeDv6zUGjLqhy6yEoCfoVkejOqM xbux6Bpza4bvTPtQM/vyaUncD/Y1hDdpHMU2fbpZ9+zpY9FeNqoBwVUPH6izXEUr46bk1d qRwHrbT/ooHREjoEIM/2wY/B2A7dnNMbBkc8gTti/Dd4LanVkKiGea8ZoQ7xBw9iiDO90d P/nhs/JMuleOfLBawF43POCUGAdbHsIYSTmDODS+HmLnjEtxLQNH1qtvpWRZvvNk+jXkZ6 9UOP7APDBoqPE/x4b2X0sz/qsep4G+yzQoPxyfbNeCSUmFpJZexQrt0r6o0fHA== From: Kyle Meyer To: sourcehut@relevant-information.com Cc: piem@inbox.kyleam.com Subject: Re: [PATCH 1/1] piem-notmuch-am-ready-mbox: Add option to edit patches before applying them In-Reply-To: <87r1amfnoa.fsf@kyleam.com> References: <20211208160142.84085-1-sourcehut@relevant-information.com> <20211208160142.84085-2-sourcehut@relevant-information.com> <87r1amfnoa.fsf@kyleam.com> Date: Thu, 09 Dec 2021 00:20:53 -0500 Message-ID: <87o85qfj62.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: kyleam.com X-TUID: 2YUo+CGXgyDV Kyle Meyer writes: > I wonder if we can redesign this a bit to more closely and transparently > connect the "edit" and "am" parts. Something like: > > * from a notmuch message, invoke piem-notmuch-edit-message [*] (or > whatever name) > > This commands puts the message (or perhaps thread) into a dedicated > piem mode for editing, setting up any buffer-local variables piem > needs for record-keeping/linking (e.g., what piem-inbox-coderepo > returns in the notmuch message) and then ... > > * once the user is done editing, they can hit, say, 'C-c C-c' to call > a wrapper command that feeds the mbox to piem-am > > (Perhaps there could also be a b4 variant.) Here's a sketch of what that could look like. diff --git a/Makefile b/Makefile index b8d9fe6f..83635de6 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,8 @@ EMACS = emacs # Rely on EMACSLOADPATH for everything but the current directory. BATCH = $(EMACS) --batch -Q -L . -L tests -EL = piem.el piem-b4.el piem-elfeed.el piem-eww.el piem-gnus.el \ - piem-lei.el piem-maildir.el piem-notmuch.el piem-rmail.el \ +EL = piem.el piem-b4.el piem-edit-patch.el piem-elfeed.el piem-eww.el \ + piem-gnus.el piem-lei.el piem-maildir.el piem-notmuch.el piem-rmail.el \ tests/piem-lei-tests.el tests/piem-rmail-tests.el tests/piem-tests.el ELC = $(EL:.el=.elc) @@ -32,6 +32,7 @@ docs: Documentation/piem.html Documentation/piem.info -c TOP_NODE_UP_URL=/ Documentation/piem.texi piem-b4.elc: piem-b4.el piem.elc +piem-edit-patch.elc: piem-edit-patch.el piem-b4.elc piem.elc piem-elfeed.elc: piem-elfeed.el piem.elc piem-eww.elc: piem-eww.el piem.elc piem-gnus.elc: piem-gnus.el piem.elc diff --git a/piem-edit-patch.el b/piem-edit-patch.el new file mode 100644 index 00000000..9b309dec --- /dev/null +++ b/piem-edit-patch.el @@ -0,0 +1,66 @@ +;;; piem-edit-patch.el --- TODO -*- lexical-binding: t; -*- + +;; Copyright (C) 2021 all contributors + +;; TODO + +;;; Code: + +(require 'piem) +(require 'piem-b4) ; not used yet + +(define-derived-mode piem-edit-patch-mode nil "piem-edit-patch" + "TODO" + :group 'piem) + +(defvar piem-edit-patch-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c C-c") #'piem-edit-patch-am) + map) + "TODO") + +(defvar-local piem-edit-patch--coderepo nil) +(defvar-local piem-edit-patch--format nil) +(defvar-local piem-edit-patch--mid nil) + +(defun piem-edit-patch-open (&optional entire-thread) + (interactive "P") + (if-let ((mid (or (piem-mid) + (user-error + "No message ID found for the current buffer"))) + (fn (if entire-thread + ;; NEEDSWORK: B4 isn't wired up, so caller would + ;; need to prune non-patch messages. + (run-hook-with-args-until-success + 'piem-mid-to-thread-functions mid) + (run-hook-with-args-until-success + 'piem-am-ready-mbox-functions)))) + (let ((coderepo (piem-inbox-coderepo)) + (format "mboxrd")) + (when (member (cdr-safe fn) '("mbox" "mboxrd")) + (setq format (cdr fn)) + (setq fn (car fn))) + (with-current-buffer (get-buffer-create + (format "*piem-edit-patch-%s*" mid)) + (erase-buffer) + (funcall fn) + (unless (/= (point-max) 1) + (error "Failed to generated mbox")) + (goto-char (point-min)) + (piem-edit-patch-mode) + (setq piem-edit-patch--coderepo coderepo) + (setq piem-edit-patch--format format) + (setq piem-edit-patch--mid mid) + (pop-to-buffer (current-buffer)))) + (user-error "Do not know how to generate patch for current buffer"))) + +(defun piem-edit-patch-am (&optional toggle-worktree) + (interactive "P") + (piem-am (current-buffer) + piem-edit-patch--format + (piem-extract-mbox-info (current-buffer)) + piem-edit-patch--coderepo + toggle-worktree)) + +;;; piem-edit-patch.el ends here +(provide 'piem-edit-patch)