all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Indentation in C
@ 2004-01-21 21:37 Varun Sinha
  2004-01-21 21:46 ` Yuri Shtil
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Varun Sinha @ 2004-01-21 21:37 UTC (permalink / raw)


I was wondering how I could get the following done in EMACS-

1) When I hit tab to indent, I'd like the tab to be made up of spaces.
I love the way I can hit tab anywhere on a line, and it indents the
line according to the specifications and I don't want to lose that.
The indentation should be two spaces. I was trying some of the
options, but when (I think) I replaced the tabs with spaces, I lost
the ability to tab anywhere in the line and get indentation.

2) Right now, the curly braces are indented two spaces below the
function call or the control statement, like so

function_name
  {
    .........
    .........
  }

but I need the curly braces to not be indented like so

function_name
{
  ...........
  ...........
}

I tried looking through the documentation for EMACS to get these, but
I wasn't able to make sense out of it. Ordinarily, it wouldn't matter
to me, but the professor for my course has laid down these standards.
I tried asking him and the TA, but they all use VI and told me either
to switch (yeah right) or use manual spacing.

Thanks a lot!!

Varun

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Indentation in C
  2004-01-21 21:37 Indentation in C Varun Sinha
@ 2004-01-21 21:46 ` Yuri Shtil
  2004-01-21 22:03 ` Andrew Taylor
  2004-01-22 11:21 ` Vivek Dasmohapatra
  2 siblings, 0 replies; 4+ messages in thread
From: Yuri Shtil @ 2004-01-21 21:46 UTC (permalink / raw)




Varun Sinha wrote:
> I was wondering how I could get the following done in EMACS-
> 
> 1) When I hit tab to indent, I'd like the tab to be made up of spaces.
> I love the way I can hit tab anywhere on a line, and it indents the
> line according to the specifications and I don't want to lose that.
> The indentation should be two spaces. I was trying some of the
> options, but when (I think) I replaced the tabs with spaces, I lost
> the ability to tab anywhere in the line and get indentation.
> 
> 2) Right now, the curly braces are indented two spaces below the
> function call or the control statement, like so
> 
> function_name
>   {
>     .........
>     .........
>   }
> 
> but I need the curly braces to not be indented like so
> 
> function_name
> {
>   ...........
>   ...........
> }
> 
> I tried looking through the documentation for EMACS to get these, but
> I wasn't able to make sense out of it. Ordinarily, it wouldn't matter
> to me, but the professor for my course has laid down these standards.
> I tried asking him and the TA, but they all use VI and told me either
> to switch (yeah right) or use manual spacing.
> 
> Thanks a lot!!
> 
> Varun


Look up the variable indent-tabs-mode.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Indentation in C
  2004-01-21 21:37 Indentation in C Varun Sinha
  2004-01-21 21:46 ` Yuri Shtil
@ 2004-01-21 22:03 ` Andrew Taylor
  2004-01-22 11:21 ` Vivek Dasmohapatra
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Taylor @ 2004-01-21 22:03 UTC (permalink / raw)


Varun Sinha wrote:

> I tried looking through the documentation for EMACS to get these, but
> I wasn't able to make sense out of it. Ordinarily, it wouldn't matter
> to me, but the professor for my course has laid down these standards.
> I tried asking him and the TA, but they all use VI and told me either
> to switch (yeah right) or use manual spacing.

Try running c-set-style (C-c .) while in c-mode and try the various 
styles (type tab for a list at the prompt).  One of them will probably 
match your needs.

To make it permanent, run M-x customize-option and type c-default-style 
at the prompt.

-- 
Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Indentation in C
  2004-01-21 21:37 Indentation in C Varun Sinha
  2004-01-21 21:46 ` Yuri Shtil
  2004-01-21 22:03 ` Andrew Taylor
@ 2004-01-22 11:21 ` Vivek Dasmohapatra
  2 siblings, 0 replies; 4+ messages in thread
From: Vivek Dasmohapatra @ 2004-01-22 11:21 UTC (permalink / raw)


vsinha@purdue.edu (Varun Sinha) writes:

> I was wondering how I could get the following done in EMACS-
> 1) When I hit tab to indent, I'd like the tab to be made up of spaces.

  M-x customize-variable RET indent-tabs-mode RET

Set it to off (nil).
 
> 2) Right now, the curly braces are indented two spaces below the

You can alter the indentation style by calling c-set-style

  M-x c-set-style RET

You will can tab complete the available styles - BSD style is
sounds close to what you want.

You can control the amount of indentation by setting c-basic-offset

M-x customize-variable RET c-basic-offset RET

and setting it to 4.

You can find a much more detailed example in 

  http://rtfm.etla.org/emacs/dot.html

look for "(defvar viveks-c-style" and "(setq c-mode-common-hook"

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-01-22 11:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-21 21:37 Indentation in C Varun Sinha
2004-01-21 21:46 ` Yuri Shtil
2004-01-21 22:03 ` Andrew Taylor
2004-01-22 11:21 ` Vivek Dasmohapatra

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.