[Top][All Lists]

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

Re: indentation in jde/java mode

From: Alan Mackenzie
Subject: Re: indentation in jde/java mode
Date: Wed, 28 Apr 2004 18:02:24 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

ad <> wrote on Tue, 27 Apr 2004 22:55:19 -0400:
> On Tue, 27 Apr 2004 06:50:09 +0000, Alan Mackenzie wrote:

>>> While I am writing the code and get to the new-line and hit TAB, the
>>> cursor does not move, but when I finished the line with ";" or having
>>> a "." (dot) in the line (example (aClass.method), does the
>>> indentation automatically, and it looks by 2 chars. I also tend to
>>> use "Java -> Indent Expression" menu selection quite often which also
>>> looks like indenting by 2 chars. All the indentation looks just fine
>>> (2-chars) within the emacs, but opening with other editors (even
>>> "less") is making it look like it was indented by 8 chars. Because of
>>> this, I get some complaints from my colleagues that are using xemacs.

[ .... ]

>> If you put the cursor in those 2 spaces, then do "C-x =", it will tell
>> you what's there.  If it is indeed a TAB character, check the value of
>> the Emacs variables `tab-width' and `indent-tabs-mode' (using "C-h v").

> "C-x =" says: 
> Char: TAB (011, 9, 0x9) point=251 of 3560 (7%) column 0 

> And tab-width's value is 2

> And indent-tabs-mode's value is t

Aha!  There's the problem.  Something in your setup is setting tab-width
to 2 (by default, it's 8).  This seems to be a very small tab width
indeed.  Could it be something in your .emacs?

The question is, do you want to use TABs at all for indentation?  I
prefer not to, because different editors/display programs sometimes
disagree on how wide a TAB should be.  I suggest you change
`my-jde-mode-hook' to the following: 

(defun my-jde-mode-hook ()
  (setq c-basic-offset 2)
  (setq indent-tabs-mode nil))

That will prevent TABS being used for indentation in the future.

As for the source files which already contain TABS, (the ones your
colleagues are moaning about ;-), a good way to correct them is with the
function `untabify':  First make sure that `tab-width' is still set to 2.
Load a source file and type "C-x h" to mark the buffer, then "M-x
untabify" to convert the TABS to spaces.  Save the file again.  ViolĂ !

> Thank you so much for the help.

My pleasure!

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").

reply via email to

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