From: Paul Whitfield <NoSpam@iinet.net.au>
Subject: Re: Auto-indentation
Date: Mon, 13 Feb 2006 08:30:40 +0800 [thread overview]
Message-ID: <43efd2a2$0$22056$5a62ac22@per-qv1-newsreader-01.iinet.net.au> (raw)
In-Reply-To: <43efd1b5$0$22056$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
Paul Whitfield wrote:
> Alan Mackenzie wrote:
>> Marcus Husar <mail@marcus-husar.de> wrote on Fri, 10 Feb 2006 14:27:32
>> +0100:
>>
>>> I no searched 2 hours for auto-indentation in emacs. I couldn't find
>>> anything. Could someone please tell me how it works?
>>
>> Assuming you're talking about C, C++, Objective-C and Java, (as suggested
>> by your .emacs), then an existing line of code gets re-indented when
>>
>> o - you press the TAB key.
>> o - you type an "electric" character, such as ";" or "{".
>> o - you run some other indentation command, such as C-M-q, C-c C-q, or
>> C-M-\.
>>
>> 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.
>
> Adding to the common hook means that all languages that
> make use of CC-mode will be "auto" indented.
Oops... just re-read the documentation, c-initialization-hook is run
first, so ignore my advice about using the common-hook instead of the
initialisation hook.
regards
Paul
next prev parent reply other threads:[~2006-02-13 0:30 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 ` Paul Whitfield [this message]
2006-02-13 8:07 ` Auto-indentation Alan Mackenzie
2006-02-14 1:04 ` Auto-indentation Paul Whitfield
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='43efd2a2$0$22056$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.
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).