From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Peter Milliken" Newsgroups: gmane.emacs.help Subject: Re: indent-region to indent comments Date: Thu, 11 Dec 2003 07:30:25 +1100 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1071089175 9735 80.91.224.253 (10 Dec 2003 20:46:15 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 10 Dec 2003 20:46:15 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 10 21:46:11 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AUBDn-0002Bm-00 for ; Wed, 10 Dec 2003 21:46:11 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AUC9S-0002k8-IG for geh-help-gnu-emacs@m.gmane.org; Wed, 10 Dec 2003 16:45:46 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!pd7cy1no!pd7cy2so!shaw.ca!news-out.superfeed.net!propagator2-maxim!news-in-maxim.spamkiller.net!snewsf0.syd.ops.aspac.uu.net!nnrp1.ozemail.com.au!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 71 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4927.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 Original-NNTP-Posting-Host: 203.15.64.33 Original-X-Trace: nnrp1.ozemail.com.au 1071088225 203.15.64.33 (Thu, 11 Dec 2003 07:30:25 EST) Original-NNTP-Posting-Date: Thu, 11 Dec 2003 07:30:25 EST Original-Xref: shelby.stanford.edu gnu.emacs.help:119201 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:15140 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:15140 indent-region only works on indenting the beginnings of lines. It knows nothing about comments on the end of lines or the contents of the lines after the first character. To achieve what you want, you need to use a lovely little utility called align.el. Then you could get this: int main(int argc, char **argv) { int a = 5; // first comment double b = 5.0; // second comment long c = 3; // third comment b = a + c; // so as not to get unused variable error return 0; } Note that the declarations are aligned as well :-) Align.el has tremendous power and works off a set of relatively simple rules. You can create your own alignment rules quite easily. Peter "Suhas Pai" wrote in message news:mailman.1528.1071089915.399.help-gnu-emacs@gnu.org... > > If I mark a region and indent it, I find that it > only idents the source lines and not the comment lines. > If my comment-column is set, why the indenting skips > comments? This will save me ton of time having to > do each one using "esc ;". I could always write a macro > but I don't know how to bind a macro to a key. > > Please help. > > Before: > ------- > > int main(int argc, char **argv) > { > int a = 5; // first comment > double b = 5.0; // second comment > long c = 3; // third comment > b = a + c; // so as not to get unused variable error > > return 0; > } > > Expect after ident-region: > -------------------------- > int main(int argc, char **argv) > { > int a = 5; // first comment > double b = 5.0; // second comment > long c = 3; // third comment > b = a + c; // so as not to get unused variable error > > return 0; > } > > > Thanks, > Suhas > >