summaryrefslogtreecommitdiffstats
path: root/clang/tools/clang-format/clang-format.el
Commit message (Collapse)AuthorAgeFilesLines
* clang-format: Add a fallback style to Emacs modepaulhoad2019-11-061-0/+13
| | | | | | | | | | | | | | | | | | Summary: This allows one to enable `clang-format-buffer` on file save and avoid reformatting files that are outside of any project with .clang-format style. Reviewers: djasper, klimek, sammccall, owenpan, mitchell-stellar, MyDeveloperDay Reviewed By: MyDeveloperDay Subscribers: cfe-commits Patch By: dottedmag Tags: #clang, #clang-format Differential Revision: https://reviews.llvm.org/D69752
* [Format] Add machine-readable SPDX license ID to clang-format.elSam McCall2019-10-151-0/+1
| | | | llvm-svn: 374864
* [ClangFormat] Editor integrations inherit default style from clang-format binarySam McCall2019-05-171-3/+3
| | | | | | | | | | | | | | | | Summary: This allows downstream customizations to the default style to work without needing to also modify the editor integrations. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49719 llvm-svn: 360996
* Fix typos in clangAlexander Kornienko2018-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* Fix assume-filename handling in clang-format.elPhilipp Stephani2017-12-021-16/+29
| | | | | | | | | | | | | | | | | | | | | Summary: When 'buffer-file-name' is nil 'call-process-region' returned a segmentation fault error. This was a problem when using clang-format-buffer on an orgmode source code editing buffer. I fixed this problem by excluding the '-assume-filename' argument when 'buffer-file-name' is nil. To make it a bit more flexible I also added an optional argument, 'assume-file-name', to specify an assume-filename that overrides 'buffer-file-name'. Reviewers: klimek, djasper, phst, phi Reviewed By: phst, phi Subscribers: phi, jholewinski, mgorny, javed.absar, eraman, cfe-commits Differential Revision: https://reviews.llvm.org/D37903 llvm-svn: 319621
* Use UTF-8 for all communication with clang-formatPhilipp Stephani2017-01-201-11/+16
| | | | | | | | | | | | Summary: Instead of picking the buffer file coding system, always use utf-8-unix for communicating with clang-format. This is fine because clang-format never actually reads the file to be formatted, only standard input. This is a bit simpler (process coding system is now a constant) and potentially faster, as utf-8-unix is Emacs's internal coding system. Also add an end-to-end test that actually invokes clang-format. Reviewers: klimek Reviewed By: klimek Differential Revision: https://reviews.llvm.org/D28904 llvm-svn: 292593
* Make sure that clang-format input is in the right encodingPhilipp Stephani2017-01-171-1/+5
| | | | | | | | | | | | Summary: Add unit tests. Reviewers: klimek, massberg Reviewed By: massberg Differential Revision: https://reviews.llvm.org/D28800 llvm-svn: 292234
* Minor cleanups in clang-format.el.Manuel Klimek2016-10-041-41/+48
| | | | | | | | | | | | | | | | | | - Enable lexical binding - Formatting - Enable file name completion for the clang-format-executable variable - Add a missing docstring - When available, use bufferpos-to-filepos and filepos-to-bufferpos. These functions given more precise mapping than byte-to-position and position-bytes. - Rename arguments of clang-format-region to match the docstring - Instead of binding local variables to nil and then assigning them, bind them directly to their values - Make use of the fact that insert-file-contents returns the number of characters it inserted - Use cl-destructuring-bind to make the code a bit shorter - Use standard iteration (dolist) instead of mapc with a lambda, which is more common and shorter - Remove a message that was most likely only present for debugging purposes Patch by Philipp Stephani. llvm-svn: 283206
* clang-format: Make emacs integration work with narrowed buffers.Daniel Jasper2016-09-121-1/+1
| | | | | | | | | Use (call-process region nil ...) instead of (point-min) so that the call works in narrowed buffers. Patch by Philipp Stephani, thank you! llvm-svn: 281203
* clang-format: Enable #include sorting by default.Daniel Jasper2015-11-161-1/+0
| | | | | | | | | This has seen quite some usage and I am not aware of any issues. Also add a style option to enable/disable include sorting. The existing command line flag can from now on be used to override whatever is set in the style. llvm-svn: 253202
* clang-format: Add include sorting capabilities to sublime, emacs andDaniel Jasper2015-10-071-0/+1
| | | | | | clang-format-diff.py. llvm-svn: 249567
* Reapply r236854 and fixed r236867.Daniel Jasper2015-05-101-6/+11
| | | | | | | Makes emacs show a different message when clang-format encountered a syntax error. llvm-svn: 236943
* Revert "Make emacs show when clang-format encountered a syntax error."Tobias Grosser2015-05-081-11/+6
| | | | | | | | | | | This reverts commit 236854, which caused clang-format to always print '{ "IncompleteFormat": false }' at the top of an incompletely formatted file. This output causes problems e.g. in Polly's automatic formatting checks. Daniel tried to fix this in 236867, but this fix had to be reverted due to buildbot failures. I revert this change as well for now as it is Friday night and unlikely to be fixed immediately. llvm-svn: 236908
* Make emacs show when clang-format encountered a syntax error.Manuel Klimek2015-05-081-6/+11
| | | | | | | Propagate the 'incomplete-format' state back through clang-format's command line interace and adapt the emacs integration to show a better result. llvm-svn: 236854
* Make clang-format work in emacs buffers with unicode characters.Manuel Klimek2015-01-191-11/+16
| | | | | | | | | | Emacs functions by default use character positions; convert characters to offsets when handing parameters to clang-format and convert byte offsets we get from clang-format back to character positions. Reworked the code a bit so the 0-based to 1-based offset calculations are done in the same place where we do the multi-byte to offset mapping. llvm-svn: 226445
* Update clang-format.el to use xml output and patch in the returned chunks.Manuel Klimek2015-01-131-46/+86
| | | | | | | | | This leads to better undo behavior and avoids window content jumping around. Patch by Johann Klähn. llvm-svn: 225777
* Improve clang-format.el.Manuel Klimek2015-01-081-48/+117
| | | | | | | | | | | | - includes header/footer as required by MELPA - correctly handles buffers that are not associated with a file - displays stderr and exit code of clang-format process - customizable via the emacs customization interface and file-/directory- local variables Patch by Johann Klähn. llvm-svn: 225447
* clang-format: Make it possible to (require 'clang-format)Justin Bogner2014-11-051-0/+2
| | | | | | | This makes the emacs integration ``provide`` a clang-format feature, so that a .emacs can ``require`` it. llvm-svn: 221330
* clang-format: Add -assume-filename option for editor integrations.Daniel Jasper2013-09-131-1/+3
| | | | | | | | | | | | | | With -style=file, clang-format now starts to search for a .clang-format file starting at the file given with -assume-filename if it reads from stdin. Otherwise, it would start searching from the current directory, which is not helpful for editor integrations. Also changed vim, emacs and sublime integrations to actually make use of this flag. This fixes llvm.org/PR17072. llvm-svn: 190691
* Switch the default mode for clang-format to '-file'. Make 'LLVM' theChandler Carruth2013-09-021-1/+1
| | | | | | | | | | | | | | | | | | | fallback syntax used when we fail to find a '.clang-format' file. Adjust variable names appropriately. Update the editor integration pieces that specify a '-style' option to specify it as '-style=file'. I left the functionality in place because even if the preferred method is to use '.clang-format' files, this way if someone needs to clobber the style in their editor we show how to do so in these examples. Also check in a '.clang-format' file for Clang to ensure that separate checkouts and builds of Clang from LLVM can still get the nice formatting. =] This unfortunately required nuking the test for the absence of a '.clang-format' file as now the directory happening to be under your clang source tree will cause there to always be a file. ;] llvm-svn: 189741
* Make it possible to assign clang-format-buffer to a keybinding.Manuel Klimek2013-06-111-0/+1
| | | | | | Patch by Chris Gray. llvm-svn: 183739
* Fix off-by-one error in clang-format's emacs integration.Daniel Jasper2013-05-211-2/+2
| | | | llvm-svn: 182395
* Let clang-format move the cursor appropriately.Daniel Jasper2013-05-211-4/+12
| | | | | | | | | With this patch, clang-format will try to keep the cursor at the original code position in editor integrations (implemented for emacs and vim). This means, after formatting, clang-format will try to keep the cursor on the same character of the same token. llvm-svn: 182373
* Update clang-format emacs integration.Daniel Jasper2013-05-141-15/+29
| | | | | | | | | | - Remove free variables - Add function clang-format-buffer, e.g. for before-save-hooks - Wrap restoring windows in an unwind-protect Patch by Stephen Gildea! llvm-svn: 181766
* Further fix to clang-format emacs integration.Daniel Jasper2013-05-071-1/+1
| | | | | | | This is just a slight improvement for the fix in r181299, which fixes formatting the very last line of a file. llvm-svn: 181303
* Fix clang-format emacs integration in last line.Daniel Jasper2013-05-071-2/+2
| | | | | | | | Emacs seems to have a line that is just past the last character of the buffers content. This needs to be handled specially so that clang-format is not called with an invalid -offset. llvm-svn: 181299
* Fix scrolling bug in clang-format's emacs integration.Daniel Jasper2013-04-251-5/+9
| | | | | | | This patch ensure that nothing scrolls even if the same buffer is opened in multiple windows. llvm-svn: 180252
* Small improvements to clang-format documentation and integrationDaniel Jasper2013-04-171-7/+7
| | | | | | scripts. llvm-svn: 179676
* Provide better emacs integration.Daniel Jasper2013-04-121-33/+13
| | | | | | | | | | | The new emacs integration is simpler, does not save the current file before reformatting and ensures that emacs does not scroll as a result of formatting. Also explicitly set the style in clang-format tests to make them more robust. llvm-svn: 179372
* Improvements to clang-format integrations.Daniel Jasper2013-04-091-0/+47
This adds an emacs editor integration (thanks to Ami Fischman). Also pulls out the style into a variable for the vi integration and just uses clang-formats defaults style in clang-format-diff.py. llvm-svn: 179098
OpenPOWER on IntegriCloud