newt: honor environment variables $editor and $pager

This commit is contained in:
stanley lieber 2017-05-26 11:15:35 -04:00
parent ce17224eaf
commit 9c70c81e70
2 changed files with 20 additions and 8 deletions

View file

@ -6,6 +6,8 @@ ramfs
argv0=$0 argv0=$0
if(~ $#editor 0) if(~ $#editor 0)
editor=hold editor=hold
if(~ $#pager 0)
pager=cat
group=alt/test group=alt/test
maxposts=30 maxposts=30
mnt=/mnt/news mnt=/mnt/news
@ -97,7 +99,8 @@ fn k{
f $mnt/$* | f $mnt/$* |
grep -v -e '\/([0-9]+|article|body|header|post|xover)$' | grep -v -e '\/([0-9]+|article|body|header|post|xover)$' |
sed 's/^'$"kmnt'\// g /g' | sed 's/^'$"kmnt'\// g /g' |
sort sort |
eval $pager
} }
fn nshift{ shift; echo $* } fn nshift{ shift; echo $* }
fn printhelp{ fn printhelp{
@ -121,14 +124,14 @@ y synchronize message list with server
||cmd pipe raw message to a command ||cmd pipe raw message to a command
? print debug information' ? print debug information'
} }
fn p{ fn np{
if(test $1 -le $#rposts && test -f $mnt/$group/$rposts($1)^/body){ if(test $1 -le $#rposts && test -f $mnt/$group/$rposts($1)^/body){
{ # don't stutter { # don't stutter
grep -e '(^From|^Newsgroups|^Subject|^Date)' $rposts($1)^/header grep -e '(^From|^Newsgroups|^Subject|^Date)' $rposts($1)^/header
echo echo
cat $rposts($1)^/body cat $rposts($1)^/body
} >/tmp/p } >/tmp/p
cat /tmp/p eval $pager /tmp/p
} }
echo echo
go=1 go=1
@ -138,7 +141,7 @@ fn p{
} }
fn P{ fn P{
if(test $1 -le $#rposts && test -f $mnt/$group/$rposts($1)^/article) if(test $1 -le $#rposts && test -f $mnt/$group/$rposts($1)^/article)
cat $rposts($1)^/article eval $pager $rposts($1)^/article
echo echo
go=1 go=1
r=$1 r=$1
@ -262,10 +265,11 @@ while(){
k `{nshift $cmd | sed 's/\./\//g'} k `{nshift $cmd | sed 's/\./\//g'}
case kf' '* case kf' '*
grep -e `{nshift $cmd} $home/lib/newsgroups | grep -e `{nshift $cmd} $home/lib/newsgroups |
sed 's/^/ g /g' sed 's/^/ g /g' |
eval $pager
case p case p
for(i in $r) for(i in $r)
p $i np $i
case P case P
for(i in $r) for(i in $r)
P $i P $i
@ -291,6 +295,8 @@ while(){
cmd=`{echo $"cmd | sed 's/^\|//g'} cmd=`{echo $"cmd | sed 's/^\|//g'}
cat $mnt/$group/^$rposts($post)^/body | eval $cmd cat $mnt/$group/^$rposts($post)^/body | eval $cmd
case '?' case '?'
echo editor: $editor
echo pager: $pager
echo mnt: $mnt echo mnt: $mnt
echo group: $group echo group: $group
echo maxposts: $maxposts echo maxposts: $maxposts
@ -302,12 +308,12 @@ while(){
echo r: $r echo r: $r
case * case *
if(~ $post $posts(1) && ~ $#go 0) if(~ $post $posts(1) && ~ $#go 0)
p $post np $post
if not if(! ~ $post $posts($#posts)){ if not if(! ~ $post $posts($#posts)){
post=`{echo $post^+1 | bc} post=`{echo $post^+1 | bc}
if(test $post -gt $posts($#posts)) if(test $post -gt $posts($#posts))
post=$posts($#posts) post=$posts($#posts)
p $post np $post
} }
} }
} }

6
sys/man/1/newt Normal file → Executable file
View file

@ -142,6 +142,12 @@ with the whole message as standard input.
.TP .TP
\fB"\fP \fB"\fP
Print the current message in quoted form, suitable for reply. Print the current message in quoted form, suitable for reply.
.PP
The environment variables
.B $editor
and
.B $pager
are honored.
.SH FILES .SH FILES
.B $home/lib/newsgroups .B $home/lib/newsgroups
list of newsgroups, one per line list of newsgroups, one per line