[comp.mail.mh] Can you associate user-defined status bits with each message?

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (02/07/91)

I've always read mail with /usr/ucb/mail, but these days I'm receiving a
few hundred messages a week and am finding the reader inadequate. I need
to keep track of some status bits with each message: e.g., ``I've begun
reading this,'' ``I've finished reading this,'' ``I've sent some
responses,'' ``I've finished sending responses,'' etc. I should be able
to configure the reader to understand these bits and to read and set
them automatically.

Can I do this easily with mh? If so, how? I read through the mh man
pages a while back, and I know that it'll work well for archiving and
indexing mail, keeping track of discussion threads, etc. But I don't see
how to keep track of these status bits---which are simply necessary for
getting through large volumes of mail every day. I may just write the
code from scratch, but I'd rather not if mh can already handle the job.

Feel free to point me to specific parts of man pages if they answer my
question.

---Dan

jromine@buckaroo.ics.uci.edu (John Romine) (02/07/91)

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:
> I need to keep track of some status bits with each message: e.g.,
>``I've begun reading this,'' ``I've finished reading this,'' ``I've
>sent some responses,'' ``I've finished sending responses,'' etc. I
>should be able to configure the reader to understand these bits and to
>read and set them automatically.  Can I do this easily with mh?

You bet!  However, since MH doesn't use AI, it's going to be hard for
it to decide when you've "finished sending responses", but you can flag
messages easily yourself :-).

I don't know if Jerry Peek mentions this technique in his excellent MH
nutshell handbook, but here's what we do for our sysadmin group at UCI.

First, let me describe our problem.  It's slightly more complex than
what you want to do, but is similar.  Since our sysadmin staff share
our "support" +inbox, we need to to alert staff members that a message
is for them.

We use "anno" to annotate messages with `flags', along with a modified
scan format file to show these `flags' in the scan listing.  I'll show
these as csh aliases, but you could as easily make them shell scripts:

	alias attn 'anno -nodate -comp x-attn -text \!*'

We use a staff member's initials for this flag, so an example would be:

	% attn jlr 43

Indicating that "jlr" (i.e., me) should answer message 43.  The scan
format file has a line added just after the date line which looks like:

	%<{x-attn}%3{x-attn}%|   %> \

So a scan line of a message attn'd to "jlr" looks something like:

  43  17/Jan jlr  Joe Bob User       enhancement request <<blah blah...

If a message hasn't been attn'd to anyone yet, the "initials" scan field
is blank.  If I decide this message isn't for me, and attn it to someone
else, their initials will appear (annotations are put at the beginning of
a message, so the most recent annotation comes first).

We also need a way for a staff member to indicate that he's started
working on a problem.  For this we use a similar alias called "todo":

	alias todo 'anno -nodate -comp x-todo -text \!*'

Change the above scan format addition to:

	%<{x-todo}%3{x-todo}*%|%<{x-attn}%3{x-attn} %|    %>%> \

and after marking message 43 with "todo jlr 43", the scan line looks like:

  43  17/Jan jlr* Joe Bob User       enhancement request <<blah blah...

