[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do you make code look pretty??
From: |
Pascal Bourguignon |
Subject: |
Re: How do you make code look pretty?? |
Date: |
Wed, 27 Jul 2005 19:40:21 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
T Smith <trevorboydsmith@gmail.com> writes:
> 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.
You want something specific, so you'll need to write specific emacs
lisp code to implement it.
> 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] ))
Beurk. What'd look "pretty" for me would be:
if((work[x][y]<expression[x][y])
||(work[x+1][y]<expression[x+1][y])
||(work[x][y+1]<expression[x][y+1])
||(work[x][y-1]<expression[x][y-1])){
See what I mean by "specific"...
So, you need to write (at least a partial) parser for C in emacs lisp,
matching C statements and expressions, and reformating them.
--
__Pascal Bourguignon__ http://www.informatimago.com/
The world will now reboot. don't bother saving your artefacts.
- Re: How do you make code look pretty??,
Pascal Bourguignon <=