🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.mail.mush
Article #337

Re: filtering the response

#337
From: Jesse Buckley
Date: Fri, 04 Sep 1992 18:22
71 lines
2362 bytes
In article <1992Aug28.132940.25322@corwin.barra.com> robertb@BARRA.COM (Robert Brown) writes:
>
>I asked this question long ago, but I don't think it ever actually got
>posted...
>
>I'd like to be able to specify a filter of some sort that filters the
>message that I'm responding to before it gets "autoinclude"d.  I would
>prefer that this filter be an executeable that I can specify, perhaps
>through a variable.
>
>The reason I want to do this is to filter tabs into spaces because the
>tabs get all messed up once they get the indent_str is put onto the
>beginning of each line.
>
>Does anyone know how I can do this?  Is this possible with the current
>mush?  If it is not possible, has anyone implemented something like
>this?

With perl all things are possible.  =)

Set your editor to detabed.  Don't forget this is a hack...

#! /usr/local/bin/perl
#
# Author: Jesse R. Buckley, Jr. (buck@sunyit.edu NIC:JRB69)
#
# detabed -- A quick hack to use tabs the right way...
#
# Useage: detabed file prefix
#

$TEMP	= "$ENV{'HOME'}/.mushtmp$$";
$FILE	= $ARGV[0];
$EDITOR = $ENV{'EDITOR'} || "/usr/ucb/vi";

$prefix= $ARGV[1] || '} ';	# The stuff in the 'quotes' 
				# is the default prefix.
open(IN,"$FILE");
open(OUT,">$TEMP");

$prelen = length($prefix);
while(<IN>)
{

    if (/^$prefix/o)
    {


	$_ = substr($_,$prelen);
	# This is taken verbatim from the Camel book.
        1 while s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
	print OUT "$prefix$_";

    }
    else
    {
        print OUT;
    }

}
close(OUT);
system("cp $TEMP $FILE");
system("rm -f $TEMP");
system("$EDITOR $FILE");


-- 
=) Buck (buck@sunyit.edu)
"There are some micro-organisms that exhibit characteristics of both plants
and animals.  When exposed to light they undergo photosynthesis; and when the
lights go out, they turn into animals.  But then again, don't we all?"
Technical Details
Message-ID: <1992Sep4.182227.27445@pool.info.sunyit.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!rpi!psinntp!psinntp!pool!buck
References: <1992Aug28.132940.25322@corwin.barra.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.mail.mush
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!rpi!psinntp!psinntp!pool!buck
From: buck@pool.info.sunyit.edu (Jesse Buckley)
Subject: Re: filtering the response
Message-ID: <1992Sep4.182227.27445@pool.info.sunyit.edu>
Keywords: filter, responding
Organization: State University of New York -- Institute of Technology
References: <1992Aug28.132940.25322@corwin.barra.com>
Date: Fri, 4 Sep 1992 18:22:27 GMT
Lines: 71