From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Tony Harbin Newsgroups: gmane.emacs.help Subject: Re: automatic indentation in C,C++ modes Date: Mon, 15 Apr 2002 11:51:58 -0500 Sender: help-gnu-emacs-admin@gnu.org Message-ID: <3CBB052E.4B5C6FAB@hiwaay.net> References: <3CB7662B.82AA21D9@hiwaay.net> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1018889877 11902 127.0.0.1 (15 Apr 2002 16:57:57 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 15 Apr 2002 16:57:57 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16x9ng-00035j-00 for ; Mon, 15 Apr 2002 18:57:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16x9n8-0002nd-00; Mon, 15 Apr 2002 12:57:22 -0400 Original-Received: from sed04.sed.redstone.army.mil ([136.205.12.4]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16x9me-0002lG-00 for ; Mon, 15 Apr 2002 12:56:52 -0400 Original-Received: from hiwaay.net (dh900-249.sed.redstone.army.mil [136.205.148.246]) by sed04.sed.redstone.army.mil (PMDF V6.0-24 #41095) with ESMTP id <01KGLB95O3EO000081@sed04.sed.redstone.army.mil>; Mon, 15 Apr 2002 11:56:48 -0500 (CDT) Original-To: Greg Hill X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:88 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:88 Not quite. C/C++ mode binds open-paren, open-brace, colon, and slash (among others) to "electric" functions that, when the key is typed, automatically change the spacing and/or indentation on the line. I would like to disable/override/turn off this behavior. I was able to do this in an older version where I had to explicitly load the C/C++ mode modules, but in my current version (20.7.1), the stuff was already compiled in and the same tricks no longer work. Basically, I would just like those keys above to just self-insert and not run the "electric" functions. Is there a way to do this? Thanks. Greg Hill wrote: > At 5:56 PM -0500 4/12/02, Tony Harbin wrote: > >How do I turn off all automatic indentation in C and C++ modes? I find > >this > >behavior *VERY* annoying and would like to disable it permanently (i.e. > >in the > >.emacs file) > > > >Thanks for your time. > > Tony, > > If all you want is to insert a tab character at the beginning of a > line when you type the tab key, try adding this to your .emacs file: > > (add-hook 'c-mode-hook > (function (lambda () > (substitute-key-definition > 'c-indent-command 'self-insert-command c-mode-map)))) > > (add-hook 'c++-mode-hook > (function (lambda () > (substitute-key-definition > 'c-indent-command 'self-insert-command c++-mode-map)))) > > If, while you are at it, you also want to define the size of a tab > as, say, 3 spaces, make it: > > (add-hook 'c-mode-hook > (function (lambda () > (substitute-key-definition > 'c-indent-command 'self-insert-command c-mode-map) > (setq tab-width 3)))) > > --Greg