]> git.cworth.org Git - notmuch/commitdiff
emacs/reply: reply to correct duplicate
authorDavid Bremner <david@tethera.net>
Fri, 1 Jul 2022 21:45:48 +0000 (18:45 -0300)
committerDavid Bremner <david@tethera.net>
Sat, 30 Jul 2022 11:46:22 +0000 (08:46 -0300)
Essentially we just need to arrange to pass the right --duplicate
argument to notmuch reply.

As a side-effect, correct the previously unused value of EXPECTED in
T453-emacs-reply.sh.

emacs/notmuch-mua.el
emacs/notmuch-show.el
test/T453-emacs-reply.sh
test/emacs-reply.expected-output/notmuch-reply-duplicate-4 [new file with mode: 0644]

index 0f9ef3c22c7152b89d0c87a0703267a57806a709..ac878a619d07e7c4947f1c359b9d6825580516b6 100644 (file)
@@ -237,11 +237,12 @@ Typically this is added to `notmuch-mua-send-hook'."
 
 ;;; Mua reply
 
-(defun notmuch-mua-reply (query-string &optional sender reply-all)
-  (let ((args '("reply" "--format=sexp" "--format-version=5"))
-       (process-crypto notmuch-show-process-crypto)
-       reply
-       original)
+(defun notmuch-mua-reply (query-string &optional sender reply-all duplicate)
+  (let* ((duparg (and duplicate (list (format "--duplicate=%d" duplicate))))
+        (args `("reply" "--format=sexp" "--format-version=5" ,@duparg))
+        (process-crypto notmuch-show-process-crypto)
+        reply
+        original)
     (when process-crypto
       (setq args (append args '("--decrypt=true"))))
     (if reply-all
@@ -540,12 +541,13 @@ the From: address."
       (message-hide-headers)
       (set-buffer-modified-p nil))))
 
-(defun notmuch-mua-new-reply (query-string &optional prompt-for-sender reply-all)
+(defun notmuch-mua-new-reply (query-string &optional prompt-for-sender reply-all duplicate)
   "Compose a reply to the message identified by QUERY-STRING.
 
 If PROMPT-FOR-SENDER is non-nil, the user will be prompted for
 the From: address first.  If REPLY-ALL is non-nil, the message
-will be addressed to all recipients of the source message."
+will be addressed to all recipients of the source message.  If
+DUPLICATE is non-nil, based the reply on that duplicate file"
   ;; `select-active-regions' is t by default. The reply insertion code
   ;; sets the region to the quoted message to make it easy to delete
   ;; (kill-region or C-w). These two things combine to put the quoted
@@ -560,7 +562,7 @@ will be addressed to all recipients of the source message."
   (let ((sender (and prompt-for-sender
                     (notmuch-mua-prompt-for-sender)))
        (select-active-regions nil))
-    (notmuch-mua-reply query-string sender reply-all)
+    (notmuch-mua-reply query-string sender reply-all duplicate)
     (deactivate-mark)))
 
 ;;; Checks
index 0d9bf0710d4c58d369f7674e4533279824baea78..1bc3b3196ecdf8331fbee59d83c3058db4fae1d8 100644 (file)
@@ -2020,13 +2020,15 @@ any effects from previous calls to
 (defun notmuch-show-reply (&optional prompt-for-sender)
   "Reply to the sender and all recipients of the current message."
   (interactive "P")
-  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender t))
+  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender t
+                        (notmuch-show-get-prop :duplicate)))
 
 (put 'notmuch-show-reply-sender 'notmuch-prefix-doc "... and prompt for sender")
 (defun notmuch-show-reply-sender (&optional prompt-for-sender)
   "Reply to the sender of the current message."
   (interactive "P")
-  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender nil))
+  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender nil
+                        (notmuch-show-get-prop :duplicate)))
 
 (put 'notmuch-show-forward-message 'notmuch-prefix-doc
      "... and prompt for sender")
index c26c4473019ca8a6d47f3d2191e5157c5a975792..0a27d0661ae29d8033a0285fbb448279d3790201 100755 (executable)
@@ -4,7 +4,7 @@ test_description="emacs reply"
 . $(dirname "$0")/test-lib.sh || exit 1
 . $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
 
-EXPECTED=$NOTMUCH_SRCDIR/test/emacs-show.expected-output
+EXPECTED=$NOTMUCH_SRCDIR/test/emacs-reply.expected-output
 
 test_require_emacs
 
@@ -31,4 +31,41 @@ EOF
 notmuch_dir_sanitize < OUTPUT.raw > OUTPUT
 test_expect_equal_file EXPECTED OUTPUT
 
+add_email_corpus duplicate
+
+ID2=87r2geywh9.fsf@tethera.net
+for dup in {1..2}; do
+    test_begin_subtest "body, duplicate=${dup}"
+    test_emacs "(notmuch-show \"id:${ID2}\")
+          (notmuch-test-wait)
+          (notmuch-show-choose-duplicate $dup)
+          (notmuch-test-wait)
+          (notmuch-show-reply)
+          (test-visible-output \"OUTPUT.raw\")"
+    output=$(grep '^> # body' OUTPUT.raw)
+    test_expect_equal "$output" "> # body ${dup}"
+done
+
+ID3=87r2ecrr6x.fsf@zephyr.silentflame.com
+test_begin_subtest "duplicate=3, subject"
+test_emacs "(notmuch-show \"id:${ID3}\")
+          (notmuch-test-wait)
+          (notmuch-show-choose-duplicate 3)
+          (notmuch-test-wait)
+          (notmuch-show-reply)
+          (test-visible-output \"OUTPUT\")"
+output=$(sed -n 's/^Subject: //p' OUTPUT)
+file=$(notmuch search --output=files id:${ID3} | head -n 3 | tail -n 1)
+subject=$(sed -n 's/^Subject: //p' $file)
+test_expect_equal "$output" "Re: $subject"
+
+test_begin_subtest "duplicate=4"
+test_emacs "(notmuch-show \"id:${ID3}\")
+          (notmuch-show-choose-duplicate 4)
+          (notmuch-test-wait)
+          (notmuch-show-reply)
+          (test-visible-output \"OUTPUT.raw\")"
+notmuch_dir_sanitize < OUTPUT.raw > OUTPUT
+test_expect_equal_file_nonempty $EXPECTED/notmuch-reply-duplicate-4 OUTPUT
+
 test_done
diff --git a/test/emacs-reply.expected-output/notmuch-reply-duplicate-4 b/test/emacs-reply.expected-output/notmuch-reply-duplicate-4
new file mode 100644 (file)
index 0000000..836f77b
--- /dev/null
@@ -0,0 +1,21 @@
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+To: Sean Whitton <spwhitton@spwhitton.name>, 916811@bugs.debian.org, 916805@bugs.debian.org, 916807@bugs.debian.org, 916808@bugs.debian.org, 916809@bugs.debian.org, 916811@bugs.debian.org, 916867@bugs.debian.org, 916869@bugs.debian.org, 916872@bugs.debian.org, 916875@bugs.debian.org, 916876@bugs.debian.org
+Subject: Re: [Pkg-emacsen-addons] Bug#916811: Increase severity to 'serious'
+In-Reply-To: <87r2ecrr6x.fsf@zephyr.silentflame.com>
+Fcc: MAIL_DIR/sent
+--text follows this line--
+Sean Whitton <spwhitton@spwhitton.name> writes:
+
+> control: severity -1 serious
+>
+> Hello,
+>
+> Emacs 26.1 has reached Debian unstable (sooner than expected; sorry for
+> all the e-mails).
+>
+> -- 
+> Sean Whitton
+> _______________________________________________
+> Pkg-emacsen-addons mailing list
+> Pkg-emacsen-addons@alioth-lists.debian.net
+> https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-emacsen-addons