unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How do you make code look pretty??
@ 2005-07-27 16:47 T Smith
  2005-07-27 20:04 ` J. David Boyd
       [not found] ` <mailman.1921.1122495039.20277.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: T Smith @ 2005-07-27 16:47 UTC (permalink / raw)



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

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])||(expression[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=0;i<10;i++)

for( int i = 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 what 
you
want. Some of your issues are style issues for which emacs's c-mode will not
make modifications. My guess is that the reason it only worked once was 
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 format
for.

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

Regards,
David V.

[-- Attachment #1.2: Type: text/html, Size: 3762 bytes --]

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

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

^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <mailman.1905.1122483652.20277.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2005-07-27 20:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-27 16:47 How do you make code look pretty?? T Smith
2005-07-27 20:04 ` J. David Boyd
     [not found] ` <mailman.1921.1122495039.20277.help-gnu-emacs@gnu.org>
2005-07-27 20:24   ` Pascal Bourguignon
     [not found] <mailman.1905.1122483652.20277.help-gnu-emacs@gnu.org>
2005-07-27 17:40 ` Pascal Bourguignon
2005-07-27 18:49   ` David Hansen

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).