How can I apply a new Emacs C style to reformat all my source files?

前端 未结 4 2210
心在旅途
心在旅途 2020-12-31 21:08

I\'d like to re-format all my source files using the Google formatting function for emacs: google-c-style.el (see here).

How can I apply this function to all my sour

4条回答
  •  误落风尘
    2020-12-31 21:43

    There are several pieces to this:

    • you need to come up with EMACS functions to do all the reformatting you want. indent-region is a start, but you might also want to untabify or some other things.
    • you need to invoke them on each file, and since the indent functions work on ranges, you need a function that sets mark to cover the whole file: mark-whole-buffer.
    • you need to invoke EMACS on each file: this means invoking emacs with the --batch file.

    There's a couple of nice blog posts on doing this here and here.

提交回复
热议问题