From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Whitfield Newsgroups: gmane.emacs.help Subject: Re: Auto-indentation Date: Tue, 14 Feb 2006 09:04:34 +0800 Message-ID: <43f12c13$0$22069$5a62ac22@per-qv1-newsreader-01.iinet.net.au> References: <43efd1b5$0$22056$5a62ac22@per-qv1-newsreader-01.iinet.net.au> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1139879296 18559 80.91.229.2 (14 Feb 2006 01:08:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 14 Feb 2006 01:08:16 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 14 02:08:16 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 1F8ofv-0007SL-IJ for geh-help-gnu-emacs@m.gmane.org; Tue, 14 Feb 2006 02:08:15 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F8ofu-0003wt-5a for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Feb 2006 20:08:14 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.news.ucla.edu!newsfeed.media.kyoto-u.ac.jp!snewsf0.syd.ops.aspac.uu.net!news1.optus.net.au!optus!news.uwa.edu.au!nntp.waia.asn.au!203.59.27.186.MISMATCH!newsfeed.iinet.net.au!newsfeed.iinet.net.au!per-qv1-newsstorage1.iinet.net.au!per-qv1-newsstorage1.iinet.net.au!per-qv1-newsreader-01.iinet.net.au!not-for-mail User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Thunderbird/1.0.6 Mnenhy/0.7.2.0 Original-Newsgroups: gnu.emacs.help In-Reply-To: Original-Lines: 54 Original-NNTP-Posting-Host: 203.59.9.243 Original-X-Trace: 1139878931 per-qv1-newsreader-01.iinet.net.au 22069 203.59.9.243 Original-Xref: shelby.stanford.edu gnu.emacs.help:137561 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:33186 Archived-At: Alan Mackenzie wrote: > 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. 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.