From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "filebat Mark" Newsgroups: gmane.emacs.help Subject: Re: ident the code Date: Tue, 26 Aug 2008 22:35:51 +0800 Message-ID: References: <87ljyka3kg.fsf@localhorst.mine.nu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_8798_13565366.1219761351786" X-Trace: ger.gmane.org 1219761404 11427 80.91.229.12 (26 Aug 2008 14:36:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Aug 2008 14:36:44 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 26 16:37:38 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KXzfe-0005YC-8E for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Aug 2008 16:37:22 +0200 Original-Received: from localhost ([127.0.0.1]:41810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KXzef-00018y-Uz for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Aug 2008 10:36:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KXzeG-000189-LB for help-gnu-emacs@gnu.org; Tue, 26 Aug 2008 10:35:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KXzeE-00016y-TJ for help-gnu-emacs@gnu.org; Tue, 26 Aug 2008 10:35:56 -0400 Original-Received: from [199.232.76.173] (port=42831 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KXzeE-00016v-F7 for help-gnu-emacs@gnu.org; Tue, 26 Aug 2008 10:35:54 -0400 Original-Received: from wr-out-0506.google.com ([64.233.184.224]:46178) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KXzeC-0002rC-VO for help-gnu-emacs@gnu.org; Tue, 26 Aug 2008 10:35:53 -0400 Original-Received: by wr-out-0506.google.com with SMTP id c30so2273431wra.14 for ; Tue, 26 Aug 2008 07:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=qMyBlmp+YeKRW8filmWQDwOVAKM0Yt9tXmOecarC6X8=; b=Va5PBosaX8WZqzk69/NVb2Wv14hyjNPGNyW35ByylpM6BnM1Bb63Q0MgQKAXxtOdgV PSDYzGuSoPFg+hkOgQEBEWw1CHDOtOlfAeooVdiNAvge0LeA+nuXAtXv0szKx8xLFQ1O kR6c9FNHxvXRoR5S9Cb30Yvbtgu0Ft7LOjKM8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=P2g7nS6JtJSouZNL4F7ZuHPZk4OhgWq5ShKZ6R50K4KDslDzIkIqnC+sMAD4d5nxlV SmlRRCPPqr43vuh5OK73Q9crA/U1LXTWI19Up9SAH9rmtPHtxqRE1/AxOdnyJU8XCeX8 g0qgxWn2RVHv/tlhQdwBoajiZzVIx03gGA8Ds= Original-Received: by 10.90.72.3 with SMTP id u3mr7180349aga.103.1219761351758; Tue, 26 Aug 2008 07:35:51 -0700 (PDT) Original-Received: by 10.90.87.6 with HTTP; Tue, 26 Aug 2008 07:35:51 -0700 (PDT) In-Reply-To: <87ljyka3kg.fsf@localhorst.mine.nu> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:57002 Archived-At: ------=_Part_8798_13565366.1219761351786 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline to Peter: I think our replace-regex doesn't work well. 1) Supposing a code line is "if(s!=0)", it will be changed into "if(s! = 0)". That's definitely not the thing we want. The same problem occurs for "if (s==0)". 2) A line of "strcpy(str, "a=2")", will be changed into "strcpy(str, "a = 2"). So we should spend more effort to solve those problems. ----------------------------------------------------------------------------------------------------------------------- To David: Indent is quite a useful utility. Thanks very much for your suggestion! There are still something that doesn't look good for me. Such as, script1 will be changed to srcipt2. script1 void test(char* str) { int i; i= 2; strcpy(str, "hello"); } script2 void test( char* str ) { int i; i = 2; strcpy(str, "hello"); } But what I want is script3. script3: void test( char* str ) { int i; i = 2; strcpy(str, "hello"); } ----------------------------------------------------------------------------------------------------------------------- I'am sorry to bother you guys. I just curious how skilled programmers indent their codes, to make them look nice. They may have written tons of codes, not only C/C++, but also java, python, whatever. 2008/8/26 David Hansen > On Mon, 25 Aug 2008 21:59:01 +0800 filebat Mark wrote: > > > I think maybe an elisp function can do this job. I am wondering how to > find > > this elisp code, cause I don't want to reinvent the wheel. > > Tried this? It has tons of options. > > INDENT(1) > > NAME > indent - changes the appearance of a C program by inserting or > deleting whitespace. > > David > > > > -- Thanks & Regards Denny Zhang ------=_Part_8798_13565366.1219761351786 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
to Peter:
I think our replace-regex doesn't work well.
1) Supposing a code line is "if(s!=0)", it will be changed into "if(s! = 0)". That's definitely not the thing we want. The same problem occurs for "if (s==0)".
2) A line of "strcpy(str, "a=2")", will be changed into "strcpy(str, "a = 2").

So we should spend more effort to solve those problems.
-----------------------------------------------------------------------------------------------------------------------
To David:
Indent is quite a useful utility. Thanks very much for your suggestion!
There are still something that doesn't look good for me.
Such as, script1 will be changed to srcipt2.
script1

void test(char* str)
{
 int i;
i=    2;
 
strcpy(str,        "hello");
}

script2
void
test( char* str )
{
 int i;
 i = 2;

 strcpy(str, "hello");
}


But what I want is script3.
script3:
void test( char* str )
{
 int i;
 i = 2;
 strcpy(str, "hello");
}

-----------------------------------------------------------------------------------------------------------------------
I'am sorry to bother you guys. I just curious how skilled programmers indent their codes, to make them look nice. They may have written tons of codes, not only C/C++, but also java, python, whatever.


2008/8/26 David Hansen <david.hansen@gmx.net>
On Mon, 25 Aug 2008 21:59:01 +0800 filebat Mark wrote:

> I think maybe an elisp function can do this job. I am wondering how to find
> this elisp code, cause I don't want to reinvent the wheel.

Tried this?  It has tons of options.

INDENT(1)

NAME
      indent  - changes the appearance of a C program by inserting or
      deleting whitespace.

David






--
Thanks & Regards

Denny Zhang

------=_Part_8798_13565366.1219761351786--