unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: T Smith <trevorboydsmith@gmail.com>
Subject: How do you make code look pretty??
Date: Wed, 27 Jul 2005 12:47:39 -0400	[thread overview]
Message-ID: <4548740a05072709476c2bbd92@mail.gmail.com> (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

             reply	other threads:[~2005-07-27 16:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-27 16:47 T Smith [this message]
2005-07-27 20:04 ` How do you make code look pretty?? 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

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=4548740a05072709476c2bbd92@mail.gmail.com \
    --to=trevorboydsmith@gmail.com \
    /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.
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).