From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: T Smith Newsgroups: gmane.emacs.help Subject: How do you make code look pretty?? Date: Wed, 27 Jul 2005 12:47:39 -0400 Message-ID: <4548740a05072709476c2bbd92@mail.gmail.com> Reply-To: T Smith NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0766645039==" X-Trace: sea.gmane.org 1122483740 4501 80.91.229.2 (27 Jul 2005 17:02:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 27 Jul 2005 17:02:20 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 27 19:02:12 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DxpHn-0007JI-Mi for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Jul 2005 19:01:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DxpKC-0001h2-MG for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Jul 2005 13:04:08 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DxpGt-0008U2-I0 for help-gnu-emacs@gnu.org; Wed, 27 Jul 2005 13:00:44 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DxpGo-0008Qf-Hs for help-gnu-emacs@gnu.org; Wed, 27 Jul 2005 13:00:38 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DxpGm-0008Ec-Nm for help-gnu-emacs@gnu.org; Wed, 27 Jul 2005 13:00:36 -0400 Original-Received: from [64.233.170.200] (helo=rproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DxpFH-0001Ud-Pd for help-gnu-emacs@gnu.org; Wed, 27 Jul 2005 12:59:04 -0400 Original-Received: by rproxy.gmail.com with SMTP id c16so343535rne for ; Wed, 27 Jul 2005 09:47:39 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type; b=ZNZfYs//OVYTRjed5+UvKV8G2dd+w3g/w25nuLIS9FX2V39/YOk5oFR3plJaGwG7EqP0mtfZiO5E/NNt7IoNY92/aErsMwx42fZxJ+wmxQ65L5K//n3Z6AXTufd7Q5Xlqysq0ViuZTshsf6277jknHytpdU/FCM7Rb0YV1ve2Us= Original-Received: by 10.38.9.67 with SMTP id 67mr613299rni; Wed, 27 Jul 2005 09:47:39 -0700 (PDT) Original-Received: by 10.38.74.79 with HTTP; Wed, 27 Jul 2005 09:47:39 -0700 (PDT) Original-To: help-gnu-emacs@gnu.org 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:28223 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:28223 --===============0766645039== Content-Type: multipart/alternative; boundary="----=_Part_4991_23671748.1122482859767" ------=_Part_4991_23671748.1122482859767 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Dear emacs helpers, Anyway, I have some code that I want to be formatted to all look the same. I opened a terminal and used: indent file.cpp It worked once on one specific file, but afterwards it always returned any other files that I tried with it. By ruined I mean it was all garbaled text with garbage and had these weird newline characters everywhere that ruined it! ------------------------------ ---------------------------------------- ******************************** My question is what commands will format the code to look nice? I know of the "indent" command but it only seems to do uniform indenting for all the code. What I am asking for is something that does the indenting and auto edits the code to make it look a little more pretty. ************************** I know it sounds crazy that it worked once, but it did! I have the file and it looks really good! I wanted that same thing on the others but it ended up corrupting one of the files with all these "new line characters". I also want to just state for the record that I have searched the emacs functions a lot. And I searched google a lot. But I am still only a newbie to emacs so I really am kinda having trouble with finding any help. Thanks, Trevor When i say "format" or "make it look pretty" I mean it does stuff like: Ex: Take a really long if statement expression and make it into 4 lines instead of just one HUGE expression. Ex: if((expression[x][y]>work[x][y])||(expression[x+1][y]>work[x+1][y])||(expre= ssion[x][y+1]>work[x][y+1])||(expression[x][y-1]>work[x][y-1])|| if (( expression[x-1][y] > work[x-1][y] ) || ( expression[x+1][y] > work[x+1][y] ) || ( expression[x][y+1] > work[x][y+1] ) || ( expression[x][y-1] > work[x][y-1] )) Ex: Take an expression that has no spaces at all and add the proper spaces to it. Ex: a+b becomes a + b Ex: for(inti=3D0;i<10;i++) for( int i =3D 0; i < 10; i++ ) Ex: inline void class::function() inline void class:function() -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -----------------reply by one guy---------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- In this case, I am not even sure that emacs is the right solution for you. There exists a standalone utility called "indent" which will do more of wha= t=20 you want. Some of your issues are style issues for which emacs's c-mode will no= t make modifications. My guess is that the reason it only worked once was=20 that, on that occasion only, you had the whole buffer marked. It is also possible that you tried it on buffers for which emacs did not what language to forma= t for. Another key word you might check into is "prettyprint". Regards, David V. ------=_Part_4991_23671748.1122482859767 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Dear emacs helpers,

Anyway, I have some code that I want to be formatted to all look the
same.  I opened a terminal and used:
indent file.cpp

It worked once on one specific file, but afterwards it always returned
any other files that I tried with it.  By ruined I mean it was all
garbaled text with garbage and had these weird newline characters
everywhere that ruined it!

------------------------------
----------------------------------------
**************= ******************
My question is what commands will format the code to = look nice?  I
know of the "indent" command but it only se= ems to do uniform indenting
for all the code.  What I am asking for is something that does the=
indenting and auto edits the code to make it look a little more
pret= ty.
**************************

I know it sounds crazy that it wor= ked once, but it did!  I have the
file and it looks really good!  I wanted that same thing on the ot= hers
but it ended up corrupting one of the files with all these "ne= w line
characters".  I also want to just state for the record = that I have
searched the emacs functions a lot.  And I searched google a lot. =  But
I am still only a newbie to emacs so I really am kinda having = trouble
with finding any help.


Thanks,
Trevor


<= br>





When i say "format" or "make it look pre= tty" I mean it does stuff like:





Ex:  Take = a really long if statement expression and make it into 4
lines instead o= f just one HUGE expression.
Ex:
if((expression[x][y]>work[x][y])||(expression[x+1][y]>work= [x+1][y])||(expression[x][y+1]>work[x][y+1])||(expression[x][y-1]>wor= k[x][y-1])||

if (( expression[x-1][y] > work[x-1][y] )
 =    || ( expression[x+1][y] > work[x+1][y] )
     || ( expression[x][y+1] > work[x][y+1] )
&n= bsp;    || ( expression[x][y-1] > work[x][y-1] ))


<= br>


Ex: Take an expression that has no spaces at all and add the= proper
spaces to it.  Ex:  a+b becomes a + b

Ex:
for(inti=3D0;i<10;i++)

for( int i =3D 0; i < 10= ; i++ )






Ex:
inline void class::function()
=
inline void
class:function()

=  
--------------------------------------------------
--------------------------------------------------
--------------------------------------------------
--------------------------------------------------
-----------------reply by one guy----------
--------------------------------------------------
--------------------------------------------------
--------------------------------------------------
--------------------------------------------------

In this case, I am not even sure that emacs is the right solution for you.<= br> There exists a standalone utility called "indent" which will do m= ore of what you
want.  Some of your issues are style issues for which emacs's c-mode w= ill not
make modifications.  My guess is that the reason it only worked once w= as that,
on that occasion only, you had the whole buffer marked.  It is also po= ssible
that you tried it on buffers for which emacs did not what language to forma= t
for.

Another key word you might check into is "prettyprint".

Regards,
 David V. ------=_Part_4991_23671748.1122482859767-- --===============0766645039== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs --===============0766645039==--