🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nn
1 messages
1 total messages Started by Daniel Smith - Ministry of Silly... Mon, 15 Jul 1991 03:04
1st pass, kill many Subjects in nn, using perl
#1862
Author: Daniel Smith - Ministry of Silly...
Date: Mon, 15 Jul 1991 03:04
114 lines
4392 bytes
	I've got a start on how to kill more than one subject at
a time in nn.  I use a perl script to generate an nn macro on the
fly and run it.  This is even more warped than my posting yesterday
to comp.mail.mush, where I implemented a foreach cmd for mush using perl :-)

	The first thing to do is to create a macro, and bind it
to something like ^Xk.  Here's an initial setup for ~/.nn/init:

# define ctrl-x keymap
make map ctl-x
map both ^X prefix ctl-x


	Now for two macros.  I used 19 & 20, change to suit yourself.
The first one is called by the second one in ~/.nn.init:


#	this macro is needed because it appears that no statements coming
#	after "load" in a macro are executed.  We call this from our kill
#	macro.
#
#	note: use an absolute path here.  I tried $HOME and ~, and
#	went up the wall for a while trying to figure out what the
#	problem was.

define 19
	:load /usr/bermuda/people/daniel/.nn/killmacro
	return
end

#	my kill macro.  I call a perl script which tranforms single
#	articles and ranges of articles into a macro of kill commands.
##	I reset the window size so that redraw is kept to a minimum.
#	One thing I would like to get away from is having the # of lines
#	hardcoded.  How can I set another variable to $lines?
#	This should be considered a first pass.
#
#	daniel@island.com, July 14, 1991

map ctl-x k (
	:set shell /bin/sh
	prompt "enter range of articles, then hit return"
	:!$HOME/bin/nn_range	# perl script
	#:set lines 10
	macro 19
	macro 20
	#:set lines 24
	:set shell $SHELL
)


	The second one up above is controlling everything.  When
you see the prompt "enter range of articles", you may enter
something like "a d f-h <RETURN>".   The perl script is then called
to generate the kill macro (20), which is loaded in by macro 19.
Here's the perl script:

#! /usr/bin/perl
#
#	nn_range - use a range of articles to generate a list of kills
#
#	Daniel Smith, daniel@island.com, July 14, 1991
#
#	this was written to produce batches of nn kill commands

#	a macro in nn calls this, and prints the initial prompt...
#	we define macro 20 in here..could be any number 1..100
@ARTS = split(" ", <STDIN>);
open (STDOUT, "> $ENV{'HOME'}/.nn/killmacro") || die "can't redirect stdout";
print "define 20\n";
for $article (@ARTS) {
	if ($article =~ /\w-\w/) {
		($start, $end) = split (/-/,$article);
		for $char ($start..$end) {
			print "\tkill-select '^M' '$char'", "\n";
		}
	} else {
		print "\tkill-select '^M' '$article'", "\n";
	}
}
print "end\n";


	Some notes on all this:

	1) Sorry about the light show when this runs!  I've commented
	out where I "set lines" because it seemed to cause problems.
	I'm using 6.4.10 on a Sun 3 running 4.0.3.  I was looking for
	a way to cut down on all of the redrawing.

	2) looks like load has to be the last thing called in a macro,
	or has this been patched?

	3) this may hang things up on you if you give too many articles
	to kill at once.  I haven't determined what that threshold is
	yet.

	4) there needs to be a way of saving the state of a variable, so
	that it can be reset later.

	5) using perl to expand a range such as 'a-f' was the fun part.

	5a) major flaw...the range you give should be a a b, etc...you
	have to account for articles having their "names" change

	6) ok, here's a start!  I'd love to see something better.  enjoy,

				Daniel
-- 
   daniel@island.com       daniel@world.std.com       dansmith@well.sf.ca.us
Daniel Smith, Island Graphics, 94903, CA (415) 491 0765 x 250(w), 491 0402(fax)
              Disclaimer: written by a highly caffeinated mammal
$|=1;for("..."," hacker"," perl"," a","just"){print $l=$_.$l,"\015";sleep 1;}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads