[Freeciv-Dev] Re: Emacs function to indent regions
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Wed, Jan 24, 2001 at 03:40:38PM +0000, Gaute B Strokkenes wrote:
> On Sun, 14 Jan 2001, hawk@xxxxxxxxxxxxxxxxxxxxxxx wrote:
>
> > Based on comments of some list members I wrote some lisp code. It
> > inserts some "{" to match up the base level, calls indent(1) and
> > removes the "{"s. It will only work if you select a proper
> > region. So selecting "if(cond) {block}" is ok while "else {block}"
> > will not work.
> >
> > I'm a beginner to list so please point out anything which can be
> > done better.
>
> Try M-x c-set-style RET k&r RET . It works for me.
If you apply indent-region-by-shell-command to:
--------
int unit_can_defend_here(struct unit *punit)
{
if(is_ground_unit(punit)&&map_get_terrain(punit->x,punit->y)==T_OCEAN)
{
return 0;
}
return 1;
}
--------
you will get
--------
int unit_can_defend_here(struct unit *punit)
{
if (is_ground_unit(punit)
&& map_get_terrain(punit->x, punit->y) == T_OCEAN) {
return 0;
}
return 1;
}
--------
AFAIK emacs's c-mode will not change the position of "{" and won't
insert whitespaces in certain places.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
Two OS engineers facing a petri net chart:
"dead lock in four moves!"
|
|