* Re: [handa@m17n.org: C indentation problem]
[not found] <E1FTnAc-0004Fk-15@fencepost.gnu.org>
@ 2006-04-18 22:15 ` Alan Mackenzie
2006-04-19 1:30 ` Kenichi Handa
0 siblings, 1 reply; 7+ messages in thread
From: Alan Mackenzie @ 2006-04-18 22:15 UTC (permalink / raw)
Cc: bug-cc-mode, Richard Stallman
Hi, Kenichi!
On Wed, 12 Apr 2006, Richard Stallman wrote:
>Would you please DTRT and ack:
>------- Start of forwarded message -------
>From: Kenichi Handa <handa@m17n.org>
>To: emacs-devel@gnu.org
>Date: Wed, 12 Apr 2006 14:37:14 +0900
>Subject: C indentaion problem
>X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=failed
> version=3.0.4
>In the latest CVS code, arguments following DEFUN macro (in
>Emacs C source files) is not indented as before.
>For instance, when I visit src/cmds.c, i-search DEFUN (and
>find "forward-point"), move cursor to the argument line
>(that is " (n)"), and type TAB, "(n)" is moved to BOL.
>I remember that such an argument line was indented by 2
>columns, and the following type-declaration line was
>indented by 5 columns before. At least Emacs did that until
>CC Mode was updated to 5.31 on 2005-12-08.
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.
#########################################################################
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.
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.
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.)
What do you Think?
>Kenichi Handa
--
Alan Mackenzie (Munich, Germany)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [handa@m17n.org: C indentation problem]
2006-04-18 22:15 ` [handa@m17n.org: C indentation problem] Alan Mackenzie
@ 2006-04-19 1:30 ` Kenichi Handa
2019-04-30 13:11 ` Basil L. Contovounesios
0 siblings, 1 reply; 7+ messages in thread
From: Kenichi Handa @ 2006-04-19 1:30 UTC (permalink / raw)
Cc: bug-cc-mode, rms, emacs-devel
In article <Pine.LNX.3.96.1060418211302.439V-100000@acm.acm>, Alan Mackenzie <acm@muc.de> 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
handa@m17n.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [handa@m17n.org: C indentation problem]
2006-04-19 1:30 ` Kenichi Handa
@ 2019-04-30 13:11 ` Basil L. Contovounesios
2019-05-20 13:51 ` Basil L. Contovounesios
2019-05-21 10:32 ` Alan Mackenzie
0 siblings, 2 replies; 7+ messages in thread
From: Basil L. Contovounesios @ 2019-04-30 13:11 UTC (permalink / raw)
To: Kenichi Handa; +Cc: Alan Mackenzie, rms, emacs-devel
Kenichi Handa <handa@m17n.org> writes:
> In article <Pine.LNX.3.96.1060418211302.439V-100000@acm.acm>, Alan Mackenzie <acm@muc.de> 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.
CC Mode 5.33.2 also indents "Emacs 22-style", i.e. to 5 columns, but the
current sources, AFAICS, are indented to 2 columns, "Emacs 21-style".
>> 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.
Shouldn't the now-existing c-lineup-gnu-DEFUN-intro-cont be changed
accordingly, to indent to 2 columns instead of 5?
>> 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.
I too have yet to notice a problem with other macros.
Thanks,
--
Basil
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [handa@m17n.org: C indentation problem]
2019-04-30 13:11 ` Basil L. Contovounesios
@ 2019-05-20 13:51 ` Basil L. Contovounesios
2019-05-21 10:32 ` Alan Mackenzie
1 sibling, 0 replies; 7+ messages in thread
From: Basil L. Contovounesios @ 2019-05-20 13:51 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: handa, rms, emacs-devel
"Basil L. Contovounesios" <contovob@tcd.ie> writes:
> Kenichi Handa <handa@m17n.org> writes:
>
>> In article <Pine.LNX.3.96.1060418211302.439V-100000@acm.acm>, Alan Mackenzie <acm@muc.de> 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.
>
> CC Mode 5.33.2 also indents "Emacs 22-style", i.e. to 5 columns, but the
> current sources, AFAICS, are indented to 2 columns, "Emacs 21-style".
>
>>> 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.
>
> Shouldn't the now-existing c-lineup-gnu-DEFUN-intro-cont be changed
> accordingly, to indent to 2 columns instead of 5?
Any thoughts on this?
>>> 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.
>
> I too have yet to notice a problem with other macros.
Thanks,
--
Basil
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [handa@m17n.org: C indentation problem]
2019-04-30 13:11 ` Basil L. Contovounesios
2019-05-20 13:51 ` Basil L. Contovounesios
@ 2019-05-21 10:32 ` Alan Mackenzie
2019-05-21 10:57 ` Basil L. Contovounesios
1 sibling, 1 reply; 7+ messages in thread
From: Alan Mackenzie @ 2019-05-21 10:32 UTC (permalink / raw)
To: Basil L. Contovounesios; +Cc: emacs-devel, rms, Kenichi Handa
Hello, Basil.
Sorry I missed this post when you posted it at the end of April.
The issue goes back to 2006. ;-)
On Tue, Apr 30, 2019 at 14:11:05 +0100, Basil L. Contovounesios wrote:
> Kenichi Handa <handa@m17n.org> writes:
[ .... ]
> > 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.
> CC Mode 5.33.2 also indents "Emacs 22-style", i.e. to 5 columns, but the
> current sources, AFAICS, are indented to 2 columns, "Emacs 21-style".
More to the point, we no longer have knr declarations.
> >> 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.
> Shouldn't the now-existing c-lineup-gnu-DEFUN-intro-cont be changed
> accordingly, to indent to 2 columns instead of 5?
Seeing as how we don't have knr declarations any more, it seems senseless
now to indent with the CC Mode syntactic symbol knr-argdecl-intro, i.e.
5. Instead c-basic-offset (2) seems right.
How about the following patch?
diff -r f9e4e46ed54d cc-align.el
--- a/cc-align.el Mon May 20 12:34:51 2019 +0000
+++ b/cc-align.el Tue May 21 10:24:11 2019 +0000
@@ -112,7 +112,7 @@
(let (case-fold-search)
(goto-char (c-langelem-pos langelem))
(if (looking-at "\\<DEFUN\\>")
- (c-calc-offset '(knr-argdecl-intro))))))
+ c-basic-offset))))
(defun c-block-in-arglist-dwim (arglist-start)
;; This function implements the DWIM to avoid far indentation of
> >> 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.
> I too have yet to notice a problem with other macros.
That's good.
> Thanks,
> --
> Basil
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [handa@m17n.org: C indentation problem]
2019-05-21 10:32 ` Alan Mackenzie
@ 2019-05-21 10:57 ` Basil L. Contovounesios
2019-05-21 12:00 ` Alan Mackenzie
0 siblings, 1 reply; 7+ messages in thread
From: Basil L. Contovounesios @ 2019-05-21 10:57 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel, rms, Kenichi Handa
Alan Mackenzie <acm@muc.de> writes:
> Sorry I missed this post when you posted it at the end of April.
No worries. :)
> The issue goes back to 2006. ;-)
>
> On Tue, Apr 30, 2019 at 14:11:05 +0100, Basil L. Contovounesios wrote:
>> Kenichi Handa <handa@m17n.org> writes:
>
> [ .... ]
>
>> > 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.
>
>> CC Mode 5.33.2 also indents "Emacs 22-style", i.e. to 5 columns, but the
>> current sources, AFAICS, are indented to 2 columns, "Emacs 21-style".
>
> More to the point, we no longer have knr declarations.
>
>> >> 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.
>
>> Shouldn't the now-existing c-lineup-gnu-DEFUN-intro-cont be changed
>> accordingly, to indent to 2 columns instead of 5?
>
> Seeing as how we don't have knr declarations any more, it seems senseless
> now to indent with the CC Mode syntactic symbol knr-argdecl-intro, i.e.
> 5. Instead c-basic-offset (2) seems right.
>
> How about the following patch?
>
> diff -r f9e4e46ed54d cc-align.el
> --- a/cc-align.el Mon May 20 12:34:51 2019 +0000
> +++ b/cc-align.el Tue May 21 10:24:11 2019 +0000
> @@ -112,7 +112,7 @@
> (let (case-fold-search)
> (goto-char (c-langelem-pos langelem))
> (if (looking-at "\\<DEFUN\\>")
> - (c-calc-offset '(knr-argdecl-intro))))))
> + c-basic-offset))))
>
> (defun c-block-in-arglist-dwim (arglist-start)
> ;; This function implements the DWIM to avoid far indentation of
LGTM, thanks.
--
Basil
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [handa@m17n.org: C indentation problem]
2019-05-21 10:57 ` Basil L. Contovounesios
@ 2019-05-21 12:00 ` Alan Mackenzie
0 siblings, 0 replies; 7+ messages in thread
From: Alan Mackenzie @ 2019-05-21 12:00 UTC (permalink / raw)
To: Basil L. Contovounesios; +Cc: emacs-devel
Hello, Basil.
On Tue, May 21, 2019 at 11:57:42 +0100, Basil L. Contovounesios wrote:
> Alan Mackenzie <acm@muc.de> writes:
> >> CC Mode 5.33.2 also indents "Emacs 22-style", i.e. to 5 columns, but the
> >> current sources, AFAICS, are indented to 2 columns, "Emacs 21-style".
> > More to the point, we no longer have knr declarations.
> >> Shouldn't the now-existing c-lineup-gnu-DEFUN-intro-cont be changed
> >> accordingly, to indent to 2 columns instead of 5?
> > Seeing as how we don't have knr declarations any more, it seems senseless
> > now to indent with the CC Mode syntactic symbol knr-argdecl-intro, i.e.
> > 5. Instead c-basic-offset (2) seems right.
> > How about the following patch?
> > diff -r f9e4e46ed54d cc-align.el
> > --- a/cc-align.el Mon May 20 12:34:51 2019 +0000
> > +++ b/cc-align.el Tue May 21 10:24:11 2019 +0000
> > @@ -112,7 +112,7 @@
> > (let (case-fold-search)
> > (goto-char (c-langelem-pos langelem))
> > (if (looking-at "\\<DEFUN\\>")
> > - (c-calc-offset '(knr-argdecl-intro))))))
> > + c-basic-offset))))
> > (defun c-block-in-arglist-dwim (arglist-start)
> > ;; This function implements the DWIM to avoid far indentation of
> LGTM, thanks.
Thanks, I've committed it (with amendments to the doc string).
> --
> Basil
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-05-21 12:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <E1FTnAc-0004Fk-15@fencepost.gnu.org>
2006-04-18 22:15 ` [handa@m17n.org: C indentation problem] Alan Mackenzie
2006-04-19 1:30 ` Kenichi Handa
2019-04-30 13:11 ` Basil L. Contovounesios
2019-05-20 13:51 ` Basil L. Contovounesios
2019-05-21 10:32 ` Alan Mackenzie
2019-05-21 10:57 ` Basil L. Contovounesios
2019-05-21 12:00 ` Alan Mackenzie
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).