[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 903fb9e 216/495: Cancel narrowing before gofmt
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 903fb9e 216/495: Cancel narrowing before gofmt |
Date: |
Sat, 7 Aug 2021 09:05:17 -0400 (EDT) |
branch: elpa/go-mode
commit 903fb9e997166f2f1a23377a79fefe5ca49e830b
Author: Rui Ueyama <ruiu@google.com>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
Cancel narrowing before gofmt
Previously gofmt would mess up your buffer if you run
it while your buffer is being narrowed. This patch fixes
the issue.
---
go-mode.el | 50 ++++++++++++++++++++++++++------------------------
1 file changed, 26 insertions(+), 24 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index 0cf2855..af36149 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -689,30 +689,32 @@ buffer."
(coding-system-for-read 'utf-8)
(coding-system-for-write 'utf-8))
- (with-current-buffer errbuf
- (setq buffer-read-only nil)
- (erase-buffer))
- (with-current-buffer patchbuf
- (erase-buffer))
-
- (write-region nil nil tmpfile)
-
- ;; We're using errbuf for the mixed stdout and stderr output. This
- ;; is not an issue because gofmt -w does not produce any stdout
- ;; output in case of success.
- (if (zerop (call-process gofmt-command nil errbuf nil "-w" tmpfile))
- (if (zerop (call-process-region (point-min) (point-max) "diff" nil
patchbuf nil "-n" "-" tmpfile))
- (progn
- (kill-buffer errbuf)
- (message "Buffer is already gofmted"))
- (go--apply-rcs-patch patchbuf)
- (kill-buffer errbuf)
- (message "Applied gofmt"))
- (message "Could not apply gofmt. Check errors for details")
- (gofmt--process-errors (buffer-file-name) tmpfile errbuf))
-
- (kill-buffer patchbuf)
- (delete-file tmpfile)))
+ (save-restriction
+ (widen)
+ (with-current-buffer errbuf
+ (setq buffer-read-only nil)
+ (erase-buffer))
+ (with-current-buffer patchbuf
+ (erase-buffer))
+
+ (write-region nil nil tmpfile)
+
+ ;; We're using errbuf for the mixed stdout and stderr output. This
+ ;; is not an issue because gofmt -w does not produce any stdout
+ ;; output in case of success.
+ (if (zerop (call-process gofmt-command nil errbuf nil "-w" tmpfile))
+ (if (zerop (call-process-region (point-min) (point-max) "diff" nil
patchbuf nil "-n" "-" tmpfile))
+ (progn
+ (kill-buffer errbuf)
+ (message "Buffer is already gofmted"))
+ (go--apply-rcs-patch patchbuf)
+ (kill-buffer errbuf)
+ (message "Applied gofmt"))
+ (message "Could not apply gofmt. Check errors for details")
+ (gofmt--process-errors (buffer-file-name) tmpfile errbuf))
+
+ (kill-buffer patchbuf)
+ (delete-file tmpfile))))
(defun gofmt--process-errors (filename tmpfile errbuf)
- [nongnu] elpa/go-mode 9d0732c 201/495: refactor godef error handling, (continued)
- [nongnu] elpa/go-mode 9d0732c 201/495: refactor godef error handling, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f664cff 197/495: correctly fontify methods when go-fontify-function-calls is nil, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 10281b7 202/495: add godoc-at-point, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6ed8eec 206/495: style adjustments as per CL 106010043, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 0e030ef 207/495: style adjustment, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b626ee9 213/495: readd link to gocode in README, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 541e559 212/495: when parsing GOPATH, split on the platform-specific path separator, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 40b55e3 211/495: improve README, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e639832 208/495: add documentation for godoc-at-point, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7e22639 215/495: remove LEGAL, treat this repository as a mirror of misc/emacs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 903fb9e 216/495: Cancel narrowing before gofmt,
ELPA Syncer <=
- [nongnu] elpa/go-mode 21cba0e 220/495: add gofmt-show-errors option, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 731b93c 152/495: godef: instead of printing just the first line of a definition, print all, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6e1d5ea 162/495: bump version, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 5a58bda 149/495: bump version, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a55aa42 168/495: add pledgie to the readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 115b2eb 171/495: add go-coverage to readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b0d4379 175/495: fix for eea3ccf, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2089798 200/495: ignore backquote in comment or string, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6b5fe38 204/495: write our own implementation of go--delete-whole-line, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 1319be5 210/495: simplify godoc-at-point, ELPA Syncer, 2021/08/07