all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* CC Mode 5.28 (C); struct braces are not indented in GNU style
@ 2006-11-29  4:56 John Darrington
  2006-11-30 19:48 ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: John Darrington @ 2006-11-29  4:56 UTC (permalink / raw)



GNU coding standards say: 
 "It is important to put the open-brace that starts the body of a C
 function in column one, and avoid putting any other open-brace or
 open-parenthesis or open-bracket in column one"  

But given a code snippet like:

struct foobar  
 {
  int x;
 };

indent-region reformats it as:

struct foobar  
{
  int x;
};

which is contrary to the second clause of this sentence.



Emacs  : GNU Emacs 21.4.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2006-10-25 on raven, modified by Debian
Package: CC Mode 5.28 (C)
Buffer Style: gnu

c-emacs-features: (1-bit)

current state:
==============
(setq
 c-basic-offset 2
 c-comment-only-line-offset '(0 . 0)
 c-block-comment-prefix ""
 c-comment-prefix-regexp '((pike-mode . "//+!?\\|\\**") (other . "//+\\|\\**"))
 c-cleanup-list '(scope-operator)
 c-hanging-braces-alist '((brace-list-open) (brace-entry-open)
			  (substatement-open after)
			  (block-close . c-snug-do-while)
			  (extern-lang-open after) (inexpr-class-open after)
			  (inexpr-class-close before))
 c-hanging-colons-alist nil
 c-hanging-semi&comma-criteria '(c-semi&comma-inside-parenlist)
 c-backslash-column 48
 c-label-minimum-indentation 1
 c-offsets-alist '((string . c-lineup-dont-change)
		   (c . c-lineup-C-comments)
		   (defun-open . 0)
		   (defun-close . 0)
		   (defun-block-intro . +)
		   (class-open . 0)
		   (class-close . 0)
		   (inline-close . 0)
		   (func-decl-cont . +)
		   (knr-argdecl . 0)
		   (topmost-intro . 0)
		   (topmost-intro-cont . 0)
		   (member-init-intro . +)
		   (member-init-cont . c-lineup-multi-inher)
		   (inher-intro . +)
		   (inher-cont . c-lineup-multi-inher)
		   (block-open . 0)
		   (block-close . 0)
		   (brace-list-close . 0)
		   (brace-list-intro . +)
		   (brace-list-entry . 0)
		   (brace-entry-open . 0)
		   (statement . 0)
		   (statement-case-intro . +)
		   (substatement . +)
		   (case-label . 0)
		   (access-label . -)
		   (do-while-closure . 0)
		   (else-clause . 0)
		   (catch-clause . 0)
		   (comment-intro . c-lineup-comment)
		   (arglist-cont . 0)
		   (arglist-cont-nonempty . c-lineup-arglist)
		   (stream-op . c-lineup-streamop)
		   (inclass . +)
		   (cpp-macro . [0])
		   (cpp-macro-cont . c-lineup-dont-change)
		   (friend . 0)
		   (objc-method-intro . [0])
		   (objc-method-args-cont . c-lineup-ObjC-method-args)
		   (objc-method-call-cont . c-lineup-ObjC-method-call)
		   (extern-lang-open . 0)
		   (extern-lang-close . 0)
		   (inextern-lang . +)
		   (namespace-open . 0)
		   (namespace-close . 0)
		   (innamespace . +)
		   (template-args-cont c-lineup-template-args +)
		   (inlambda . c-lineup-inexpr-block)
		   (lambda-intro-cont . +)
		   (inexpr-statement . 0)
		   (inexpr-class . +)
		   (statement-block-intro . +)
		   (knr-argdecl-intro . 5)
		   (substatement-open . +)
		   (label . 0)
		   (statement-case-open . +)
		   (statement-cont . +)
		   (arglist-intro . c-lineup-arglist-intro-after-paren)
		   (arglist-close . c-lineup-arglist)
		   (inline-open . 0)
		   (brace-list-open . +)
		   )
 c-delete-function 'delete-char
 c-electric-pound-behavior nil
 c-indent-comments-syntactically-p nil
 c-tab-always-indent t
 defun-prompt-regexp nil
 tab-width 8
 comment-column 32
 parse-sexp-ignore-comments t
 auto-fill-function nil
 comment-multi-line t
 comment-start-skip "/\\*+ *\\|//+ *"
 fill-prefix nil
 paragraph-start "[ 	]*\\(//+\\|\\**\\)[ 	]*$\\|^\f"
 adaptive-fill-mode t
 adaptive-fill-regexp "[ 	]*\\(//+\\|\\**\\)[ 	]*\\([ 	]*\\([-|#;>*]+[ 	]*\\|(?[0-9]+[.)][ 	]*\\)*\\)"
 )

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: CC Mode 5.28 (C); struct braces are not indented in GNU style
  2006-11-29  4:56 CC Mode 5.28 (C); struct braces are not indented in GNU style John Darrington
@ 2006-11-30 19:48 ` Richard Stallman
  2006-12-14  2:20   ` John Darrington
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2006-11-30 19:48 UTC (permalink / raw)
  Cc: bug-cc-mode, bug-gnu-emacs

    GNU coding standards say: 
     "It is important to put the open-brace that starts the body of a C
     function in column one, and avoid putting any other open-brace or
     open-parenthesis or open-bracket in column one"  


    But given a code snippet like:

    struct foobar  
     {
      int x;
     };

    indent-region reformats it as:

    struct foobar  
    {
      int x;
    };

    which is contrary to the second clause of this sentence.

The standards are too strict; sometimes it is useful for the struct
defintion to be treated as a defun.

I don't think the C indentation commands know how to distinguish
functions from structs.  But perhaps they should not alter
the indentation of a top-level open-brace.

What do others think of that?

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: CC Mode 5.28 (C); struct braces are not indented in GNU style
  2006-11-30 19:48 ` Richard Stallman
@ 2006-12-14  2:20   ` John Darrington
  0 siblings, 0 replies; 3+ messages in thread
From: John Darrington @ 2006-12-14  2:20 UTC (permalink / raw)
  Cc: bug-cc-mode, bug-gnu-emacs


[-- Attachment #1.1: Type: text/plain, Size: 1249 bytes --]

On Thu, Nov 30, 2006 at 02:48:59PM -0500, Richard Stallman wrote:
>     GNU coding standards say: 
>      "It is important to put the open-brace that starts the body of a C
>      function in column one, and avoid putting any other open-brace or
>      open-parenthesis or open-bracket in column one"  
> 
> 
>     But given a code snippet like:
> 
>     struct foobar  
>      {
>       int x;
>      };
> 
>     indent-region reformats it as:
> 
>     struct foobar  
>     {
>       int x;
>     };
> 
>     which is contrary to the second clause of this sentence.
> 
> I don't think the C indentation commands know how to distinguish
> functions from structs.  But perhaps they should not alter
> the indentation of a top-level open-brace.

Braces in a struct initialisation get indented correctly, as in

struct foobar = 
 {
   1,
   2
 };

so it would seem to me, that it wouldn't be too much effort to get

struct foobar
 {
  int x;
  int y;
 };

to indent in the same way.


-- 
John Darrington                                 jmd@csse.uwa.edu.au
University of Western Australia                 http://www.csse.uwa.edu.au/~jmd
PhD Candidate                                   +61 8 6488 4775

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-12-14  2:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-29  4:56 CC Mode 5.28 (C); struct braces are not indented in GNU style John Darrington
2006-11-30 19:48 ` Richard Stallman
2006-12-14  2:20   ` John Darrington

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.