From 6b3ee33b1a2028136b5c0001a0d9e7422c2f7231 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sun, 7 Nov 2021 11:43:17 +0200 Subject: [PATCH] mu4e-compose: make undo work across compose saves Hide the header-separator change from the user-visible undo. --- mu4e/mu4e-compose.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index d7b1478e..0a6c16e5 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -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