Commit Graph

21 Commits

Author SHA1 Message Date
Daniel Jasper da44677082 clang-format: Enable #include sorting by default.
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
2015-11-16 12:38:56 +00:00
Daniel Jasper db125cb326 clang-format: Add include sorting capabilities to sublime, emacs and
clang-format-diff.py.

llvm-svn: 249567
2015-10-07 17:00:20 +00:00
Daniel Jasper 622c72ded5 Reapply r236854 and fixed r236867.
Makes emacs show a different message when clang-format encountered a
syntax error.

llvm-svn: 236943
2015-05-10 07:47:19 +00:00
Tobias Grosser a704600295 Revert "Make emacs show when clang-format encountered a syntax error."
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
2015-05-08 21:34:09 +00:00
Manuel Klimek 3dfe4a87c8 Make emacs show when clang-format encountered a syntax error.
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
2015-05-08 13:59:15 +00:00
Manuel Klimek 7a95ce4399 Make clang-format work in emacs buffers with unicode characters.
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
2015-01-19 10:48:04 +00:00
Manuel Klimek 1ba46c661c Update clang-format.el to use xml output and patch in the returned chunks.
This leads to better undo behavior and avoids window content jumping
around.

Patch by Johann Klähn.

llvm-svn: 225777
2015-01-13 08:35:34 +00:00
Manuel Klimek 295b7b6800 Improve clang-format.el.
- 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
2015-01-08 15:29:03 +00:00
Justin Bogner 12b50a95c9 clang-format: Make it possible to (require 'clang-format)
This makes the emacs integration ``provide`` a clang-format feature,
so that a .emacs can ``require`` it.

llvm-svn: 221330
2014-11-05 04:32:54 +00:00
Daniel Jasper e488f5dd1e clang-format: Add -assume-filename option for editor integrations.
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
2013-09-13 13:40:24 +00:00
Chandler Carruth bc36e6e099 Switch the default mode for clang-format to '-file'. Make 'LLVM' the
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
2013-09-02 07:42:02 +00:00
Manuel Klimek c00dd83583 Make it possible to assign clang-format-buffer to a keybinding.
Patch by Chris Gray.

llvm-svn: 183739
2013-06-11 12:00:24 +00:00
Daniel Jasper a3c14575ef Fix off-by-one error in clang-format's emacs integration.
llvm-svn: 182395
2013-05-21 17:05:40 +00:00
Daniel Jasper 2a250b8b49 Let clang-format move the cursor appropriately.
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
2013-05-21 12:21:39 +00:00
Daniel Jasper 6e3506f212 Update clang-format emacs integration.
- 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
2013-05-14 08:48:24 +00:00
Daniel Jasper ee48c856e2 Further fix to clang-format emacs integration.
This is just a slight improvement for the fix in r181299, which fixes
formatting the very last line of a file.

llvm-svn: 181303
2013-05-07 10:04:47 +00:00
Daniel Jasper f7bec9b4ed Fix clang-format emacs integration in last line.
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
2013-05-07 09:25:29 +00:00
Daniel Jasper a04337e22b 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.

llvm-svn: 180252
2013-04-25 07:06:48 +00:00
Daniel Jasper dd77743af8 Small improvements to clang-format documentation and integration
scripts.

llvm-svn: 179676
2013-04-17 07:55:02 +00:00
Daniel Jasper 92a3130509 Provide better emacs integration.
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
2013-04-12 10:12:01 +00:00
Daniel Jasper e4549a2391 Improvements to clang-format integrations.
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
2013-04-09 15:23:04 +00:00