Hi,

I’ve landed a js/src/.clang-format configuration file, so clang-format is now 
more useful for SpiderMonkey code. Previously, it would pick up the top-level 
.clang-format file which uses the standard Mozilla style. (I also added a 
separate config for the VIXL snowflake.)

The clang-format command line utility will reformat a whole source file which 
is probably not what you want, but there are also editor integration scripts. 
For Vim, I use:

" Hook up clang-format to C-K.
map <C-K> :pyf /usr/local/share/clang/clang-format.py<cr>
imap <C-K> <c-o>:pyf /usr/local/share/clang/clang-format.py<cr>

This reformats just the current line or selection with Ctrl-K.

There is also a clang-format.el file with a lot of parentheses in it. It looks 
like some kind of precursor to XML. I dunno, maybe poke at it?

The 'git clang-format’ command can reformat just the lines that were changed 
since a given commit. I am not aware of a Mercurial equivalent.

Unfortunately, the way SpiderMonkey indents case labels is too odd for 
clang-format. I don’t think it has a configuration flag that can do that 
half-indent. (It does have the half-indent flag for public/private/protected 
labels.) It’s on my todo list to add such an option to clang-format, but I 
haven’t gotten around to it yet. In the meantime, I use Vim’s ‘=‘ command to 
fix the indentation of case labels.

Thanks,
/jakob

_______________________________________________
dev-tech-js-engine-internals mailing list
dev-tech-js-engine-internals@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to