all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Can emacs open a new line below or above the current line?
@ 2006-12-21  7:45 Ronald
  2006-12-21  9:06 ` Mathias Dahl
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Ronald @ 2006-12-21  7:45 UTC (permalink / raw)


Better if it can be indented automatically (for example in cc mode).

I get a habit that code the main ones first, and then add on the 
trivialities. For example:

if((n=write(fd,line,n))!=n){
	perror("write error\n");		//second
	exit(-1);				//first
}

This may also applies when I type:

a.
	if(){}
b.
	if(){
	|}		//`|' as the cursor
c.
	Then I'd like to open a line above indented automatically.
	It normally would be C-j C-p tab. Just too many key strokes.

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

* Re: Can emacs open a new line below or above the current line?
  2006-12-21  7:45 Can emacs open a new line below or above the current line? Ronald
@ 2006-12-21  9:06 ` Mathias Dahl
  2006-12-21  9:24   ` Ronald
  2006-12-21  9:15 ` David Hansen
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Mathias Dahl @ 2006-12-21  9:06 UTC (permalink / raw)


Ronald <followait@163.com> writes:

> 	Then I'd like to open a line above indented automatically.  It
> 	normally would be C-j C-p tab. Just too many key strokes.

I am not completely sure, but it sounds as you want to use C-o,
`open-line'.

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

* Re: Can emacs open a new line below or above the current line?
  2006-12-21  7:45 Can emacs open a new line below or above the current line? Ronald
  2006-12-21  9:06 ` Mathias Dahl
@ 2006-12-21  9:15 ` David Hansen
       [not found] ` <mailman.2176.1166693025.2155.help-gnu-emacs@gnu.org>
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: David Hansen @ 2006-12-21  9:15 UTC (permalink / raw)


On Thu, 21 Dec 2006 15:45:30 +0800 Ronald wrote:

> Better if it can be indented automatically (for example in cc mode).
>
> I get a habit that code the main ones first, and then add on
> the trivialities. For example:
>
> if((n=write(fd,line,n))!=n){
> 	perror("write error\n");		//second
> 	exit(-1);				//first
> }
>
> This may also applies when I type:
>
> a.
> 	if(){}
> b.
> 	if(){
> 	|}		//`|' as the cursor
> c.
> 	Then I'd like to open a line above indented automatically.
> 	It normally would be C-j C-p tab. Just too many key strokes.

Not sure though if i understand you right but the electric
features of cc-mode may be interesting for you.  In Emacs 22
you can toggle that behavior with C-c C-a.

David

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

* Re: Can emacs open a new line below or above the current line?
  2006-12-21  9:06 ` Mathias Dahl
@ 2006-12-21  9:24   ` Ronald
  0 siblings, 0 replies; 8+ messages in thread
From: Ronald @ 2006-12-21  9:24 UTC (permalink / raw)


Mathias Dahl wrote:
> Ronald <followait@163.com> writes:
> 
>> 	Then I'd like to open a line above indented automatically.  It
>> 	normally would be C-j C-p tab. Just too many key strokes.
> 
> I am not completely sure, but it sounds as you want to use C-o,
> `open-line'.
Nope

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

* Re: Can emacs open a new line below or above the current line?
       [not found] ` <mailman.2176.1166693025.2155.help-gnu-emacs@gnu.org>
@ 2006-12-21  9:47   ` Ronald
  0 siblings, 0 replies; 8+ messages in thread
From: Ronald @ 2006-12-21  9:47 UTC (permalink / raw)


David Hansen wrote:
> On Thu, 21 Dec 2006 15:45:30 +0800 Ronald wrote:
> 
>> Better if it can be indented automatically (for example in cc mode).
>>
>> I get a habit that code the main ones first, and then add on
>> the trivialities. For example:
>>
>> if((n=write(fd,line,n))!=n){
>> 	perror("write error\n");		//second
>> 	exit(-1);				//first
>> }
>>
>> This may also applies when I type:
>>
>> a.
>> 	if(){}
>> b.
>> 	if(){
>> 	|}		//`|' as the cursor
>> c.
>> 	Then I'd like to open a line above indented automatically.
>> 	It normally would be C-j C-p tab. Just too many key strokes.
> 
> Not sure though if i understand you right but the electric
> features of cc-mode may be interesting for you.  In Emacs 22
> you can toggle that behavior with C-c C-a.
> 
> David
> 
> 
> 
Nope

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

