Re: Reformatting text using elvis/par
On (06/08/01 12:05), David Champion wrote: > On 2001.08.06, in <[EMAIL PROTECTED]>, "Ailbhe > Leamy" <[EMAIL PROTECTED]> wrote: > > I've been reformatting text using par, before editing it in vi. > > Basically, I've changed my editor to a script that pipes the message > > through par and then opens it in vi. The only trouble with this is > > that it also reformats my signatures at the bottom of the mail. > > I'm not sure exactly how you're running par, but I'd think it's > possible to add in something to set its range. All I could find was "protected characters", which one can set in the environment. But I've obviously done it wrong, as it's not working. > editor="vi '+/^>/;!}par" %s My vi doesn't do what I'd expect here, but This seems to open and close the file without altering it; "Abort unmodified message?". I tried it as editor="vi '+/^>/;!}par'" but it didn't quite work then either... At least, it didn't seem to reformat anything, though it was quite good at leaving the sig where it was. > 2. Use something more complex as your editor filter. Perl or awk > should be able to split up the incoming document nicely. I've attached > an example. This script filters the draft message, then runs the > editor on it, leaving no temporary files behind. Again, this seemed to close the file without altering it, giving me "Abort unmodified message?" as before. Hum. Ailbhe -- Homepage: http://ailbhe.ossifrage.net/
Re: Reformatting text using elvis/par
On 2001.08.06, in <[EMAIL PROTECTED]>, "Ailbhe Leamy" <[EMAIL PROTECTED]> wrote: > Hi > > I've been reformatting text using par, before editing it in vi. > Basically, I've changed my editor to a script that pipes the message > through par and then opens it in vi. The only trouble with this is that > it also reformats my signatures at the bottom of the mail. I'm not sure exactly how you're running par, but I'd think it's possible to add in something to set its range. Two thoughts: 1. Invoke par not as a pipeline, but as an argument to vi. E.g., set editor="vi '+/^>/;!}par" %s My vi doesn't do what I'd expect here, but I hope that's a bug in my vi. I don't know; I'll play with this some more just because I'm curious. 2. Use something more complex as your editor filter. Perl or awk should be able to split up the incoming document nicely. I've attached an example. This script filters the draft message, then runs the editor on it, leaving no temporary files behind. -- -D.[EMAIL PROTECTED]NSITUniversity of Chicago #!/usr/bin/perl $new = $ARGV[0] . ".2"; open (IN, $ARGV[0]); open (OUT, ">$new"); while () { last if (/^>/); print OUT $_; } close (OUT); open (OUT, "|par >>$new"); while () { last if (/^-- /); print OUT $_; } close (OUT); open (OUT, ">>$new"); print OUT $_; while () { print OUT $_; } close (OUT); close (IN); rename($new, $ARGV[0]); system("vi \"$ARGV[0]\""); exit ($?);
Re: Reformatting text using elvis/par
> I've been reformatting text using par, before editing it in vi. > Basically, I've changed my editor to a script that pipes the message > through par and then opens it in vi. The only trouble with this is that > it also reformats my signatures at the bottom of the mail. I use par to reformat paragraph by paragraph. >From .exrc/.vimrc: " reformat paragraph with no arguments: map ** {!}par " reformat paragraph with arguments: map *^V {!}par And PARINIT: .login:setenv PARINIT '67rTbgqR B=.?_A_a Q=_s>|' The keystroke "gqip" (with textwidth set to whatever you like) in vim has more or less the same effect. -- Phil -- Philip <[EMAIL PROTECTED]>
Re: Reformatting text using elvis/par
On (06/08/01 18:16), Suresh Ramasubramanian wrote: > Using a large mallet, Ailbhe Leamy whacked out: > > > I've been reformatting text using par, before editing it in vi. > > Basically, I've changed my editor to a script that pipes the message > > through par and then opens it in vi. The only trouble with this is > > that it also reformats my signatures at the bottom of the mail. > > Try using a vi macro to append your signature on starting vi. But then I couldn't change sigs using folder- and send-hooks... Ailbhe -- Homepage: http://ailbhe.ossifrage.net/
Re: Reformatting text using elvis/par
Using a large mallet, Ailbhe Leamy whacked out: > I've been reformatting text using par, before editing it in vi. > Basically, I've changed my editor to a script that pipes the message > through par and then opens it in vi. The only trouble with this is that > it also reformats my signatures at the bottom of the mail. Try using a vi macro to append your signature on starting vi. -- Suresh Ramasubramanian + Lumber Cartel India - EMail Sturmbannfuhrer, Lower Middle Class Unix Sysadmin