help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using indent program as filter to automatically view read-only C fil


From: Paul Whitfield
Subject: Re: Using indent program as filter to automatically view read-only C files
Date: Mon, 06 Feb 2006 12:02:25 +0800
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Thunderbird/1.0.6 Mnenhy/0.7.2.0

François Gannaz wrote:
Le ven 03 fév 03:46, juanleon1@gmail.com a écrit :
Hi,

I have to work with C/C++ files with a very ugly and inconsistent
indentation (many developers adding things with no style guide). This
is very distracting, and since I cannot change them (to avoid conflicts
when taking/carryng changes from/to other branches), I had think that
for read-only files (those that I have not opened in the revision
control system), it would be nice if emacs could run automagically the
"indent" program so I can see the code "beatyfully" indented.

Why would you use the indent program when emacs can do it itself? You
can use indent-region, bounded to C-M-\

Because there are limits to the indention in emacs...
namely that it will not fix misplaced braces in C/C++

I.e. if you prefered style is K&R

if ( thing ) {
        ....
}

and the code is indented as

if ( thing )
{
        ...
}


(Or vice-versa).


I generally find that Gnu Indent with a suitably setup rc file
is very useful for doing this type of indenting / conversion.

(It is also a lot quicker to run it over large numbers
of files).

Perhaps it can be combined with the other suggestions of format.el
to do what you require.

Regards

Paul


reply via email to

[Prev in Thread] Current Thread [Next in Thread]