Hi Folks, For reference, the current CMake indentation style is:
https://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style but with 2 space indentation instead of 4 as shown on that page. The style was popular when CMake started (year 2000) but is not very widely used anymore. For Emacs, see attached file (that comes from VTK folks that also use the style. For Vim one can use something like: set tabstop=2 shiftwidth=2 expandtab set cindent cinoptions={1s,l1,g0,c0,t0,(0,W1s Since the style is not very popular anymore I don't know whether other editors can be configured for it. For this reason I've been thinking about proposing use of clang-format for a while. We could also consider switching to a more widely-used indentation style outright and using clang-format to define it formally. On 11/17/2015 04:29 PM, Daniel Pfeifer wrote: > On Tue, Nov 17, 2015 at 10:12 PM, Robert Dailey wrote: >> How did you guys want to approach reformatting inconsistently >> formatted source files? > > I would say: As a byproduct. > > Adding a .clang-format file to CMake would be greatly appreciated. It > can be used to ensure that refactorings and new contributions follow > exactly the predefined style. However, changing existing code simply > because it does not match the style is something that should be > refused. I think we could do a one-shot conversion of existing sources. This was done in our CMakeLists.txt and *.cmake files a while ago to update capitalization style. We recorded the commit as done by a robot user instead of a specific developer's name. It is not that hard to re-invoke `git blame` to see past any blame poisoning such a commit might introduce. For that cost, we gain consistency in the code and simplicity for patches. -Brad
(require 'cc-mode) ; Indent code within block by c-basic-offset only if in column 0 (defun vtk-c-defun-block-intro (dummy) (save-excursion (back-to-indentation) (if (= (save-excursion (re-search-backward "{" 1) (current-column)) 0) c-basic-offset 0))) ; Don't indent code inside a namespace. (defun vtk-c-innamespace (dummy) (save-excursion (back-to-indentation) (if (= (save-excursion (re-search-backward "{" 1) (current-column)) 0) 0 c-basic-offset))) ; Hold the VTK indentation style. (defvar vtk-c-style '((c-backslash-column . 78) (c-basic-offset . 2) (c-comment-only-line-offset . (0 . 0)) (c-offsets-alist . ((substatement-open . +) (statement-block-intro . 0) (statement-case-open . +) (case-label . 0) (defun-block-intro vtk-c-defun-block-intro) (statement-block-intro vtk-c-defun-block-intro) (innamespace vtk-c-innamespace) )) (c-tab-always-indent . t) ) "VTK Indentation Style") (c-add-style "vtk" vtk-c-style) (provide 'vtk-c-style)
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers