Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2001:
[Freeciv-Dev] Re: Emacs function to indent regions
Home

[Freeciv-Dev] Re: Emacs function to indent regions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gaute B Strokkenes <gs234@xxxxxxxxxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Emacs function to indent regions
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Jan 2001 20:54:22 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxxxx

On Wed, Jan 24, 2001 at 06:53:12PM +0000, Gaute B Strokkenes wrote:
> On Wed, 24 Jan 2001, hawk@xxxxxxxxxxxxxxxxxxxxxxx wrote:
> 
> > 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.
> 
> > AFAIK emacs's c-mode will not change the position of "{" and won't
> > insert whitespaces in certain places.
> 
> Hm, you're right.  However, I still thinks it's a good idea to write
> it in the right style to begin with, rather than relying on indent to
> tidy up after you.  Setting the right style in Emacs makes it easier
> to do so.

My "native" style is a bit different than freeciv's. I will not change
my style if a tool can also format my code in the preferred way. The
mentioned lisp construct is such a tool and it is easy to use.

> You also need to do M-x set-variable RET c-basic-offset RET 2 RET for
> best results.

from ~/.emacs
-------
(defun my-c-mode-hook ()
  (setq-default c-basic-offset 4)
  (setq c-basic-offset 4)
  (setq c-hanging-comment-ender-p nil)
  (c-set-offset 'statement-cont '+)
  (c-set-offset 'substatement-open 0)
  (c-set-offset 'case-label '+)
  (setq c-tab-always-indent nil)
  )
(add-hook 'c-mode-common-hook 'my-c-mode-hook)
-------

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 A life? Cool! Where can I download one?



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