From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id eLBDIGeUu2EcNwAAsNZ9tg (envelope-from ) for ; Thu, 16 Dec 2021 19:32:55 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qEAZHGeUu2HXUQAA1q6Kng (envelope-from ) for ; Thu, 16 Dec 2021 19:32:55 +0000 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050::465:101]) (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 9BF622A64E for ; Thu, 16 Dec 2021 20:32:51 +0100 (CET) Received: from smtp202.mailbox.org (smtp202.mailbox.org [80.241.60.245]) (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-101.mailbox.org (Postfix) with ESMTPS id 4JFMhb5nrhzQlCN; Thu, 16 Dec 2021 20:32:47 +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 v3 1/2] Support preparing am-ready mbox via notmuch-extract-patch Date: Thu, 16 Dec 2021 20:32:33 +0100 Message-Id: <20211216193234.25745-1-sourcehut@relevant-information.com> In-Reply-To: <87y24mwipm.fsf@kyleam.com> References: <87y24mwipm.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=1639683175; 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=xOaTKdQvDOQvYr1I9/BOJAqE2aW1RASSaVF6tEJi6PI=; b=awzh8klSzZ9/5BGiy7scl4Qosuju4Wze2+/+JoR/GA/LbwtSRMhWQVZvGjDNef+wDML0wr LWc0NlVVvgciJYkdHV5OoOxcp758o0oE2XOSn1SOIEzLwTuVVe57tESoIXOEsXsay6Vnec MUC8a3QHs2C2UXLANbWM61i4eBSVrSKU9UdqF5qNxQt2DQt73XDQaz17c1moF4fCIkEYOC WcbaA4xmx/m+XNwoTF9u9bNiNtediCaL2qXjW2bF0CpJKNUFDxlpLhBfKk0+Jl/Rat1A+S n5GqfPS+Tk/l1HqNAcDpPeoXZi2WZzzaiIY8ShweNoN0LiR9niKJpi/5QTT2tA== ARC-Seal: i=1; s=key1; d=kyleam.com; t=1639683175; a=rsa-sha256; cv=none; b=xqx+71vVX24xSCVIMolUX6PmqH9kuqaTgayaw503W4UkxWXbxeT6Co5IRPUVdiY7Q36HiI wod9wwrHJowDzhAavl+H8aWlAXmVxW4LGdWtBECjJaXnzK07tVQcwCXLAqt2eL3A+p3/XZ UTNj+M07XRDttOHnZG/I+Ynx4cElvM5z94Q9YlbtafUALAuf9iK3JbxkkyODZ66iUvIemm 9bm4n8jeLT2mR2we8fuvyV7ddSE3W6aIH2bmBL5QK4Pq+ci2/VSTi52MfIJk0VxtboP1yo fUre8HM6qGwkigh3ZnyvtHea5GL4+SBkZQ8e0I+MLBr9DSTYSNaKF5xMbbDy+A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of sourcehut@relevant-information.com designates 2001:67c:2050::465:101 as permitted sender) smtp.mailfrom=sourcehut@relevant-information.com X-Migadu-Spam-Score: -1.82 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of sourcehut@relevant-information.com designates 2001:67c:2050::465:101 as permitted sender) smtp.mailfrom=sourcehut@relevant-information.com X-Migadu-Queue-Id: 9BF622A64E X-Spam-Score: -1.82 X-Migadu-Scanner: scn0.migadu.com X-TUID: zhoAV3qOitqi From: Leo notmuch-extract-patch is a command line tool from the elpa-mailscripts package that extracts patches from a thread. It's a useful way to extract the latest patch series from an email thread and filter out the replies and reviews. --- piem-notmuch.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/piem-notmuch.el b/piem-notmuch.el index 8b2a353..1ee0b37 100644 --- a/piem-notmuch.el +++ b/piem-notmuch.el @@ -1,6 +1,7 @@ ;;; piem-notmuch.el --- Notmuch integration for piem -*- lexical-binding: t; -*- ;; Copyright (C) 2020-2021 all contributors +;; (C) 2019 Sean Whitton ;; Author: Kyle Meyer ;; Keywords: vc, tools @@ -106,6 +107,37 @@ (defun piem-notmuch-am-ready-mbox () (insert patch))) "mbox")))))) +(defun piem-notmuch-extract-patch-am-ready-mbox () + "Return a function that inserts an am-ready mbox. +Use the message itself if it looks like a patch using +notmuch-extract-patch to get the latest patch series from the +notmuch thread." + (when (and (derived-mode-p 'notmuch-show-mode) + (string-match-p piem-patch-subject-re + (notmuch-show-get-subject)) + (= (notmuch-count-attachments + (piem-notmuch--with-current-message + (mm-dissect-buffer))) 0)) + (let ((thread-id notmuch-show-thread-id)) + (lambda () + (if-let ((cmd (executable-find "notmuch-extract-patch")) + (tid + ;; Copied from mailscripts.el + ;; + ;; If `notmuch-show' was called with a notmuch query rather + ;; than a thread ID, as `org-notmuch-follow-link' in + ;; org-notmuch.el does, then `notmuch-show-thread-id' might + ;; be an arbitrary notmuch query instead of a thread ID. We + ;; need to wrap such a query in thread:{} before passing it + ;; to notmuch-extract-patch(1), or we might not get a whole + ;; thread extracted (e.g. if the query is just id:foo) + (if (string= (substring thread-id 0 7) "thread:") + thread-id + (concat "thread:{" thread-id "}")))) + (call-process cmd nil t nil + tid) + (user-error "The executable notmuch-extract-patch was not found")))))) + (defun piem-notmuch-show-get-public-inbox-link (mid) "Given the message-id MID, return the public-inbox url. This will lookup the url in the inboxes returned by -- 2.34.1