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

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

Date: Wed, 13 Mar 2024 17:32:24 +0100

To: notmuch@notmuchmail.org

Cc:

From: 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-leave@notmuchmail.org

Thread: