ref: b37f3b14f650cdee89f44378fa3b5dd2b5daf567
dir: /ml/
#!/bin/rc
# 2015-12-29T18:43:41-0500
#
# SYNOPSIS
# ml listname [ regex | message ]
#
# DESCRIPTION
# Print commands to search or read 9front.org mailing list archives.
#
# EXAMPLES
# First, make sure the mailing list archive is mounted:
# % 9fs 9front
# % ls /n/lists
# /n/lists/9front
# [snip]
#
# Load the entire 9front archive:
# % ml 9front
#
# Search the 9front mailing list for messages containing regex:
# % ml 9front hjdicks
# ml 9front 1423821594.00 # > User-Agent: Mozilla/5.0 (compatible; hjdicks)
#
# Open msg 1423821594.00 from the 9front mailing list:
# % ml 9front 1423821594.00
#
# BUGS
# THIS SCRIPT MAY BE BROKEN AT ANY GIVEN TIME! Download the latest version
# from http://9front.org/extra/rc/ml before reporting bugs.
#
# This script reads messages with mother(1). Download it from
# http://9front.org/extra/rc/mother. To use with nedmail(1), comment
# out references to mother and uncomment references to nedmail.
#
# Opening an entire mailbox (mdir format) requires nupas/fs. Individual
# messages can be opened with default upas/fs.
#
# Large mailboxes may take a VERY long time to open, or may fail to open
# at all.
#
# SEE ALSO
# Plumber rule for individual mdir messages (not 9front.org specific):
# # mdir individual mail message file -> new mail window for message
# type is text
# data matches '[a-zA-Z¡-0-9/\-]+/[0-9]+.[0-9][0-9]'
# plumb to showmail
# plumb start rc -c '@{rfork n; ramfs; bind -ac /tmp `{basename -d '$0'}; upas/fs -f '$0'; window -m -r 4 120 750 600 mother -p 1}'
# #plumb start rc -c '@{rfork n; ramfs; bind -ac /tmp `{basename -d '$0'}; upas/fs -f '$0'; window -m -r 4 120 750 600 upas/nedmail -s /mail/fs/mbox/1}'
#
rfork en
fn usage{
echo usage: $0 '[ listname ] [ regex | message ]' >[1=2]
exit usage
}
if(! ~ $#* 1 2)
usage
mlpath=/n/lists/$1 # Export env var $mlpath to mother(1) so the file path
# to an individual message can be easily snarfed.
if(~ $#* 1){
bind -ac /mail/box/$user /n/lists &&
upas/fs -f $mlpath &&
window -m -r 4 120 750 600 rc -c 'label ml '^$1^'; mother'
#window -m -r 4 120 750 600 rc -c 'label ml '^$1^'; upas/nedmail -r'
}
if not if(~ $#* 2){
if(~ $2 *.[0-9][0-9]){
ramfs &&
bind -ac /tmp $mlpath &&
upas/fs -f $mlpath/$2 &&
window -m -r 4 120 750 600 rc -c 'label ml '^$1^' '^$2^'; mother -p 1'
#window -m -r 4 120 750 600 rc -c 'label ml '^$1^' '^$2^'; upas/nedmail -s /mail/fs/mbox/1'
}
if not{
echo flags i >/n/lists/$1^ctl &&
echo $2 >/n/lists/$1^ctl &&
</n/lists/$1^ctl {
sed 's/^([0-9]+\.[0-9][0-9])/ml '$1' \1/g' |
sed 's/:/ # /'
}
}
}
if not
usage