unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
Cc: bug-cc-mode@gnu.org, Richard Stallman <rms@gnu.org>
Subject: Re: [handa@m17n.org: C indentation problem]
Date: Tue, 18 Apr 2006 22:15:00 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.3.96.1060418211302.439V-100000@acm.acm> (raw)
In-Reply-To: <E1FTnAc-0004Fk-15@fencepost.gnu.org>

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)

       reply	other threads:[~2006-04-18 22:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1FTnAc-0004Fk-15@fencepost.gnu.org>
2006-04-18 22:15 ` Alan Mackenzie [this message]
2006-04-19  1:30   ` [handa@m17n.org: C indentation problem] 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.3.96.1060418211302.439V-100000@acm.acm \
    --to=acm@muc.de \
    --cc=bug-cc-mode@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).