* align.el: how to align space delimited text tables?
@ 2002-12-19 20:54 Benjamin Rutt
2002-12-19 22:31 ` John Wiegley
2002-12-20 17:36 ` Kevin Rodgers
0 siblings, 2 replies; 7+ messages in thread
From: Benjamin Rutt @ 2002-12-19 20:54 UTC (permalink / raw)
I have a buffer in text-mode that I'd like to align using align.el.
Here are the contents:
max 4096 cs 70 ap_mp 9 t 55% np 63 ap 63
max 6291.456 cs 70 ap_mp 9 t 55% np 63 ap 63
max 8192 cs 70 ap_mp 9 t 55% np 63 ap 63
I'd like to align the fields to the following:
max 4096 cs 70 ap_mp 9 t 55% np 63 ap 63
max 6291.456 cs 70 ap_mp 9 t 55% np 63 ap 63
max 8192 cs 70 ap_mp 9 t 55% np 63 ap 63
Anyone have a good recipe for this?
BTW, I'm using the align.el that comes with Emacs 21.
--
Benjamin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: align.el: how to align space delimited text tables?
2002-12-19 20:54 align.el: how to align space delimited text tables? Benjamin Rutt
@ 2002-12-19 22:31 ` John Wiegley
2002-12-20 1:18 ` Miles Bader
[not found] ` <mailman.448.1040347168.19936.help-gnu-emacs@gnu.org>
2002-12-20 17:36 ` Kevin Rodgers
1 sibling, 2 replies; 7+ messages in thread
From: John Wiegley @ 2002-12-19 22:31 UTC (permalink / raw)
>>>>> On Thu Dec 19, Benjamin writes:
> I'd like to align the fields to the following:
> max 4096 cs 70 ap_mp 9 t 55% np 63 ap 63 max 6291.456 cs 70
> ap_mp 9 t 55% np 63 ap 63 max 8192 cs 70 ap_mp 9 t 55% np 63 ap 63
> Anyone have a good recipe for this?
Without a delimiter, there is no way for align.el to figure this
out. It is only regexp based, not a true parser.
It will align TeX tables, for example, because those use & as a
delimiter.
John
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: align.el: how to align space delimited text tables?
2002-12-19 22:31 ` John Wiegley
@ 2002-12-20 1:18 ` Miles Bader
[not found] ` <mailman.448.1040347168.19936.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Miles Bader @ 2002-12-20 1:18 UTC (permalink / raw)
John Wiegley <johnw@gnu.org> writes:
> > max 4096 cs 70 ap_mp 9 t 55% np 63 ap 63 max 6291.456 cs 70
> > ap_mp 9 t 55% np 63 ap 63 max 8192 cs 70 ap_mp 9 t 55% np 63 ap 63
>
> > Anyone have a good recipe for this?
>
> Without a delimiter, there is no way for align.el to figure this
> out. It is only regexp based, not a true parser.
In this case, the delimiter would appear to be whitespace (e.g. [ \t]+);
does align.el not support that well?
-Miles
--
Ich bin ein Virus. Mach' mit und kopiere mich in Deine .signature.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: align.el: how to align space delimited text tables?
[not found] ` <mailman.448.1040347168.19936.help-gnu-emacs@gnu.org>
@ 2002-12-20 2:18 ` Benjamin Lewis
2002-12-20 8:34 ` John Wiegley
1 sibling, 0 replies; 7+ messages in thread
From: Benjamin Lewis @ 2002-12-20 2:18 UTC (permalink / raw)
On 20 Dec 2002, Miles Bader wrote:
> John Wiegley <johnw@gnu.org> writes:
>>> max 4096 cs 70 ap_mp 9 t 55% np 63 ap 63 max 6291.456 cs 70
>>> ap_mp 9 t 55% np 63 ap 63 max 8192 cs 70 ap_mp 9 t 55% np 63 ap 63
>>
>>> Anyone have a good recipe for this?
>>
>> Without a delimiter, there is no way for align.el to figure this
>> out. It is only regexp based, not a true parser.
>
> In this case, the delimiter would appear to be whitespace (e.g. [ \t]+);
> does align.el not support that well?
In this case, it appears that not all the spaces are to be considered as
delimiters. You have to say something like "treat every other space as a
delimiter".
--
Benjamin Lewis
Now is the time for all good men to come to.
-- Walt Kelly
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: align.el: how to align space delimited text tables?
[not found] ` <mailman.448.1040347168.19936.help-gnu-emacs@gnu.org>
2002-12-20 2:18 ` Benjamin Lewis
@ 2002-12-20 8:34 ` John Wiegley
1 sibling, 0 replies; 7+ messages in thread
From: John Wiegley @ 2002-12-20 8:34 UTC (permalink / raw)
>>>>> On Thu Dec 19, Miles writes:
> In this case, the delimiter would appear to be whitespace (e.g. [
> \t]+); does align.el not support that well?
Try passing that regexp to M-x align-regexp, see if it works...
John
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: align.el: how to align space delimited text tables?
@ 2002-12-20 9:29 Victor Kirk
0 siblings, 0 replies; 7+ messages in thread
From: Victor Kirk @ 2002-12-20 9:29 UTC (permalink / raw)
> max 4096 cs 70 ap_mp 9 t 55% np 63 ap 63
> max 6291.456 cs 70 ap_mp 9 t 55% np 63 ap 63
> max 8192 cs 70 ap_mp 9 t 55% np 63 ap 63
> I'd like to align the fields to the following:
> max 4096 cs 70 ap_mp 9 t 55% np 63 ap 63
> max 6291.456 cs 70 ap_mp 9 t 55% np 63 ap 63
> max 8192 cs 70 ap_mp 9 t 55% np 63 ap 63
> Anyone have a good recipe for this?
Try googling for ws-align.el by Matthias Helmling, this
provides align-cols which does exactly what you want.
--
Vic
This message, including attachments, is intended only for the use by the
person(s) to whom it is addressed. It may contain information which is
privileged and confidential. Copying or use by anybody else is not
authorised. If you are not the intended recipient, please contact the sender
as soon as possible. The views expressed in this communication may not
necessarily be the views held by Serco Integrated Transport.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: align.el: how to align space delimited text tables?
2002-12-19 20:54 align.el: how to align space delimited text tables? Benjamin Rutt
2002-12-19 22:31 ` John Wiegley
@ 2002-12-20 17:36 ` Kevin Rodgers
1 sibling, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2002-12-20 17:36 UTC (permalink / raw)
Benjamin Rutt wrote:
> I have a buffer in text-mode that I'd like to align using align.el.
> Here are the contents:
>
> max 4096 cs 70 ap_mp 9 t 55% np 63 ap 63
> max 6291.456 cs 70 ap_mp 9 t 55% np 63 ap 63
> max 8192 cs 70 ap_mp 9 t 55% np 63 ap 63
>
> I'd like to align the fields to the following:
>
> max 4096 cs 70 ap_mp 9 t 55% np 63 ap 63
> max 6291.456 cs 70 ap_mp 9 t 55% np 63 ap 63
> max 8192 cs 70 ap_mp 9 t 55% np 63 ap 63
>
> Anyone have a good recipe for this?
1. Mark the region (C-x h if the text is the entire contents of the buffer,
or the buffer has already been narrowed to the text).
2. Replace the region:
C-u M-|
awk '{printf("%s %-8s %s %s %s %s %s %s %s %s %s %s\n", C-q C-j
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)}' RET
--
<a href="mailto:<kevin.rodgers@ihs.com>">Kevin Rodgers</a>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-12-20 17:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-19 20:54 align.el: how to align space delimited text tables? Benjamin Rutt
2002-12-19 22:31 ` John Wiegley
2002-12-20 1:18 ` Miles Bader
[not found] ` <mailman.448.1040347168.19936.help-gnu-emacs@gnu.org>
2002-12-20 2:18 ` Benjamin Lewis
2002-12-20 8:34 ` John Wiegley
2002-12-20 17:36 ` Kevin Rodgers
-- strict thread matches above, loose matches on Subject: below --
2002-12-20 9:29 Victor Kirk
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).