diff options
Diffstat (limited to 'docs/ClangFormat.rst')
-rw-r--r-- | docs/ClangFormat.rst | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/docs/ClangFormat.rst b/docs/ClangFormat.rst index 92d7fc3..964fc84 100644 --- a/docs/ClangFormat.rst +++ b/docs/ClangFormat.rst @@ -18,7 +18,6 @@ to format C/C++/Obj-C code. $ clang-format --help OVERVIEW: A tool to format C/C++/Obj-C code. - Currently supports LLVM and Google style guides. If no arguments are specified, it formats the code from standard input and writes the result to the standard output. If <file> is given, it reformats the file. If -i is specified together @@ -66,6 +65,37 @@ It operates on the current, potentially unsaved buffer and does not create or save any files. To revert a formatting, just undo. +Emacs Integration +================= + +Similar to the integration for :program:`vim`, there is an integration for +:program:`emacs`. It can be found at `clang/tools/clang-format/clang-format.el` +and used by adding this to your `.emacs`: + +.. code-block:: common-lisp + + (load "<path-to-clang>/tools/clang-format/clang-format.el") + (global-set-key [C-M-tab] 'clang-format-region) + +This binds the function `clang-format-region` to C-M-tab, which then formats the +current line or selected region. + + +BBEdit Integration +================== + +:program:`clang-format` cannot be used as a text filter with BBEdit, but works +well via a script. The AppleScript to do this integration can be found at +`clang/tools/clang-format/clang-format-bbedit.applescript`; place a copy in +`~/Library/Application Support/BBEdit/Scripts`, and edit the path within it to +point to your local copy of :program:`clang-format`. + +With this integration you can select the script from the Script menu and +:program:`clang-format` will format the selection. Note that you can rename the +menu item by renaming the script, and can assign the menu item a keyboard +shortcut in the BBEdit preferences, under Menus & Shortcuts. + + Script for patch reformatting ============================= @@ -81,7 +111,7 @@ a unified diff and reformats all contained lines with :program:`clang-format`. optional arguments: -h, --help show this help message and exit -p P strip the smallest prefix containing P slashes - -style STYLE formatting style to apply (LLVM, Google) + -style STYLE formatting style to apply (LLVM, Google, Chromium) So to reformat all the lines in the latest :program:`git` commit, just do: |