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

Daniel Jasper djasper at google.com
Thu Apr 25 00:06:49 PDT 2013


Author: djasper
Date: Thu Apr 25 02:06:48 2013
New Revision: 180252

URL: http://llvm.org/viewvc/llvm-project?rev=180252&view=rev
Log:
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.

Modified:
    cfe/trunk/tools/clang-format/clang-format.el

Modified: cfe/trunk/tools/clang-format/clang-format.el
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.el?rev=180252&r1=180251&r2=180252&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format.el (original)
+++ cfe/trunk/tools/clang-format/clang-format.el Thu Apr 25 02:06:48 2013
@@ -10,10 +10,12 @@
 ;; '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)))))





More information about the cfe-commits mailing list