1
0
mirror of https://github.com/golang/go synced 2024-11-22 08:04:39 -07:00

misc/emacs: Restore the window position after a successful gofmt.

This adds restoring the window position so that the buffer doesn't jump around after the erase/copy.

R=sameer
CC=golang-dev
https://golang.org/cl/5981055
This commit is contained in:
Jean-Marc Eurin 2012-05-07 11:46:01 -04:00 committed by Sameer Ajmani
parent a96a983606
commit 9d063816ef

View File

@ -757,10 +757,13 @@ Replace the current buffer on success; display errors on failure."
;; restore window config
;; gofmt succeeded: replace the current buffer with outbuf,
;; restore the mark and point, and discard errbuf.
(let ((old-mark (mark t)) (old-point (point)))
(set-window-configuration currconf)
(let ((old-mark (mark t))
(old-point (point))
(old-start (window-start)))
(erase-buffer)
(insert-buffer-substring outbuf)
(set-window-configuration currconf)
(set-window-start (selected-window) (min old-start (point-max)))
(goto-char (min old-point (point-max)))
(if old-mark (push-mark (min old-mark (point-max)) t))
(kill-buffer errbuf))