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

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

Re: Tab problem


From: Kai Grossjohann
Subject: Re: Tab problem
Date: Mon, 06 Sep 2004 14:16:44 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Nick Chorley <nick@nospam.xyphias.com> writes:

> It was mainly so I could put comments in without simply entering a
> load of spaces.

Try to hit M-; when you want to enter a comment.  Also see the
variable comment-column.

> Apart from that, well, I don't like the way it indents things
> like switch statements (ie. the case x: bits go right underneath the 
> word switch, instead of being indented a bit, if you see what I mean). 

That is easy to configure.  First of all, there are different
indentation styles.  You can choose among them with C-c . I believe.
Perhaps one of them suits your coding style.

If not, then choose the one that's closest, then go to the first line
with wrong indentation, use C-c C-o to customize its indentation, then
reindent the line to see if it was right.

If you find an indentation style that's basically right except that
its indentation level is wrong (say it indents 5 inside curlies but
you want 3), then you can simply set c-basic-offset, using M-x
set-variable RET c-basic-offset RET 42 RET.

You can make those changes permanent by writing some small amount of
Lisp:

(defun nick-c-mode-setup ()
  (c-set-style "bla")
  (setq c-basic-offset 42)
  (c-set-offset 'frumple 'foo))
(add-hook 'c-mode-hook 'nick-c-mode-setup)

Similar for other modes, such as c++ or java, instead of c.

The "bla" comes from the C-c . key.

The frumple and foo come from C-c C-o.  You can find the right
c-set-offset statement by typing C-x ESC ESC and then navigating the
history with M-p/M-n.

The CC mode info file explains how to customize indentation much
better than I can.

In any case, imagine how wonderful it would be if you could go to any
unreadable bit of source code, merely hit C-x h C-M-\, and then it
would be indented the way you like!

Kai




reply via email to

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