🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.help
Article #188780

C mode indention variables

#188780
From: Longshot
Date: Mon, 08 Jul 1991 19:44
116 lines
2903 bytes
I need a little assistance. I would like to configure my indention settings,
but am not sure as to how to achieve the desired results. The current value
of the variables are:

c-indent-level == 2
c-continued-statement-offset == 2
c-continued-brace-offset == 2
c-brace-offset == -2
c-brace-imaginary-offset == 2
c-argdecl-indent == 5
c-label-offset == -2

This produces indention along the lines of:

int
  ricky(lucy, fred, ethel)
int lucy;
int fred;
struct flake ethel;
{
  int a_local_var;
  
  if (some_test)
    single_statement();
  else
    {
      multi();
      statement();
      block();
    }
  
  switch(hit)
    {
    case HIT:
    {
      run_fast();
      break;
    }
  case BALL:
  {
    swing_again();
    break;
  }
  case FOUL:
  {
    curses(3);
    break;
  }
  case STRIKE:
  {
    break;
  }
  }

  return(home);
}

The differences I am after are subtle, but important (to me). I want a 
function's type and name/parameters on different lines, but lined up.
And I want the sub-blocks within cases to be indented relative to the
label. I want the above to look like this:

int
ricky(lucy, fred, ethel)
     int lucy;
     int fred;
     struct flake ethel;
{
  int a_local_var;
  
  if (some_test)
    single_statement();
  else
    {
      multi();
      statement();
      block();
    }
  
  switch(hit)
    {
    case HIT:
      {
        run_fast();
        break;
      }
  case BALL:
    {
      swing_again();
      break;
    }
  case FOUL:
    {
      curses(3);
      break;
    }
  case STRIKE:
    {
      break;
    }
  }

  return(home);
}

I have noted that when the declration line ("ricky(lucy, fred, ethel)") is
in column 1, the argdecl's are properly indented. But if I separate the
return type (int in this case) from the name (ricky), the second line
gets treated as a continued statement, and indented. As for the bit around
the case labels, I have no idea what approach to take.

-- 
Randy J. Ray       University of Oklahoma, Norman Campus	(405)/325-5370
!chinet!uokmax!randy	randy@uokmax.uucp    randy@uokmax.ecn.uoknor.edu
Systems programmers are the high priests of a low cult.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Technical Details
Message-ID: <1991Jul8.194451.20300@uokmax.ecn.uoknor.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!uakari.primate.wisc.edu!unmvax!uokmax!randy

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 103b8b,bfe9e4da7be79631,start
X-Google-Attributes: gid103b8b,public
X-Google-ArrivalTime: 1991-07-08 15:39:34 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!uakari.primate.wisc.edu!unmvax!uokmax!randy
From: randy@uokmax.ecn.uoknor.edu (Longshot)
Newsgroups: gnu.emacs.help
Subject: C mode indention variables
Message-ID: <1991Jul8.194451.20300@uokmax.ecn.uoknor.edu>
Date: 8 Jul 91 19:44:51 GMT
Organization: Engineering Computer Network, University of Oklahoma, Norman, OK
Lines: 116