* Re: Can emacs open a new line below or above the current line?
@ 2006-12-21 13:06 martin rudalics
  0 siblings, 0 replies; 8+ messages in thread
From: martin rudalics @ 2006-12-21 13:06 UTC (permalink / raw)


I'm using the following:

(defun newline-and-indent-maybe ()
   "Insert newline and re-indent lines if necessary.
On an empty line insert a newline before current line.  At the beginning
of a non-empty line, do `newline-and-indent', move to the beginning of
the line just inserted, and indent that line.  Otherwise, do
`newline-and-indent'.  Fixes up any whitespace at end of old line."
   (interactive)
   (let ((go-back
	 (save-excursion
	   (delete-horizontal-space)
	   (and (bolp) (not (eolp))))))
     (when (and (boundp 'show-paren-overlay-1)
	       (overlayp show-paren-overlay-1))
       ;; Remove `show-paren-overlay-1' to avoid flickering.
       (delete-overlay show-paren-overlay-1))
     (newline-and-indent)
     (when go-back
       (forward-line -1)
       (indent-according-to-mode))))

(global-set-key [?\r] 'newline-and-indent-maybe)

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

* Re: Can emacs open a new line below or above the current line?
  2006-12-21  7:45 Can emacs open a new line below or above the current line? Ronald
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.2176.1166693025.2155.help-gnu-emacs@gnu.org>
@ 2006-12-21 13:34 ` Dieter Wilhelm
       [not found] ` <mailman.2179.1166708079.2155.help-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 8+ messages in thread
From: Dieter Wilhelm @ 2006-12-21 13:34 UTC (permalink / raw)
  Cc: help-gnu-emacs

Ronald <followait@163.com> writes:

> Better if it can be indented automatically (for example in cc mode).
>
> I get a habit that code the main ones first, and then add on the
> trivialities. For example:
>
> if((n=write(fd,line,n))!=n){
> 	perror("write error\n");		//second
> 	exit(-1);				//first
> }
>
> This may also applies when I type:
>
> a.
> 	if(){}
> b.
> 	if(){
> 	|}		//`|' as the cursor
> c.
> 	Then I'd like to open a line above indented automatically.
> 	It normally would be C-j C-p tab. Just too many key strokes.

"C-M-o" is your friend.

(when you're--as in b.-- at the indentation, otherwise: "M-m C-M-o" or
as you probably meant: "C-j C-p TAB" )

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany

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

* Re: Can emacs open a new line below or above the current line?
       [not found] ` <mailman.2179.1166708079.2155.help-gnu-emacs@gnu.org>
@ 2006-12-21 22:24   ` Ronald
  0 siblings, 0 replies; 8+ messages in thread
From: Ronald @ 2006-12-21 22:24 UTC (permalink / raw)


Dieter Wilhelm wrote:
> Ronald <followait@163.com> writes:
> 
>> Better if it can be indented automatically (for example in cc mode).
>>
>> I get a habit that code the main ones first, and then add on the
>> trivialities. For example:
>>
>> if((n=write(fd,line,n))!=n){
>> 	perror("write error\n");		//second
>> 	exit(-1);				//first
>> }
>>
>> This may also applies when I type:
>>
>> a.
>> 	if(){}
>> b.
>> 	if(){
>> 	|}		//`|' as the cursor
>> c.
>> 	Then I'd like to open a line above indented automatically.
>> 	It normally would be C-j C-p tab. Just too many key strokes.
> 
> "C-M-o" is your friend.
> 
> (when you're--as in b.-- at the indentation, otherwise: "M-m C-M-o" or
> as you probably meant: "C-j C-p TAB" )
> 
C-M-o is really good. Thanks.

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

end of thread, other threads:[~2006-12-21 22:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-21  7:45 Can emacs open a new line below or above the current line? Ronald
2006-12-21  9:06 ` Mathias Dahl
2006-12-21  9:24   ` Ronald
2006-12-21  9:15 ` David Hansen
     [not found] ` <mailman.2176.1166693025.2155.help-gnu-emacs@gnu.org>
2006-12-21  9:47   ` Ronald
2006-12-21 13:34 ` Dieter Wilhelm
     [not found] ` <mailman.2179.1166708079.2155.help-gnu-emacs@gnu.org>
2006-12-21 22:24   ` Ronald
  -- strict thread matches above, loose matches on Subject: below --
2006-12-21 13:06 martin rudalics

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.