Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not modify the buffer if yapf provides no change. #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion yapfify.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
;; certain buffer, but more conveniently, a minor-mode 'yapf-mode' is provided
;; that turns on automatically running YAPF on a buffer before saving.
;;
;; This file is modified by Yushun Cheng on 1 Sep 2023.
;;
;; Installation:
;;
;; Add yapfify.el to your load-path.
Expand Down Expand Up @@ -86,7 +88,10 @@ If yapf exits with an error, the output will be shown in a help-window."
;; anything else would be very unexpected.
(cond ((or (eq exit-code 0) (eq exit-code 2))
(with-current-buffer tmpbuf
(copy-to-buffer original-buffer (point-min) (point-max))))
(unless (eq (compare-buffer-substrings original-buffer nil nil
nil nil nil)
0)
(copy-to-buffer original-buffer (point-min) (point-max)))))
((eq exit-code 1)
(error "Yapf failed, see %s buffer for details" (buffer-name tmpbuf))))
;; Clean up tmpbuf
Expand Down