shithub: rc

Download patch

ref: c6d76c84ced203089e18cb1d9d3cac63170a62f7
parent: 40a644556006e9fdf7be238c4e0c7a55c65bb3fd
author: sl <sl@x1yg3>
date: Sun Jul 6 18:44:02 EDT 2025

add ml

--- a/INDEX
+++ b/INDEX
@@ -34,6 +34,7 @@
 mailclean - Clean up IMAP litter.
 mkfile - $home/mkfile
 mkufont - Borrow from other fonts to create unicode.font (by cinap_lenrek)
+ml - Print commands to search or read mailing list archives.
 n700 - Set preferred X11 mouse acceleration for Lenovo N700 wireless mouse.
 nauth - rcpu to or rimport from auth.inri.net
 nn - run webcookies/webfs, populate factotum from secstore, perform some binds, run plumber.
--- /dev/null
+++ b/ml
@@ -1,0 +1,85 @@
+#!/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
--