Re: notmuch.el, needs without-restriction to properly save draft

2024-06-17 Thread David Bremner
Marc Fargas  writes:

> Hi,
>
> El lun. 17 de jun. 2024, Marc escribió:
>>
>> El lun. 17 de jun. 2024, Michael escribió:
 (...)
>>>
>>> Does this depend on emacs version by any chance, i.e. is
>>> `without-restriction` defined on all emacsen? In Fedora's copr
>>> infrastructure, all builds succeed but some tests fail with
>>> `Symbol'€™s function definition is void: without-restriction`. The
>>> picture is the following:
>
> So, I will have to update the patch in order to make the use of
> `without-restriction` conditional on its availability.
>
> I asked on Emacs chat @ Matrix on how to do this nicely and yantar92
> (org contributor) proposed the following macro:
>
>(defmacro notmuch--without-restriction (&rest body)
>  "Run BODY within `without-restriction', when it is available."
>  (declare (debug (body)))
>  (if (fboundp 'without-restriction)
>  `(without-restriction ,@body)
>`(progn ,@body)))

Assuming fboundp works for macros (without-restriction is a macro), then
sure
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-06-17 Thread Marc Fargas
Hi,

El lun. 17 de jun. 2024, Marc escribió:
>
> El lun. 17 de jun. 2024, Michael escribió:
>>> (...)
>>
>> Does this depend on emacs version by any chance, i.e. is
>> `without-restriction` defined on all emacsen? In Fedora's copr
>> infrastructure, all builds succeed but some tests fail with
>> `Symbol'€™s function definition is void: without-restriction`. The
>> picture is the following:

So, I will have to update the patch in order to make the use of
`without-restriction` conditional on its availability.

I asked on Emacs chat @ Matrix on how to do this nicely and yantar92
(org contributor) proposed the following macro:

   (defmacro notmuch--without-restriction (&rest body)
 "Run BODY within `without-restriction', when it is available."
 (declare (debug (body)))
 (if (fboundp 'without-restriction)
 `(without-restriction ,@body)
   `(progn ,@body)))

David, would such solution be OK? If so I'll prepare a new patch.

Marc
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-06-17 Thread Marc Fargas
Hi,

El lun. 17 de jun. 2024, Michael escribió:
>> (...)
>
> Does this depend on emacs version by any chance, i.e. is
> `without-restriction` defined on all emacsen? In Fedora's copr
> infrastructure, all builds succeed but some tests fail with
> `Symbol'€™s function definition is void: without-restriction`. The
> picture is the following:

Apparently it was introduced in Emacs 29[1]. Strange that tests pass at
all on previous versions.

What is the earliest Emacs version supported by notmuch? I can't find
any specific version in notmuch documentation.

The patch could be updated to only use without-restriction when
available, of course.

marc

[1]: 
https://github.com/emacs-mirror/emacs/blob/7be66d8223e49489b2803c0ff027f1824d774441/etc/NEWS.29#L3512
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-06-17 Thread David Bremner
David Bremner  writes:

> Marc Fargas  writes:
>
>> Hi,
>>
>> El lun. 17 de jun. 2024, Michael escribió:
 (...)
>>>
>>> Does this depend on emacs version by any chance, i.e. is
>>> `without-restriction` defined on all emacsen? In Fedora's copr
>>> infrastructure, all builds succeed but some tests fail with
>>> `Symbol'€™s function definition is void: without-restriction`. The
>>> picture is the following:
>>
>> Apparently it was introduced in Emacs 29[1]. Strange that tests pass at
>> all on previous versions.
>>
>> What is the earliest Emacs version supported by notmuch? I can't find
>> any specific version in notmuch documentation.
>
> According to the docs, it is supposed to work with 25.1. Personally I
> would be fine updating this to 26.x or 27.x, but of course that won't
> help you here.

Using "docs", loosly here. This is the most recent announcement in NEWS,
which matches emacs/notmuch-pkg.el.tmpl
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-06-17 Thread David Bremner
Marc Fargas  writes:

> Hi,
>
> El lun. 17 de jun. 2024, Michael escribió:
>>> (...)
>>
>> Does this depend on emacs version by any chance, i.e. is
>> `without-restriction` defined on all emacsen? In Fedora's copr
>> infrastructure, all builds succeed but some tests fail with
>> `Symbol'€™s function definition is void: without-restriction`. The
>> picture is the following:
>
> Apparently it was introduced in Emacs 29[1]. Strange that tests pass at
> all on previous versions.
>
> What is the earliest Emacs version supported by notmuch? I can't find
> any specific version in notmuch documentation.

According to the docs, it is supposed to work with 25.1. Personally I
would be fine updating this to 26.x or 27.x, but of course that won't
help you here.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-06-17 Thread Michael J Gruber
Am Sa., 15. Juni 2024 um 19:57 Uhr schrieb David Bremner :
>
> Marc Fargas  writes:
>
> > 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.
>
> Applied to master. Sorry for the long-ish silence.
>

Does this depend on emacs version by any chance, i.e. is
`without-restriction` defined on all emacsen? In Fedora's copr
infrastructure, all builds succeed but some tests fail with
`Symbol'€™s function definition is void: without-restriction`. The
picture is the following:

PASS:
centos-stream+epel-next-8 with emacs 26.1-11.el8
rhel+epel-8 with emacs 26.1-11.el8
fedora-39 with emacs 29.3-1.fc39
(plus all newer fedoras)

FAIL:
centos-stream+epel-next-9 with emacs 27.2-9.el9
rhel+epel-9 with emacs 27.2-9.el9

Yes, RHEL 8 is EOled.

I find it strange that tests pass on both emacs 26 and 29 but not
27.2. But said code path is not executed on emacs 26 at all?

The failing 42 tests are mostly around json and crypto, but not all.

Cheers
Michael
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-06-15 Thread David Bremner
Marc Fargas  writes:

> 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.

Applied to master. Sorry for the long-ish silence.

d
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-04-04 Thread Marc Fargas
Hi all,

El dom. 24 de mar. 2024, Marc escribió:
> 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!

Following up on this, has anyone had a chance to review the proposed
patch (the one including tests)?

Let me know if there's anything else I can do to get the fix into
notmuch!

Marc
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-03-24 Thread Marc Fargas
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

>From 77e8a775571458962ff11af549d1a0428a17435e Mon Sep 17 00:00:00 2001
From: Marc Fargas 
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@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 < EXPECTED
+References: <87d10042pu@curie.anarc.at> <87woy8vx7i@tesseract.cs.unb.ca> <87a7v42bv9@curie.anarc.at> <874llc2bkp@curie.anarc.at>
+From: Notmuch Test Suite 
+To: Antoine Beaupré 
+Subject: draft-test-reply
+In-Reply-To: <874llc2bkp@curie.anarc.at>
+Fcc: MAIL_DIR/sent
+--text follows this line--
+Antoine Beaupré  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

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-03-24 Thread Marc Fargas
Hello,

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.

marc

>From 48efd572e6b8e6d214fc8b4e7b28f001fc13345a Mon Sep 17 00:00:00 2001
From: Marc Fargas 
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 +
 1 file changed, 9 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.
-- 
2.44.0

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-03-24 Thread Marc Fargas
Hello,

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.

marc

PS: Resent while properly attaching the patch file (I hope, and
apologies).
>From 48efd572e6b8e6d214fc8b4e7b28f001fc13345a Mon Sep 17 00:00:00 2001
From: Marc Fargas 
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 +
 1 file changed, 9 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.
-- 
2.44.0

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: notmuch.el, needs without-restriction to properly save draft

2024-03-13 Thread Carl Worth
On Wed, Mar 13 2024, Marc Fargas wrote:
> Hi there,

Hi, Marc!

> I'm not sure if this is the appropiate mailing list for bugs regarding
> notmuch.el (Notmuch in Emacs). Also, I'm not subscribed so please keep
> me in CC!

Yes, this is a fine place to report things

> I recently noticed that when saving drafts in notmuch I would loose all
> the headers that are not normally visible on the compose
> buffer. References, In-Reply-To and the likes.

Thanks for the bug report, as well as the fix you provided. I haven't
run it, but it looks totally reasonable.

> Note that when resuming the draft later on all headers will be visible,
> still working out how to restore the narrow restriction there.

That seems worth chasing down, but shouldn't prevent the acceptance of
your fix here which seems like only progress in the right direction.

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.

Thanks again,

-Carl
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


notmuch.el, needs without-restriction to properly save draft

2024-03-13 Thread Marc Fargas
Hi there,

I'm not sure if this is the appropiate mailing list for bugs regarding
notmuch.el (Notmuch in Emacs). Also, I'm not subscribed so please keep
me in CC!

I recently noticed that when saving drafts in notmuch I would loose all
the headers that are not normally visible on the compose
buffer. References, In-Reply-To and the likes.

By default, when when composing a Reply all those cool and nice headers
are narrowed out of the buffer. They show up on sending because
"message-send" will sort the headers breaking the restriction.

After digging, it seems that "(insert-buffer-substring buf)", in
"with-temporary-notmuch-message-buffer" which is used by
"notmuch-draft-save" is not seeing the buffer contents beyond the
buffer's current restriction.

Thus, "insert-buffer-substring buf" should be wrapped inside a
"without-restriction".

Doing this makes the saved draft keep all headers:

  (defun unrestrict-notmuch (orig-fn &rest args)
(without-restriction
  (apply orig-fn args)))

  (advice-add #'notmuch-draft-postpone :around #'unrestrict-notmuch)

Note that when resuming the draft later on all headers will be visible,
still working out how to restore the narrow restriction there.

marc
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org