From d7a3ac17f9df30377edc5e8909b2ac289ad7d58e Mon Sep 17 00:00:00 2001 From: Frank Fischer Date: Fri, 11 Apr 2014 09:38:20 +0200 Subject: ensure `evil-with-undo` ends with exactly one boundary (fix #382) After using this macro `buffer-undo-list` or `evil-temporary-undo` should contain the undo information with exactly one boundary at the beginning (so that subsequent modifications do not merge with those executed within the body of `evil-with-undo`). In the old code the resulting `buffer-undo-list` might contain two boundaries (which is forbidden) if the modifications run within the body added a boundary to the beginning of `buffer-undo-list` themselves. In particular, this happens when repeating a previous modification using the dot-command, because `evil-end-undo-step` adds such a boundary. --- evil-common.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/evil-common.el b/evil-common.el index 2536afe..a9d24b6 100644 --- a/evil-common.el +++ b/evil-common.el @@ -2875,7 +2875,11 @@ is stored in `evil-temporary-undo' instead of `buffer-undo-list'." (let (buffer-undo-list) (prog1 (progn ,@body) - (setq evil-temporary-undo (cons nil buffer-undo-list)))) + (setq evil-temporary-undo buffer-undo-list) + ;; ensure evil-temporary-undo starts with exactly one undo + ;; boundary marker, i.e. nil + (unless (null (car-safe evil-temporary-undo)) + (push nil evil-temporary-undo)))) (unless (eq buffer-undo-list t) ;; undo is enabled, so update the global buffer undo list (setq buffer-undo-list -- cgit v1.0