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: bizarre emacs indentation problem Date: Sat, 11 Apr 2009 21:29:35 +0000 Message-ID: <20090411212935.GB2075@muc.de> References: <1490ae41-1593-4ed2-9b51-a6295d71121b@q9g2000yqc.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1239485436 14739 80.91.229.12 (11 Apr 2009 21:30:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 11 Apr 2009 21:30:36 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: luca.pamparana@gmail.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 11 23:31:54 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lskni-0007J0-5Y for geh-help-gnu-emacs@m.gmane.org; Sat, 11 Apr 2009 23:31:46 +0200 Original-Received: from localhost ([127.0.0.1]:57681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LskmJ-0006VI-5B for geh-help-gnu-emacs@m.gmane.org; Sat, 11 Apr 2009 17:30:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lskly-0006V2-2j for help-gnu-emacs@gnu.org; Sat, 11 Apr 2009 17:29:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lskls-0006Un-I9 for help-gnu-emacs@gnu.org; Sat, 11 Apr 2009 17:29:56 -0400 Original-Received: from [199.232.76.173] (port=44436 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lskls-0006Uj-8U for help-gnu-emacs@gnu.org; Sat, 11 Apr 2009 17:29:52 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:1471 helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lsklr-00010B-Ku for help-gnu-emacs@gnu.org; Sat, 11 Apr 2009 17:29:52 -0400 Original-Received: (qmail 653 invoked by uid 3782); 11 Apr 2009 21:29:48 -0000 Original-Received: from acm.muc.de (pD9E519E0.dip.t-dialin.net [217.229.25.224]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Sat, 11 Apr 2009 23:29:46 +0200 Original-Received: (qmail 9125 invoked by uid 1000); 11 Apr 2009 21:29:35 -0000 Content-Disposition: inline In-Reply-To: <1490ae41-1593-4ed2-9b51-a6295d71121b@q9g2000yqc.googlegroups.com> User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: FreeBSD 4.6-4.9 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:63679 Archived-At: Hi, Luca! On Fri, Apr 10, 2009 at 04:48:30PM -0700, luca.pamparana@gmail.com wrote: > Hello, > I have a bizarre emacs indentation problem in the C++ mode. My C++ > settings look as follows: > (defun my-c++-mode-hook () > (c-set-offset 'substatement-open 0) > (setq indent-tabs-mode nil) > (setq tab-width 4) > (define-key c++-mode-map "\C-m" 'reindent-then-newline-and-indent) > (define-key c++-mode-map "\C-ce" 'c-comment-edit) > (setq c++-auto-hungry-initial-state 'none) > (setq c++-delete-function 'backward-delete-char) > (setq c++-tab-always-indent nil) > (setq tab-stop-list '(4 8 12 16)) > (setq c-basic-offset 4) > (setq c-indent-level 4) > (setq c-continued-statement-offset 4) > (setq c++-empty-arglist-indent 4)) > ;; Add all of the hooks... > (add-hook 'c++-mode-hook 'my-c++-mode-hook) > (add-hook 'c++-mode-hook 'turn-on-auto-fill) > (setq default-major-mode 'c++-mode) > (setq column-number-mode t) > As you can see, I have set the substatement open parameter to 0, so it > should not indent after the statement braces. However, it always > indents by 1. So, my sample if clause looks as follows: > if(something) > { > } > As you can see, the braces are indented by 1 space. This is driving me > crazy! > Does anyone have any idea why I might be getting this? Yes, indeed. In a nutshell, "gnu" style imposes a minimum indentation of 1 from column zero. In more detail, it's in the CC Mode manual, as follows: (i) Your CC Mode "style" is "gnu" (the default, since you haven't changed it). Styles are explained on the pages "Config Basics" and "Styles". (ii) "gnu" style imposes a minimum indentation of 1 character FROM COLUMN ZERO. This is to help source code utilities which search for things in column zero. This "1 character" is in user option `c-label-minimum-indentation' which is on page "Other Indentation". You can fix this either by setting the default style to something other than "gnu" (user option `c-default-style' on manual page "Choosing a Style"), or by setting `c-label-minimum-indentation' to zero. As a matter of interest, why are you typing an if-statement in column zero? :-) > Many thanks, > Luca -- Alan Mackenzie (Nuremberg, Germany).