<div dir="ltr"><div>As I wrote earlier, I've put this in my ~/.emacs to format my C++ buffers before they're saved:<br></div><div><br></div><div>(add-hook 'c++-mode-hook</div><div>    (lambda()</div><div>        (add-hook 'before-save-hook 'clang-format-buffer)))</div><div><br></div><div>This worked fine when saving individual files with "C-x C-s".  However, I encountered a problem when using "C-x s" (save-some-buffers) where the window-start would be moved to the very first line, and the point would be moved to the left margin on the middle line in the window.  In clang-format.el, I added some debug messages to show what's happening with the calls to goto-char() and set-window-start().  What I found is that there's nothing wrong with those calls in the (save-some-buffers) case, and they are the exact same as in the case where I save the buffer individually with "C-x C-s".  Despite (clang-format-buffer) doing apparently the same thing in both cases, with (save-some-buffers) _something_ is moving window-start to the start of the file, which is not acceptable.</div><div><br></div><div>I don't see a problem with clang-format.el to be fixed, and I don't know how to proceed with this any more, so here I just wanted to give an account of my experience with this, in the hope that it could be useful.</div><div><br></div><div>What I've done to my clang-format.el for now is to remove the loop at the end of the function that restores the window-starts of the windows showing the formatted buffer.  The result of that is still is slightly disorienting because the line containing the point is centered on the screen (if possible), but it's far better than having the window-start moved to the first line.</div><div><br></div><div>Clang-formatting before save must be quite a common practice, so is anyone doing so _not_ seeing the same window-start dislocation problem with (save-some-buffers)?  If I can duplicate an emacs setup that doesn't have this problem, that would help.</div></div>