Skip to content

Commit e106f49

Browse files
pmiddendproofit404
authored andcommitted
Use replace-buffer-contents and remove cruft (#19)
1 parent 1dd9d18 commit e106f49

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

blacken.el

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ 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))
126124
(tmpbuf (get-buffer-create "*blacken*"))
127125
(errbuf (get-buffer-create "*blacken-error*")))
128126
;; This buffer can be left after previous black invocation. It
@@ -134,10 +132,7 @@ Show black output, if black exit abnormally and DISPLAY is t."
134132
(if (not (zerop (blacken-call-bin original-buffer tmpbuf errbuf)))
135133
(error "Black failed, see %s buffer for details" (buffer-name errbuf))
136134
(unless (eq (compare-buffer-substrings tmpbuf nil nil original-buffer nil nil) 0)
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))
135+
(with-current-buffer original-buffer (replace-buffer-contents tmpbuf)))
141136
(mapc 'kill-buffer (list tmpbuf errbuf)))
142137
(error (message "%s" (error-message-string err))
143138
(when display

0 commit comments

Comments
 (0)