C: Disable undo while uncrustify formats the buffer

master
Pierre Neidhardt 2018-12-03 23:03:57 +01:00
parent 49d8dee6d3
commit 497e44386f
1 changed files with 3 additions and 1 deletions

View File

@ -121,6 +121,7 @@ If the command is not `make', run it normally. "
(old-column (current-column))
(old-window-start-line (- (line-number-at-pos)
(line-number-at-pos (window-start)))))
(buffer-disable-undo)
(save-mark-and-excursion
(delete-region (or start (point-min)) (or end (point-max)))
(insert-buffer-substring formatbuf))
@ -128,7 +129,8 @@ If the command is not `make', run it normally. "
(move-to-column old-column)
(ignore-errors
;; recenter won't work if selected window is not the target buffer.
(recenter old-window-start-line)))
(recenter old-window-start-line))
(buffer-enable-undo))
(kill-buffer formatbuf)))
;; Return nil if in a `write-file-functions'.
nil)