lewang / ws-butler

Unobtrusively trim extraneous white-space *ONLY* in lines edited.
242 stars 26 forks source link

Undo data corrupted #39

Closed dcolascione closed 3 years ago

dcolascione commented 3 years ago

Modifying buffer text using with-silent-modifications can corrupt undo data. Let's preserve the modification flag this way instead.

diff --git a/ws-butler/ws-butler.el b/ws-butler/ws-butler.el
index 997a48e7fd..2afed1aeac 100644
--- a/ws-butler/ws-butler.el
+++ b/ws-butler/ws-butler.el
@@ -263,7 +263,7 @@ ensure point doesn't jump due to white space trimming."
   (ws-butler-clear-properties)
   ;; go to saved line+col
   (when ws-butler-presave-coord
-    (with-silent-modifications
+    (progn
       (let (remaining-lines)
         (ws-butler-with-save
          (widen)
@@ -273,7 +273,8 @@ ensure point doesn't jump due to white space trimming."
           (insert (make-string remaining-lines ?\n))))
       (move-to-column (cadr ws-butler-presave-coord))
       (when (< (current-column) (cadr ws-butler-presave-coord))
-        (insert (caddr ws-butler-presave-coord))))))
+        (insert (caddr ws-butler-presave-coord)))
+      (set-buffer-modified-p nil))))

 (defun ws-butler-before-revert ()
   "Clear `ws-butler-presave-coord'."
lewang commented 3 years ago

Wasn't this done here https://github.com/lewang/ws-butler/pull/37 ?

dcolascione commented 3 years ago

Huh, that's weird. I thought I was looking at the latest tree, but I guess I wasn't. Sorry for the noise.