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: Fri, 10 Feb 2006 19:24:08 +0000 Organization: muc.de e.V. -- private internet access Message-ID: References: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1139610330 8902 80.91.229.6 (10 Feb 2006 22:25:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 10 Feb 2006 22:25:30 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 10 23:25:17 2006 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1F7ghY-0008TE-00 for ; Fri, 10 Feb 2006 23:25:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F7ghY-00065U-90 for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Feb 2006 17:25:16 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed.freenet.de!news.space.net!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 64 Original-NNTP-Posting-Host: acm.muc.de Original-X-Trace: marvin.muc.de 1139609963 13175 193.149.49.134 (10 Feb 2006 22:19:23 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: 10 Feb 2006 22:19:23 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:137500 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:33122 Archived-At: Marcus Husar 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 , 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) > here is my .emacs: > (setq case-fold-search t) > (global-font-lock-mode t) > (mouse-wheel-mode t) > (setq auto-fill-mode 1) > (setq display-time-day-and-date t) > (display-time) > (setq c-mode-hook > (function (lambda () > (c-set-style "K&R") > (setq c-basic-offset 8)))) > (setq objc-mode-hook > (function (lambda () > (c-set-style "K&R") > (setq c-basic-offset 8)))) > (setq c++-mode-hook > (function (lambda () > (c-set-style "K&R") > (setq c-basic-offset 8)))) > (setq java-mode-hook > (function (lambda () > (c-set-style "K&R") > (setq c-basic-offset 8)))) Nothing to do with what you asked for, but a comment all the same. You can achieve the effect of the above 16 lines more simply by code like this in your .emacs: (setq c-default-style "K&R") (defun my-set-basic-offset () (setq c-basic-offset 8)) (add-hook 'c-mode-common-hook 'my-set-basic-offset) > Marcus Husar: mail@marcus-husar.de -- 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").