From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: =?iso-8859-1?q?Stefan_Reich=F6r?= Newsgroups: gmane.emacs.help Subject: Re: Aligning colums Date: 20 Jan 2005 21:16:13 +0100 Organization: UTA Telekom AG (Customer) Message-ID: <873bwvzwj6.fsf@utanet.at> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1106252396 16403 80.91.229.6 (20 Jan 2005 20:19:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 20 Jan 2005 20:19:56 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 20 21:19:24 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Crim3-0000Mw-00 for ; Thu, 20 Jan 2005 21:19:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Criy4-0007Jf-9L for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Jan 2005 15:31:48 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news2.google.com!proxad.net!newsfeed.stueberl.de!newsfeed.utanet.at!newsspool.utanet.at!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 44 Original-NNTP-Posting-Host: linzu3-217-181.utaonline.at Original-X-Trace: newsreader1.utanet.at 1106252220 17267 212.152.217.181 (20 Jan 2005 20:17:00 GMT) Original-X-Complaints-To: abuse@uta.at Original-NNTP-Posting-Date: 20 Jan 2005 20:17:00 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Original-Xref: shelby.stanford.edu gnu.emacs.help:128025 Original-To: help-gnu-emacs@gnu.org 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: main.gmane.org gmane.emacs.help:23516 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:23516 roy@panix.com (Roy Smith) writes: > I've got a bunch of text that looks like this: > > foo ("arg1", "xxxxxxxxxxxxxx", 1, "xxxx", 2) > foo ("arg1", "xxxxxxxxx", 1, "xxx", 2) > foo ("arg1", "xxxxxxxxxxx", 1, "xxxxxxxx", 2) > foo ("arg1", "xxxxxxxx", 1, "xxxxxx", 2) > foo ("arg1", "xxxxxxxxxx", 1, "xxxxxxx", 2) > > I want to get the arguments lined up so it looks like: > > foo ("arg1", "xxxxxxxxxxxxxx", 1, "xxxx", 2) > foo ("arg1", "xxxxxxxxx", 1, "xxx", 2) > foo ("arg1", "xxxxxxxxxxx", 1, "xxxxxxxx", 2) > foo ("arg1", "xxxxxxxx", 1, "xxxxxx", 2) > foo ("arg1", "xxxxxxxxxx", 1, "xxxxxxx", 2) > > What's the best way to do that? I suspect M-X align is what I want, I > can't make heads or tails out of the on-line help. > > Note, the above text looks like C code, but I seem to run into things > like this is various languages, not just C, so I'm looking for a > general solution. You could use my progr-align.el package: www.xsteve.at/prg/emacs/progr-align.el You specify a header line that matches the columns and the needed widths: // #palign "\w" 4, "(\"\w+\"" 9, "\"" 19, "[0-9]+" 17, "[0-9]+" Then you can put the cursor on a line or mark a region and call M-x progr-align. That aligns the above code the way you wanted it. Let me explain the #palign line: "\w" matches foo, the column should be 4 characters wide "(\"\w+\"" matches "arg1", columnwidth: 9 characters "\"" matches "xxx", columnwidth: 19 "[0-9]+" matches 1, columnwidth: 17 "[0-9]+" matches 2, last column, no width needed Stefan.