]> granicus.if.org Git - clang/commitdiff
Fix scrolling bug in clang-format's emacs integration.
authorDaniel Jasper <djasper@google.com>
Thu, 25 Apr 2013 07:06:48 +0000 (07:06 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 25 Apr 2013 07:06:48 +0000 (07:06 +0000)
This patch ensure that nothing scrolls even if the same buffer is opened
in multiple windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180252 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-format/clang-format.el

index d58e40358bed305eb31a608d8964776e317581e3..70504c9f3c0842ee5ef0ef16df4604edc2410e42 100644 (file)
 ;; 'style' and 'binary' below.
 (defun clang-format-region ()
   (interactive)
-  (let ((orig-window-start (window-start))
-        (orig-point (point))
-        (binary "clang-format")
-        (style "LLVM"))
+
+  (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"))
     (if mark-active
         (setq beg (region-beginning)
               end (region-end))
@@ -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)))))