Fix scrolling bug in clang-format's emacs integration.

This patch ensure that nothing scrolls even if the same buffer is opened
in multiple windows.

llvm-svn: 180252
This commit is contained in:
Daniel Jasper 2013-04-25 07:06:48 +00:00
parent a05bbe1c9a
commit a04337e22b
1 changed files with 9 additions and 5 deletions

View File

@ -10,7 +10,9 @@
;; 'style' and 'binary' below.
(defun clang-format-region ()
(interactive)
(let ((orig-window-start (window-start))
(let* ((orig-windows (get-buffer-window-list (current-buffer)))
(orig-window-starts (mapcar #'window-start orig-windows))
(orig-point (point))
(binary "clang-format")
(style "LLVM"))
@ -24,4 +26,6 @@
"-length" (number-to-string (- end beg))
"-style" style)
(goto-char orig-point)
(set-window-start (selected-window) orig-window-start)))
(dotimes (index (length orig-windows))
(set-window-start (nth index orig-windows)
(nth index orig-window-starts)))))