From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ODVeJQZXpmJthAAAbAwnHQ (envelope-from ) for ; Sun, 12 Jun 2022 23:13:42 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id aBViJQZXpmIgkAAA9RJhRA (envelope-from ) for ; Sun, 12 Jun 2022 23:13:42 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (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 4B25D172D9 for ; Sun, 12 Jun 2022 23:13:42 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7256F5F6C0; Sun, 12 Jun 2022 21:13:36 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 17B775F3FE for ; Sun, 12 Jun 2022 21:13:33 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 7A24C5FBD7; Sun, 12 Jun 2022 17:13:32 -0400 (EDT) Received: (nullmailer pid 3806112 invoked by uid 1000); Sun, 12 Jun 2022 19:05:03 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 4/4] WIP/emacs: replace message with different duplicate Date: Sun, 12 Jun 2022 16:04:59 -0300 Message-Id: <20220612190459.3804908-5-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220612190459.3804908-1-david@tethera.net> References: <20220612190459.3804908-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: SPRI2QRRVCXIERAQGGB2BJ45RWYGGNIP X-Message-ID-Hash: SPRI2QRRVCXIERAQGGB2BJ45RWYGGNIP X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1655068422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=cc+l6AQHNCyDA+zKCdcRDfyNvHz/JxKAy8AqgzjyP2E=; b=Y3Rxs1A9AlKFnePmJxEqEdWTXYiF8HAzLDAvlq6VKcue/Zyz1bGfxhv5VHXFeHeR291wBZ 1TEX6IYaga96hFbj/KY+MmqvN47Mnonxoclf5UTeJXmhGRQs3CmxC5iNLQIxPVbNvBMdqh MaGXoeTRbMbrhaWZ5HhjUC2gRE4aVxFuk8SQCFMkF6d5itfq7/4fvncsh+Ekufy11WcNdq a0lLZDl0KfbRvEKaQvjnHezoQeXzFFa60lURp16v6ucGeFW0vYnRceG1CPox/yyS56t/Rk Zyya+nXLh2eg7IjWSFLh5QxyYHCRTToBMQ0STtgvsMxX+NtUvUSBGAWd8vJ82g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655068422; a=rsa-sha256; cv=none; b=ckyYeIIjvMOXiqH2JhNpQx45dxftQ9LC9Ode3ZLINFKvXo88nTZbJXNKTQueq8R2hFgML1 YegcHYV4D0+LFs2d2dTVWpMGh4c1ED4OHWoFMnAMaPeeS08FocDfHc8yDMeBXFaUECoRP6 OfgZl7bBbasDDGdZ2qwvUc1iwVgLv4Wi98ELlGQB4VgchT//XOxgT2NQadb6/QRpCEB/kB u/iRkMqbi/NgYOjrfceJHCsPte5Ch7rdtj9uXeicDbDDUgvXBunqamX2BLcVk7RmAOyrqj Psm/cjHfSq5IF4hkQ6gYaj9TJ4j7KcsnRO+r80E+5p4qMFdCpzPQQoftMtw/ag== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.16 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 4B25D172D9 X-Spam-Score: -1.16 X-Migadu-Scanner: scn1.migadu.com X-TUID: foBDVdjTSOjW --- emacs/notmuch-query.el | 4 +++- emacs/notmuch-show.el | 11 +++++++++++ test/T450-emacs-show.sh | 12 ++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el index 5c7f4f8d..865e3ccf 100644 --- a/emacs/notmuch-query.el +++ b/emacs/notmuch-query.el @@ -25,7 +25,7 @@ ;;; Basic query function -(defun notmuch-query-get-threads (search-terms) +(defun notmuch-query-get-threads (search-terms &optional duplicate) "Return a list of threads of messages matching SEARCH-TERMS. A thread is a forest or list of trees. A tree is a two element @@ -34,6 +34,8 @@ is a possibly empty forest of replies." (let ((args '("show" "--format=sexp" "--format-version=5"))) (when notmuch-show-process-crypto (setq args (append args '("--decrypt=true")))) + (when duplicate + (setq args (append args (list (format "--duplicate=%d" duplicate))))) (setq args (append args search-terms)) (apply #'notmuch-call-notmuch-sexp args))) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 203ca7f0..833543b0 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1082,6 +1082,17 @@ is t, hide the part initially and show the button." (defvar notmuch-show-previous-subject "") (make-variable-buffer-local 'notmuch-show-previous-subject) +(defun notmuch-show-replace-msg (duplicate) + (interactive "Nduplicate: ") + (save-excursion + (let* ((extent (notmuch-show-message-extent)) + (id (notmuch-show-get-message-id)) + (depth (notmuch-show-get-depth)) + (inhibit-read-only t) + (new-msg (notmuch-query-get-threads (list id) duplicate))) + (delete-region (car extent) (cdr extent)) + (notmuch-show-insert-msg new-msg depth)))) + (defun notmuch-show-insert-msg (msg depth) "Insert the message MSG at depth DEPTH in the current thread." (let* ((headers (plist-get msg :headers)) diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh index 678efd8b..6141873d 100755 --- a/test/T450-emacs-show.sh +++ b/test/T450-emacs-show.sh @@ -271,4 +271,16 @@ when we detect the word "attachment" and there's no attach? :p EOF test_expect_equal_file EXPECTED OUTPUT +add_email_corpus duplicate + +ID3=87r2ecrr6x.fsf@zephyr.silentflame.com +test_begin_subtest "duplicate=3" +test_emacs "(notmuch-show \"id:${ID3}\") + (notmuch-show-replace-msg 3) + (test-visible-output \"OUTPUT\")" +output=$(grep "Subject:" OUTPUT) +file=$(notmuch search --output=files id:${ID3} | head -n 3 | tail -n 1) +subject=$(grep '^Subject:' $file) +test_expect_equal "$output" "$subject" + test_done -- 2.35.2