help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trying to use only tabs for indenting c# files - csharp-mode error?


From: Guido Van Hoecke
Subject: Trying to use only tabs for indenting c# files - csharp-mode error?
Date: Sun, 8 Jan 2012 14:01:38 +0100

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 <dpchiesa@hotmail.com>
;; 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->
        <tab>

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!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]