From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: Auto-indentation Date: Mon, 13 Feb 2006 08:07:17 +0000 Organization: muc.de e.V. -- private internet access Message-ID: References: <43efd1b5$0$22056$5a62ac22@per-qv1-newsreader-01.iinet.net.au> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1139825147 6759 80.91.229.2 (13 Feb 2006 10:05:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 13 Feb 2006 10:05:47 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Feb 13 11:05:47 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F8aaK-0004zO-OZ for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Feb 2006 11:05:33 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F8aaI-0007cV-Vk for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Feb 2006 05:05:31 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.news.ucla.edu!canoe.uoregon.edu!hammer.uoregon.edu!news.wind.surfnet.nl!humbolt.nl.linux.org!news.nl.linux.org!txtfeed2.tudelft.nl!tudelft.nl!txtfeed1.tudelft.nl!feeder4.cambrium.nl!feed.tweaknews.nl!feeder.ecngs.de!ecngs!feeder2.ecngs.de!news.osn.de!diablo1-ffm.news.osn.de!news.space.net!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 51 Original-NNTP-Posting-Host: acm.muc.de Original-X-Trace: marvin.muc.de 1139824373 99918 193.149.49.134 (13 Feb 2006 09:52:53 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: 13 Feb 2006 09:52:53 GMT User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686)) Original-Xref: shelby.stanford.edu gnu.emacs.help:137549 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:33174 Archived-At: Paul Whitfield wrote on Mon, 13 Feb 2006 08:26:43 +0800: > Alan Mackenzie wrote: [ .... ] >> When you type , the newline doesn't get indented. You can make >> this happen by typing C-j instead of . If you really want >> 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. > 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. > regards > Paul -- Alan Mackenzie (Munich, Germany) Email: aacm@muuc.dee; to decode, wherever there is a repeated letter (like "aa"), remove half of them (leaving, say, "a").