unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* C++/Java/C modes
@ 2003-11-19 10:38 David Rasmussen
  2003-11-19 14:09 ` Eli Zaretskii
  2003-11-20 16:55 ` kgold
  0 siblings, 2 replies; 4+ messages in thread
From: David Rasmussen @ 2003-11-19 10:38 UTC (permalink / raw)


Two questions:

1) How do change it so that when I press enter on a line, the cursor is 
already at the natural indentation point with spaces inserted before. 
Example:

int main()
{
   std::cout << "Hello, world!" << std::endl; <pressing enter>
<cursor is normally here>
   <I want it here>

2) How can I change the auto indentation style so that instead of

   if (whatever) <pressing enter>
<pressing tab, which shouldn't be necesary, if I get a good answer to 
question 1>
     <cursor is here!>
   <I want it here>

I guess the last question is about using the

   if (whatever) {
     blabla
   }

style. I (want to) use the

   if (whatever)
   {
     blabla
   }

style.

Help? Maybe I should just give in and go with the flow and use the short 
style.

/David

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

* Re: C++/Java/C modes
  2003-11-19 10:38 C++/Java/C modes David Rasmussen
@ 2003-11-19 14:09 ` Eli Zaretskii
  2003-11-20 16:55 ` kgold
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2003-11-19 14:09 UTC (permalink / raw)


> From: David Rasmussen <david.rasmussen@gmx.net>
> Newsgroups: gnu.emacs.help
> Date: Wed, 19 Nov 2003 11:38:53 +0100
> 
> 1) How do change it so that when I press enter on a line, the cursor is 
> already at the natural indentation point with spaces inserted before. 

Bind RET to the function newline-and-indent.

> I guess the last question is about using the
> 
>    if (whatever) {
>      blabla
>    }
> 
> style. I (want to) use the
> 
>    if (whatever)
>    {
>      blabla
>    }
> 
> style.

You will find the answer to this in the CC Mode manual, which is part
of a standard Emacs distribution.  There's a chapter there which
explains how to customize indentation interactively.

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

* Re: C++/Java/C modes
  2003-11-19 10:38 C++/Java/C modes David Rasmussen
  2003-11-19 14:09 ` Eli Zaretskii
@ 2003-11-20 16:55 ` kgold
  2003-12-16 21:06   ` Kai Grossjohann
  1 sibling, 1 reply; 4+ messages in thread
From: kgold @ 2003-11-20 16:55 UTC (permalink / raw)


David Rasmussen <david.rasmussen@gmx.net> writes:
> Two questions:
> 
> 1) How do change it so that when I press enter on a line, the cursor is 
> already at the natural indentation point with spaces inserted before. 
> Example:

(add-hook 'c-mode-common-hook
	  (function (lambda ()
		(define-key c-mode-base-map [RET] 'newline-and-indent)
)))

> 2) How can I change the auto indentation style so that instead of
> [snip]
> 
> Help? Maybe I should just give in and go with the flow and use the short 
> style.

Don't give in!  The whole point of emacs is that it does what you
want.

For indentation, see the manual under "cc-mode" "built-in styles".

Start with one of the built in styles.  Then, if it's not exactly
right, the manual tells you how to tweak it.


-- 

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

* Re: C++/Java/C modes
  2003-11-20 16:55 ` kgold
@ 2003-12-16 21:06   ` Kai Grossjohann
  0 siblings, 0 replies; 4+ messages in thread
From: Kai Grossjohann @ 2003-12-16 21:06 UTC (permalink / raw)


kgold@watson.ibm.com (kgold) writes:

> 		(define-key c-mode-base-map [RET] 'newline-and-indent)

Does [RET] work these days?  It might fail on older Emacsen.

I suggest the kbd syntax, as surely you all know.

Kai

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

end of thread, other threads:[~2003-12-16 21:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-19 10:38 C++/Java/C modes David Rasmussen
2003-11-19 14:09 ` Eli Zaretskii
2003-11-20 16:55 ` kgold
2003-12-16 21:06   ` Kai Grossjohann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).