mu4e-compose: make undo work across compose saves

Hide the header-separator change from the user-visible undo.
This commit is contained in:
Dirk-Jan C. Binnema 2021-11-07 11:43:17 +02:00
parent 7345edc21d
commit 6b3ee33b1a
1 changed files with 6 additions and 1 deletions

View File

@ -360,8 +360,12 @@ Message-ID."
#'mu4e~compose-after-save-hook-fn
nil t))
(defvar-local mu4e~compose-undo nil
"Remember the undo-state.")
(defun mu4e~compose-before-save-hook-fn ()
"Add the message-id if necessary and update the date."
(setq mu4e~compose-undo buffer-undo-list)
(save-excursion
(save-restriction
(message-narrow-to-headers)
@ -381,7 +385,8 @@ Message-ID."
(set-buffer-modified-p nil)
(mu4e-message "Saved (%d lines)" (count-lines (point-min) (point-max)))
;; update the file on disk -- ie., without the separator
(mu4e~proc-add (buffer-file-name))))
(mu4e~proc-add (buffer-file-name)))
(setq buffer-undo-list mu4e~compose-undo))
;;; address completion