From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Perry Smith Newsgroups: gmane.emacs.help Subject: Re: Formatting code text Date: Sat, 18 Nov 2006 07:37:14 -0600 Message-ID: References: <7416552.post@talk.nabble.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: multipart/mixed; boundary="===============2105498692==" X-Trace: sea.gmane.org 1163857082 15226 80.91.229.2 (18 Nov 2006 13:38:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 18 Nov 2006 13:38:02 +0000 (UTC) Cc: Help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 18 14:37:57 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GlQOC-0005Sy-GV for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Nov 2006 14:37:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GlQOB-0006ZF-4N for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Nov 2006 08:37:47 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GlQNr-0006XQ-5A for help-gnu-emacs@gnu.org; Sat, 18 Nov 2006 08:37:27 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GlQNn-0006VG-Ak for Help-gnu-emacs@gnu.org; Sat, 18 Nov 2006 08:37:26 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GlQNm-0006V8-Ma for Help-gnu-emacs@gnu.org; Sat, 18 Nov 2006 08:37:22 -0500 Original-Received: from [64.192.143.210] (helo=easeserver.easesoftware.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GlQNl-0000Aj-NY for Help-gnu-emacs@gnu.org; Sat, 18 Nov 2006 08:37:22 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by easeserver.easesoftware.com (Postfix) with ESMTP id B9318529414; Sat, 18 Nov 2006 07:37:19 -0600 (CST) Original-Received: from easeserver.easesoftware.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09689-08; Sat, 18 Nov 2006 07:37:15 -0600 (CST) Original-Received: from [64.192.143.210] (easeserver.easesoftware.com [64.192.143.210]) by easeserver.easesoftware.com (Postfix) with ESMTP id 71FCC5293E4; Sat, 18 Nov 2006 07:37:15 -0600 (CST) In-Reply-To: <7416552.post@talk.nabble.com> Original-To: une X-Mailer: Apple Mail (2.752.2) X-Virus-Scanned: by amavisd-new at easesoftware.net 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:38799 Archived-At: --===============2105498692== Content-Type: multipart/alternative; boundary=Apple-Mail-1-866240773 --Apple-Mail-1-866240773 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Nov 18, 2006, at 3:42 AM, une wrote: > > When writing code in C++ or Java I notice that I can get the code > all nicley > aligned and indented correctly by simply adding a comment at the > end of each > line of code. As you enter the //, the line of code moves to its > correct > alignment. What I have been doing is writing my code and periodically > tidying it up by adding // at the end of every line of code. My > question is, > can I speed this aligning and indenting process up by formatting > the entire > file using one command? Emacs obviously knows how much each line > should be > indented, but doing it one line at a time by adding // is laborious. > > PS - I did not mean to cross post, my first post was in the Gnu > Emacs forum. > Not sure how this website works yet. Sorry. > -- Sounds like you are talking about Meta-Control-Q (in C++ mode but probably in Java mode as well). Use it when you are sitting on top of, for example, an open curly brace for a function. Emacs will then reformat the whole function. I would also suggest doing "apropos" (usually hooked to Control-H a) c-indent There is a whole bunch of ways to do it. I find some of them work better than others (at least in older emacs versions) Just in case you don't know... If you find a function that you like and want to see if it is connected to a key, do C-h, w. You will be prompted for the function in the mini-buffer. When you complete it and hit return, it will tell you all the places you can get to that function. HTH, Perry Smith ( pedz@easesoftware.com ) Ease Software, Inc. ( http://www.easesoftware.com ) Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems --Apple-Mail-1-866240773 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1
On Nov 18, 2006, at = 3:42 AM, une wrote:


When = writing code in C++ or Java I notice that I can get the code all = nicley
aligned and indented correctly = by simply adding a comment at the end of each
line of code. As you enter the //, the line of code = moves to its correct
alignment. What I have been = doing is writing my code and periodically
tidying = it up by adding // at the end of every line of code. My question = is,
can I speed this aligning and = indenting process up by formatting the entire
file using one command? Emacs obviously knows how = much each line should be
indented, but = doing it one line at a time by adding // is laborious.

PS - I = did not mean to cross post, my first post was in the Gnu Emacs = forum.
Not sure how this website works = yet. Sorry.
--=A0

Sounds like you are talking about Meta-Control-Q (in C++ mode but = probably in Java mode as well).

Use it when you are sitting = on top of, for example, an open curly brace for a function.=A0 Emacs = will then reformat the whole function.

I would also suggest doing = "apropos" (usually hooked to Control-H a) c-indent

There is a whole bunch of = ways to do it.=A0 I find some of them work better than others (at least = in older emacs versions)

Just in case you don't = know... If you find a function that you like and want to see if it is = connected to a key, do C-h, w.=A0 You will be prompted for the function = in the mini-buffer.=A0 When you complete it and hit return, it will tell = you all the places you can get to that function.

HTH,
Perry Smith = (=A0pedz@easesoftware.com = )
Ease Software, Inc. (=A0http://www.easesoftware.com = )

Low = cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems

=

= --Apple-Mail-1-866240773-- --===============2105498692== 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 --===============2105498692==--