From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Guido Van Hoecke Newsgroups: gmane.emacs.help Subject: Trying to use only tabs for indenting c# files - csharp-mode error? Date: Sun, 8 Jan 2012 14:01:38 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: dough.gmane.org 1326027733 18722 80.91.229.12 (8 Jan 2012 13:02:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 8 Jan 2012 13:02:13 +0000 (UTC) Cc: =?UTF-8?Q?=C3=93scar_Fuentes?= To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jan 08 14:02:09 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RjsO0-0004gC-Pu for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Jan 2012 14:02:08 +0100 Original-Received: from localhost ([::1]:54046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjsO0-0003tt-Cl for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Jan 2012 08:02:08 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:43362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjsNu-0003tI-8s for help-gnu-emacs@gnu.org; Sun, 08 Jan 2012 08:02:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RjsNs-0004Gc-7i for help-gnu-emacs@gnu.org; Sun, 08 Jan 2012 08:02:02 -0500 Original-Received: from mail-yw0-f41.google.com ([209.85.213.41]:57968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjsNr-0004GX-VJ for help-gnu-emacs@gnu.org; Sun, 08 Jan 2012 08:02:00 -0500 Original-Received: by yhoo21 with SMTP id o21so442769yho.0 for ; Sun, 08 Jan 2012 05:01:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:cc:content-type; bh=GsfG3I25CA7BoT6fVHnSJ8j4xTB08M5mTqvKPydbkkI=; b=kTBpouQFr6tIzZiuElX6ob9x3kJmUsxHvlafnaMLaCeqOCPO1cV1NKYgPiPkJkhS8u jZiMA4VtqbjA+CaIPd5YoY/rPj+k8uhALcvNUTaqNDXCqrZaTsQm6FXm8Tquk8wXTsMS GwrTDLz9bBDsTA9IxUoVwPVAWERpe0FWA4Tfs= Original-Received: by 10.236.124.206 with SMTP id x54mr6597229yhh.112.1326027719123; Sun, 08 Jan 2012 05:01:59 -0800 (PST) Original-Received: by 10.147.182.7 with HTTP; Sun, 8 Jan 2012 05:01:38 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.213.41 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:83411 Archived-At: Hi, Objective: use only tabs for indenting c# files I start with an 'emacs -Q' session. C-x C-f MyClass.cs (This file has been created with MonoDevelop, and uses only tabs for indentation, and - in MonoDevelop - the tab width is set to 4.) As expected, MyClass.cs is shown in fundamental mode. We want to see the whitespace, so M-x whitespace-mode This shows clearly that only tabs are used for indentation. So lets load csharp-mode and select that mode: M-x load-file csharp-mode.el M-X csharp-mode That removes the whitespace visualisation, so reactivate it: M-x whitespace-mode Tell emacs that it should use tabs for indenting: M-x set-variable [enter] indent-tabs-mode [enter] t [enter] Ultimately, I want the tab-width set to 4, but for now I just want to leave or set it to 8: M-x set-variable [enter] tab-width [enter] 8 [enter] I will use following legend when showing file content: # represents a leading tab + represents a leading empty space (following a preceding tab) = represents a leading space character Here's the source file: namespace Application { #+++++++public class MyClass #+++++++{ #+++++++#+++++++public MyClass () #+++++++#+++++++{ #+++++++#+++++++} #+++++++} } Deleting the first tab changes it to: namespace Application { =======public class MyClass #+++++++{ #+++++++#+++++++public MyClass () #+++++++#+++++++{ #+++++++#+++++++} #+++++++} } Hitting tab key while point is the 'public class' line changes it to: namespace Application { ==public class MyClass #+++++++{ #+++++++#+++++++public MyClass () #+++++++#+++++++{ #+++++++#+++++++} #+++++++} } I can't help but feeling that this is in error! The tab-width is 8, indent-tabs-mode is t and still, it uses spaces to indent, and only two of them. For the record, the emacs and csharp-mode versions: GNU Emacs 23.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2011-12-13 on bob.porkrind.org ;;; csharp-mode.el --- C# mode derived mode ;; Author : Dylan R. E. Moonfire (original) ;; Maintainer : Dino Chiesa ;; Created : Feburary 2005 ;; Modified : May 2011 ;; Version : 0.8.6 ;; Keywords : c# languages oop mode ;; X-URL : http://code.google.com/p/csharpmode/ ;; Last-saved : <2011-May-21 20:28:30> So one more test: insert a 'public string MyString' line before the 'public Myclass()' line by positioning point after the second { and just typing: namespace Application { ==public class MyClass #+++++++{ #+++++++==public string MyString; #+++++++#+++++++public MyClass () #+++++++#+++++++{ #+++++++#+++++++} #+++++++} } The leading tab is respected and replicated, but the new line is then indented by two spaces rather than by an extra tab!? And finally" M-< C-SPC M-> produces following result: namespace Application { ==public class MyClass =={ ====public string MyString; ====public MyClass () ===={ ====} ==} } So obviously neither tab-width nor indent-tabs-mode are obeyed nor respected! Please advise, TIA, Guido -- If I had only known, I would have been a locksmith. -- Albert Einstein http://vanhoecke.org ... and go2 places!