aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Fargas <telenieko@telenieko.com>2024-03-14 15:56:49 +0100
committerDavid Bremner <david@tethera.net>2024-06-15 14:54:04 -0300
commit37c022aea000ab586ba2a7ea7bbac4292dda0dd3 (patch)
treeb79d02ff0fab89c9232831a6e30b4a05cf596b45
parent0d2a964ea3d0c466d6284dd0b693285941c28440 (diff)
Use `without-restriction` in `with-temporary-notmuch-message-buffer`
This ensures that the temporary copy of the current message-mode buffer is whole and not limited by a current restriction. An example of such restriction is the default one established by message-mode when composing a reply, that hides the References, In-Reply-To and similar headers.
-rw-r--r--emacs/notmuch-maildir-fcc.el17
-rwxr-xr-xtest/T630-emacs-draft.sh32
2 files changed, 41 insertions, 8 deletions
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 51020788..cf50e855 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -145,14 +145,15 @@ Otherwise set it according to `notmuch-fcc-dirs'."
(defmacro with-temporary-notmuch-message-buffer (&rest body)
"Set-up a temporary copy of the current message-mode buffer."
- `(let ((case-fold-search t)
- (buf (current-buffer))
- (mml-externalize-attachments message-fcc-externalize-attachments))
- (with-current-buffer (get-buffer-create " *message temp*")
- (message-clone-locals buf) ;; for message-encoded-mail-cache
- (erase-buffer)
- (insert-buffer-substring buf)
- ,@body)))
+ `(without-restriction
+ (let ((case-fold-search t)
+ (buf (current-buffer))
+ (mml-externalize-attachments message-fcc-externalize-attachments))
+ (with-current-buffer (get-buffer-create " *message temp*")
+ (message-clone-locals buf) ;; for message-encoded-mail-cache
+ (erase-buffer)
+ (insert-buffer-substring buf)
+ ,@body))))
(defun notmuch-maildir-setup-message-for-saving ()
"Setup message for saving.
diff --git a/test/T630-emacs-draft.sh b/test/T630-emacs-draft.sh
index c443f417..1fad58a8 100755
--- a/test/T630-emacs-draft.sh
+++ b/test/T630-emacs-draft.sh
@@ -71,4 +71,36 @@ Fcc: MAIL_DIR/sent
<#secure method=pgpmime mode=sign>
EOF
test_expect_equal_file EXPECTED OUTPUT.clean
+
+add_email_corpus attachment
+test_begin_subtest "Saving a draft keeps hidden headers"
+test_emacs '(notmuch-mua-new-reply "id:874llc2bkp.fsf@curie.anarc.at")
+ (message-goto-subject)
+ (delete-line)
+ (insert "Subject: draft-test-reply\n")
+ (test-output "DRAFT")
+ (notmuch-draft-postpone)
+ (notmuch-show "subject:draft-test-reply")
+ (notmuch-show-resume-message)
+ (test-output)'
+notmuch_dir_sanitize OUTPUT > OUTPUT.clean
+
+cat <<EOF > EXPECTED
+References: <87d10042pu.fsf@curie.anarc.at> <87woy8vx7i.fsf@tesseract.cs.unb.ca> <87a7v42bv9.fsf@curie.anarc.at> <874llc2bkp.fsf@curie.anarc.at>
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+To: Antoine Beaupré <anarcat@orangeseeds.org>
+Subject: draft-test-reply
+In-Reply-To: <874llc2bkp.fsf@curie.anarc.at>
+Fcc: MAIL_DIR/sent
+--text follows this line--
+Antoine Beaupré <anarcat@orangeseeds.org> writes:
+
+> And obviously I forget the frigging attachment.
+>
+>
+> PS: don't we have a "you forgot to actually attach the damn file" plugin
+> when we detect the word "attachment" and there's no attach? :p
+EOF
+test_expect_equal_file EXPECTED OUTPUT.clean
+
test_done