From: Pascal Bourguignon <pjb@informatimago.com>
Subject: Re: How do you make code look pretty??
Date: Wed, 27 Jul 2005 19:40:21 +0200 [thread overview]
Message-ID: <87ek9ktaey.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: mailman.1905.1122483652.20277.help-gnu-emacs@gnu.org
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.
next parent reply other threads:[~2005-07-27 17:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1905.1122483652.20277.help-gnu-emacs@gnu.org>
2005-07-27 17:40 ` Pascal Bourguignon [this message]
2005-07-27 18:49 ` How do you make code look pretty?? David Hansen
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>
2005-07-27 20:24 ` Pascal Bourguignon
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=87ek9ktaey.fsf@thalassa.informatimago.com \
--to=pjb@informatimago.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).