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 yBcvLd6vr2LyRgAAbAwnHQ (envelope-from ) for ; Mon, 20 Jun 2022 01:23:10 +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 cD8PLd6vr2J6OwEA9RJhRA (envelope-from ) for ; Mon, 20 Jun 2022 01:23:10 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 7FC6A3F8E9 for ; Mon, 20 Jun 2022 01:23:10 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id B11B45F7CA; Sun, 19 Jun 2022 23:22:43 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 72CAC5F6B8 for ; Sun, 19 Jun 2022 23:22:41 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id A8BFF5FC1F; Sun, 19 Jun 2022 19:22:40 -0400 (EDT) Received: (nullmailer pid 847108 invoked by uid 1000); Sun, 19 Jun 2022 23:22:33 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [RFC PATCH v2 6/7] WIP/emacs: replace message with different duplicate Date: Sun, 19 Jun 2022 20:21:52 -0300 Message-Id: <20220619232152.846823-7-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220619232152.846823-1-david@tethera.net> References: <20220619232152.846823-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 7NMMDM76TMYPCVAQSLFH7R43KPXCXOYW X-Message-ID-Hash: 7NMMDM76TMYPCVAQSLFH7R43KPXCXOYW 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=1655680990; 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=epVeIClQq36mVTAsMnlrIXmPY5TILwQRt86ymczRKHg=; b=NRHC4a1YcvGwKLkWSKik+qg3nBGyHeJoJwDjVJzEEKEjAPWSokx//6BT8SazWYWCNddEuo Ufzd+lO15h56Osi84YThNpGrDw+fh7gHUK7rDgEzi4Os3UXQ6O+EaDOof14rw8MtfSHQnH oIhmbpiEjLgbSaYDcuTk03J/rkhATKcXoTJtiznFWnSnTlM3OwC5xBG/gDfYZXQ+6WmHgu ZJoN/5AiYVkVZeiAwpGJEsrGZx+wTqUHrot9GSD9N70uE0IrjEpVXBW6D2moCcVtjJTZI6 uGEMEmd3C4/R63MmX8xkdpjj1820ykwTVNSN7bNiwcYJDKHDQcum6v1RIzzK4A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655680990; a=rsa-sha256; cv=none; b=DgE3MZnKhUoNdnm1h99CqabVsZRNSy0k4Mtm6DABJdsP33xkfbLLowqG03eRMt7gZ3tqrI Pc1nubqgspbVwYzfeWbWVeTQw2MLu3u4kv7DebR6R9oIDv8xQRibTPXY3CxJbkopwcq1TI WNzhvUVc2ggRPENFEwB0WG4Cp8iufBWGpbIE9s9obvetPejWiL/i42CrOJVxfAlbNoOjNT Pxjtglc1PeIu1gdPJj1lAWuYLFUFtGrCJq9LRj58OW5Ux5RbxQDS1mV/IR9Uu0WOlJZSZN HbNk3WSRiepNipncH4wM8j0r8vCDOHjaVqoTYVTes19O49iy0Xp6bQYrYfxjJQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.62 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 7FC6A3F8E9 X-Spam-Score: -1.62 X-Migadu-Scanner: scn0.migadu.com X-TUID: vpYrXw3IywM9 --- devel/emacs-keybindings.org | 1 + emacs/notmuch-query.el | 4 +++- emacs/notmuch-show.el | 20 ++++++++++++++++++++ test/T450-emacs-show.sh | 12 ++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/devel/emacs-keybindings.org b/devel/emacs-keybindings.org index 00977bc3..ad7f72ef 100644 --- a/devel/emacs-keybindings.org +++ b/devel/emacs-keybindings.org @@ -40,6 +40,7 @@ | Z | notmuch-tree-from-search-current-query | notmuch-tree-from-show-current-query | | | =!= | | notmuch-show-toggle-elide-non-matching | | | =#= | | notmuch-show-print-message | | +| =%= | | notmuch-show-replace-msg | | | =$= | | notmuch-show-toggle-process-crypto | | | =*= | notmuch-search-tag-all | notmuch-show-tag-all | notmuch-tree-tag-thread | | + | notmuch-search-add-tag | notmuch-show-add-tag | notmuch-tree-add-tag | 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 aded1ee7..1777756b 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1082,6 +1082,25 @@ 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))) + ;; clean up existing overlays to avoid extending them. + (dolist (o (overlays-in (car extent) (cdr extent))) + (delete-overlay o)) + ;; pretend insertion is happening at end of buffer + (narrow-to-region (point-min) (car extent)) + ;; Insert first, then delete, to avoid marker for start of next + ;; message being in same place as the start of this one. + (notmuch-show-insert-msg new-msg depth) + (widen) + (delete-region (point) (cdr extent))))) + (defun notmuch-show-insert-msg (msg depth) "Insert the message MSG at depth DEPTH in the current thread." (let* ((headers (plist-get msg :headers)) @@ -1537,6 +1556,7 @@ reset based on the original query." (define-key map "#" 'notmuch-show-print-message) (define-key map "!" 'notmuch-show-toggle-elide-non-matching) (define-key map "$" 'notmuch-show-toggle-process-crypto) + (define-key map "%" 'notmuch-show-replace-msg) (define-key map "<" 'notmuch-show-toggle-thread-indentation) (define-key map "t" 'toggle-truncate-lines) (define-key map "." 'notmuch-show-part-map) diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh index 0c1f6204..7fe58dfa 100755 --- a/test/T450-emacs-show.sh +++ b/test/T450-emacs-show.sh @@ -282,4 +282,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