如何应用新的Emacs C风格来重新格式化所有的源文件? [英] How can I apply a new Emacs C style to reformat all my source files?

查看:131
本文介绍了如何应用新的Emacs C风格来重新格式化所有的源文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用emacs的Google格式化功能重新格式化我的所有源文件: google-c-style.el (请参阅 here )。

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

如何一次将这个函数应用到我的所有源文件,这样它们都被格式化和缩进根据Google风格正确吗?

How can I apply this function to all my source files at once, so that they are all formatted and indented correctly according to the Google style?

推荐答案

有几件作品:


  • 您需要提出EMACS功能才能执行所需的所有重新格式化。 indent-region 是一个开始,但您可能还想取消其他一些事情。

  • 您需要在每个文件,并且由于缩进函数适用于范围,因此您需要一个设置标记以覆盖整个文件的功能: mark-whole-buffer

  • 您需要在每个文件中调用EMACS:这意味着使用--batch文件调用emacs。

  • 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.

这篇关于如何应用新的Emacs C风格来重新格式化所有的源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