[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: address@hidden: C indentation problem]
From: |
Kenichi Handa |
Subject: |
Re: address@hidden: C indentation problem] |
Date: |
Wed, 19 Apr 2006 10:30:18 +0900 |
User-agent: |
SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/22.0.50 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI) |
In article <address@hidden>, Alan Mackenzie <address@hidden> writes:
> Sometime between Emacs 21 and Emacs 22 CVS, the indentation in the actual
> source code was changed from:
> Emacs 21 sources:
> #########################################################################
> DEFUN ("forward-char", Fforward_char, Sforward_char, 0, 1, "p",
> "Move point right N characters (left if N is negative).\n\
> On reaching end of buffer, stop and signal error.")
> (n) <====== indentation of 2 columns.
> Lisp_Object n; <====== indentation of 5 columns.
> #########################################################################
> to
> Emacs 22 sources:
> #########################################################################
> DEFUN ("forward-char", Fforward_char, Sforward_char, 0, 1, "p",
> doc: /* Move point right N characters (left if N is negative).
> On reaching end of buffer, stop and signal error. */)
> (n) <====== indentation of 5 columns.
> Lisp_Object n; <====== indentation of 5 columns.
> #########################################################################
Ah! Yes. I personally prefer Emacs 21 style (perhaps just
because I used to it for long time).
> However, CC Mode 5.28 seems to me to indent like the Emacs 22 sources are
> indented, i.e. column 5, and 5.
> The problem here is there is no Right Thing to do, since a C macro can
> violate any syntactic rules. Consecutive parenthesis pairs are uncommon
> in C.
Yes. But, I noticed this:
If I have a function without declaring the return type, I
get this indentation (case1):
test (a)
int a;
{
}
But, if I put the return type, I get this correct
indentation (case2):
int
test (a)
int a;
{
}
And, if I insert extra parenthesis after the line of
function name, I get this (case3):
int
test (a)
(b)
int a;
{
}
And, when I delete "void" line, I get this (case 4):
test (a)
(b)
int a;
{
}
Is the difference of case1 and case2 (or case3 and case4)
intentional? Isn't the case1 bug?
Is the indentation of case3 ("(b)" is indented by 2-col)
intentional?
Is it difficult to treat case4 as the same way as case3? If
that is possible, I think DEFUN case is solved because DEFUN
syntax is the same as case4.
> I suggest the following: a new lineup function,
> c-lineup-gnu-DEFUN-intro-cont which would be active only in GNU style,
> and would give the offset knr-argdecl-intro (i.e. 5) for the lines
> between DEFUN's closing paren and the function's opening brace. This new
> function would be tried only if the existing c-lineup-topmost-intro-cont
> returns nil.
I have no idea how adequate that method is.
> Question: Are there any other C macros, besides DEFUN, whose indentation
> is also broken at the moment? (I do not know the C source at all well.)
All I noticed is the DEFUN case.
---
Kenichi Handa
address@hidden