Obviously, you can make up whatever annotations are appropriate for
your purpose.  "repl" already does an annotation (if you put "repl:
-annotate" in your .mh_profile) and the standard scan listing puts a
"-" flag next to the message number if the message has been replied-to.

"pick" works with these flags as well.  To find messages attn'd to
"jlr", use:

	% pick --x-attn jlr

Numerous variations on this are possible.

Since your particular application is simpler, I'd use an alias like:

	alias flag 'anno -nodate -comp status \!*'

and use some flag letter(s) instead of the initials that we use:

	% flag WIP 43		-or-		% flag W 43

to indicate that message 43 is work-in-progress, etc.  A scan format
addition for this would be something like:

	%<{status}%3{status}%|   %> \

This technique has worked quite well for us.  I'll be happy to
answer any questions about this.
--
John Romine

swb@chumley.tn.cornell.edu (Scott Brim) (02/08/91)

Dan, in addition to what John Romine sent about annotations, consider
the simple power of "sequences".  For example, if you want to flag a
message foo as having attribute bar, you say "mark foo -add -sequence
bar" (actually you do this in aliases for common attributes).  A message
can be in as many sequences as you like, and you can manipulate whole
batches of messages in sequences, e.g. "rmm bar".  Also, with a decent
interface (I use GNUemacs) you can temporarily narrow your view of a
folder to just a sequence or set of sequences, and so forth.
							Scott

wohler@sapwdf.UUCP (Bill Wohler) (02/08/91)

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:
>few hundred messages a week and am finding the reader inadequate. I need
>to keep track of some status bits with each message: e.g., ``I've begun

dan,

  john's ideas were pretty cool but perhaps using `mark' might be
  simpler.  the first step would be to add the following to your
  .mh_profile:

	Unseen-Sequence: unseen

  then inc will add new messages in your inbox to the sequence
  "unseen" and show will remove those messages from the sequence.  you
  could add aliases to create your own sequences:

	alias todo 'mark -sequence todo \!*'

  without args it will add the current message in the current folder
  to the sequence foo, or you can specify the message(s) or folder as
  normal.  you can treat the sequence todo as you would "last" or
  "all", etc.

						--bw
						wohler@sap-ag.de

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (02/09/91)

In article <SWB.91Feb7123257@chumley.tn.cornell.edu> swb@chumley.tn.cornell.edu (Scott Brim) writes:
> Dan, in addition to what John Romine sent about annotations, consider
> the simple power of "sequences".

Isn't the number of sequences per folder limited?

---Dan

jerry@ora.com (Jerry Peek) (02/10/91)

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:
> I need to keep track of some status bits with each message: e.g.,
> ``I've begun reading this,'' ``I've finished reading this,'' ``I've
> sent some responses,'' ``I've finished sending responses,'' etc. I
> should be able to configure the reader to understand these bits and to
> read and set them automatically.  Can I do this easily with mh?

The other replies to Dan's questions have been about annotation and
sequences.  They're probably the best ways I can think of.

One method I haven't seen people mention is using multiple folders
and/or subfolders.  You could have folders named like this:
	inbox     (for unread messages)
	begun     (for messages you've begun)
	finished
	...etc...
or, if you've already split your messages into folders, use subfolders:
	foo/unread    bar/unread
	foo/begun     bar/begun
	foo/finished  bar/finished
	...etc...
If you want to change a message's category, just use "refile".
You can also use "refile -link" to put a message into more than one
folder at the same time... although if you also want to ask "which
folders did I link this into?," there's no easy way to answer that
with MH (you can do it with a shell script, though).

Here are some ideas about the pluses and minuses of annotation and
sequences, and some info that I haven't seen people mention yet:
- Annotation lets you put arbitrary text in a message header, like:
	X-bug: Look on line 173 of foo/bar/glop.c
  you can't be as specific with sequences.
- If you want to link messages into multiple folders, annotations will
  show up in all the links.  Annotations also follow the messages when
  you refile them.  Neither of those are true of sequences.
- It's usually faster to search for messages using sequences:
	scan seqname
  than annotations:
        pick --annoname
  because the message numbers for sequences are stored in just two
  files... MH doesn't have to grep every message for the annotations.
- If you want to use scan format files like John mentions, annotations
  will work... but you can't do that sort of thing with sequences.
- "scan" will find the annotation that's closest to the top of a message
  file.  If you annotate a message with the same component more than once,
  scan will use the most recent annotation.  For example, in this header:
	x-attn: jlr
	x-attn: mtr
	To: bug-mh@ics.uci.edu
  the x-attn component will scan as "jlr".  With annotations, you can
  reassign a message to another person or category and keep the whole
  history in the header.  Sequences aren't permanent; annotations are.
- By default, "anno" adds both a date and a text field:
	x-attn: Fri, 8 Feb 91 09:15:45 -0500
	x-attn: jlr
  You might want both (it's a nice way to keep track of *when* you
  put the message in a category), but watch out for problems the
  multiple annotations cause "scan" and "pick".  John used "anno -nodate".
  You can also annotate twice to put the date annotation after the text.
- Instead of aliases like
	alias todo 'mark -sequence todo \!*'
  or shell scripts that do the same thing, I usually make what I call
  "versions" or "links".  They take an entry in the .mh_profile like:
	todo: -sequence todo
  and a symlink named "todo" from my bin directory to the "mark" binary
  file.  These are more efficient than writing a shell script because
  there's no shell to start... and, unlike aliases, you can use these
  versions from other programs, from shell scripts, etc.

Whew.

jromine@buckaroo.ics.uci.edu (John Romine) wrote:
> I don't know if Jerry Peek mentions this technique in his excellent MH
> nutshell handbook...

Gee, thanks. :-)  Yes, all the stuff people have mentioned so far is in
the book, and there's a lot more.  Sorry I can't re-print the book
here :-)... if you've got it, though, look in sections 2.7, 5.2.1, 5.4.1,
7.1-7.4, 7.7, 7.8, 8.5-8.7 (maybe), 9.all, 10.2, and 12.11 for info about
these and related topics.

--Jerry Peek, jerry@ora.com, uunet!ora!jerry

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (02/18/91)

Okay, thanks for all the help. In case anyone cares, I'm now using mh
with multiple folders (each message is linked into either +read,
+unread, or +noread, as well as either +reply, +unreply, or +noreply,
as well as +archive mode 0500, etc., etc., etc.). To solve the problem
of finding out which folders a message is in, I'm using refile -preserve
religiously, with some safeguards to make sure I don't refile -preserve
a message into the same folder (hence wiping it out---not good). I'm
using annotations for longer-term notes and sequences for short-term
manipulations; 10 sequences just aren't enough for the status bits I
need. (Btw, nobody mentioned that anno needs -inplace for messages
linked into several folders; this was a surprise at first.)

Now I just need to add fast indexing, kludge in an NNTP interface, and
catch up on several hundred messages... :-(  Does anyone have an NNTP
reader, or is there just the mh-6.7/miscellany/netnews stuff?

---Dan