all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Whitfield <NoSpam@iinet.net.au>
Subject: Re: Auto-indentation
Date: Tue, 14 Feb 2006 09:04:34 +0800	[thread overview]
Message-ID: <43f12c13$0$22069$5a62ac22@per-qv1-newsreader-01.iinet.net.au> (raw)
In-Reply-To: <lnepsd.hc.ln@acm.acm>

Alan Mackenzie wrote:
> Paul Whitfield <NoSpam@iinet.net.au> wrote on Mon, 13 Feb 2006 08:26:43 +0800:
>> Alan Mackenzie wrote:
> 
> [  .... ]
> 
>>> When you type <ret>, the newline doesn't get indented.  You can make
>>> this happen by typing C-j instead of <ret>.  If you really want <ret>
>>> to indent the new line, then put this into your .emacs:
> 
>>>         (defun my-make-CR-do-indent ()
>>>           (define-key c-mode-base-map "\C-m" 'c-context-line-break))
>>>         (add-hook 'c-initialization-hook 'my-make-CR-do-indent)
>>>
> 
>> Alternatively:
> 
>> (defun my-c-mode-common-hook ()
>>    (define-key c-mode-base-map "\C-m" 'newline-and-indent))
> 
>> (add-hook 'c-mode-common-hook' my-c-mode-common-hook)
> 
> 
> 
>> This uses the generic newline-and-indent which should work
>> for even non "c" type languages.
> 
> Yes, but the binding suggested is in CC Mode's main keymap
> (c-mode-base-map), so this is irrelevant.  The command
> c-context-line-break, unlike newline-and-indent, continues comments and
> multi-line macros with comment prefixes (e.g. " * " at beginning of line)
> and backslashed newlines.

Oh... I think I will try that out!

>> Adding to the common hook means that all languages that
>> make use of CC-mode will be "auto" indented.
> 
> Yes.  I've seen your follow-up post.  ;-)  The thing about
> c-mode-common-hook is that it's executed every time you visit a new
> buffer.  You only need to bind key sequences once.  Binding them in the
> common hook isn't wrong, and doesn't noticeably delay anything, but it's
> kind of klunky.  This klunkiness was actually encouraged by the CC Mode
> manual, but newer editions have corrected this.

Goes to show you should re-visit manuals!

Thank you for correcting my wrong headedness :-)

Regards
Paul.

  reply	other threads:[~2006-02-14  1:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.124.1139578896.2885.help-gnu-emacs@gnu.org>
2006-02-10 14:02 ` Auto-indentation Zhang Wei
2006-02-10 17:34 ` Auto-indentation Stefan Monnier
2006-02-10 19:24 ` Auto-indentation Alan Mackenzie
2006-02-13  0:26   ` Auto-indentation Paul Whitfield
2006-02-13  0:30     ` Auto-indentation Paul Whitfield
2006-02-13  8:07     ` Auto-indentation Alan Mackenzie
2006-02-14  1:04       ` Paul Whitfield [this message]
2012-04-20 12:57 Auto-indentation Richard H Lee
2012-04-21  8:39 ` Auto-indentation Mark Skilbeck
2012-04-21 12:58   ` Auto-indentation Richard H Lee
2012-04-21 13:51     ` Auto-indentation Richard H Lee
2012-04-21 22:38       ` Auto-indentation Ludwig, Mark
  -- strict thread matches above, loose matches on Subject: below --
2006-02-10 13:27 Auto-indentation Marcus Husar
2006-02-10 17:30 ` Auto-indentation Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='43f12c13$0$22069$5a62ac22@per-qv1-newsreader-01.iinet.net.au' \
    --to=nospam@iinet.net.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.