Skip to content

Commit 17b48ee

Browse files
authored
Revert "Use replace-buffer-contents and remove cruft (#19)" (#23)
This reverts commit e106f49.
1 parent e106f49 commit 17b48ee

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

blacken.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ Return black process the exit code."
121121
Show black output, if black exit abnormally and DISPLAY is t."
122122
(interactive (list t))
123123
(let* ((original-buffer (current-buffer))
124+
(original-point (point))
125+
(original-window-pos (window-start))
124126
(tmpbuf (get-buffer-create "*blacken*"))
125127
(errbuf (get-buffer-create "*blacken-error*")))
126128
;; This buffer can be left after previous black invocation. It
@@ -132,7 +134,10 @@ Show black output, if black exit abnormally and DISPLAY is t."
132134
(if (not (zerop (blacken-call-bin original-buffer tmpbuf errbuf)))
133135
(error "Black failed, see %s buffer for details" (buffer-name errbuf))
134136
(unless (eq (compare-buffer-substrings tmpbuf nil nil original-buffer nil nil) 0)
135-
(with-current-buffer original-buffer (replace-buffer-contents tmpbuf)))
137+
(with-current-buffer tmpbuf
138+
(copy-to-buffer original-buffer (point-min) (point-max)))
139+
(goto-char original-point)
140+
(set-window-start (selected-window) original-window-pos))
136141
(mapc 'kill-buffer (list tmpbuf errbuf)))
137142
(error (message "%s" (error-message-string err))
138143
(when display

0 commit comments

Comments
 (0)