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