From: Marc Fargas <telenieko@telenieko.com>
To: Carl Worth <cworth@cworth.org>, <notmuch@notmuchmail.org>,
<david@tethera.net>
Subject: Re: notmuch.el, needs without-restriction to properly save draft
Date: Sun, 24 Mar 2024 18:54:53 +0100 [thread overview]
Message-ID: <87wmprqzv6.fsf@marcfargas.com> (raw)
In-Reply-To: <877chrsgr4.fsf@marcfargas.com>
[-- Attachment #1: Type: text/plain, Size: 1359 bytes --]
Hi again,
El dom. 24 de mar. 2024, Marc escribió:
> El mié. 13 de mar. 2024, Carl escribió:
>> (...)
>> Could you put your fix together in the form of a git-appliable patch?
>> Such as by applying it to the notmuch source, running `git commit` and
>> then `git format-patch HEAD~` or similar.
>
> Please disregard the previous patch, consider the one attached
> here. Hope I did the "format-patch" thing properly.
>
> I had to move the `without-restriction` call to the top of the
> `with-temporary-notmuch-message-buffer` defmacro. It does work properly
> now.
I just saw on the archives that David Bremner replied to my original
patch, I have no idea why that email didn't reach me :(
David:
> Although it is significantly more work, it would be very helpful if
> you could come up with an automated test in the style of those in
> T630-emacs-draft.sh. There is one that checks for an internal header,
> so perhaps it could be modified to check for In-Reply-To?
I am attaching a new patch that includes an additional test on
T630-emacs-draft.sh.
On the test only `References` is at the top (hence hidden by emacs), not
`In-Reply-To`. I guess that does rely on some configuration.
In any case, the test reproduces the problem (lost headers on draft
save), and the patch fixes it!
Hope all is good!! :D
marc
[-- Attachment #2: 0001-Use-without-restriction-in-with-temporary-notmuch-me.patch --]
[-- Type: text/x-patch, Size: 3435 bytes --]
From 77e8a775571458962ff11af549d1a0428a17435e Mon Sep 17 00:00:00 2001
From: Marc Fargas <telenieko@telenieko.com>
Date: Thu, 14 Mar 2024 15:56:49 +0100
Subject: [PATCH] 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.
---
emacs/notmuch-maildir-fcc.el | 17 +++++++++--------
test/T630-emacs-draft.sh | 32 ++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 5102078..cf50e85 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 c443f41..1fad58a 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
--
2.44.0
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
next prev parent reply other threads:[~2024-03-24 18:01 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 16:32 notmuch.el, needs without-restriction to properly save draft Marc Fargas
2024-03-13 23:00 ` Carl Worth
2024-03-14 15:03 ` [PATCH] Use `without-restriction` in `with-temporary-notmuch-message-buffer` Marc Fargas
2024-03-15 8:33 ` Marc Fargas
2024-03-15 9:59 ` David Bremner
2024-03-24 17:04 ` notmuch.el, needs without-restriction to properly save draft Marc Fargas
2024-03-24 17:54 ` Marc Fargas [this message]
2024-04-04 11:13 ` Marc Fargas
2024-06-15 17:57 ` David Bremner
2024-06-17 9:27 ` Michael J Gruber
2024-06-17 9:53 ` Marc Fargas
2024-06-17 10:27 ` David Bremner
2024-06-17 10:29 ` David Bremner
2024-06-17 11:37 ` Marc Fargas
2024-06-17 14:04 ` [PATCH] Replace `without-restriction` with `save-restriction` michaeljgruber+grubix+git
2024-06-17 19:28 ` [PATCH v2 1/2] " michaeljgruber+grubix+git
2024-06-17 19:28 ` [PATCH v2 2/2] Replace `delete-line` with its definition michaeljgruber+grubix+git
2024-06-17 22:49 ` David Bremner
2024-06-18 5:58 ` Marc Fargas
2024-06-18 14:33 ` Michael J Gruber
2024-06-19 10:48 ` David Bremner
2024-06-17 14:28 ` notmuch.el, needs without-restriction to properly save draft David Bremner
2024-03-24 17:08 ` Marc Fargas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wmprqzv6.fsf@marcfargas.com \
--to=telenieko@telenieko.com \
--cc=cworth@cworth.org \
--cc=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).