nmh-workers
[Top] [All Lists]

Re: check if message is in a particular sequence?

2021-05-01 04:20:27
Hi Paul,

    $ mark -list
    cur: 1
    odd: 1 3 5 7 9
    even: 2 4 6 8 10

    $ mark -seq even -list
    even: 2 4 6 8 10

    $ mark -seq even -list 2-6
    even: 2 4 6               <-- previously output was "even: 2 4 6 8 10"

    $ mark -seq odd -list 2-6
    odd: 3 5          <-- previously output was "odd: 1 3 5 7 9"

Up to here seems fine, assuming ‘2-6’ can also be ‘3 5 2 4 6’ or
‘3 5 even:3’.  IOW, all the things I could normally scan(1), etc.

    $ mark -list 2-6    <-- previously behaved as "mark -list", above
    odd: 3 5
    even: 2 4 6

I would have expected an extra line,

    $ mark -list 2-6
 +  cur: 
    odd: 3 5
    even: 2 4 6

because the messages given are being intersected with the normal
‘mark -list’ output you showed at the start above.  IOW, if no messages
are given then the default is ‘all’.  This seems more orthogonal to me
and means a script can give multiple sequences and expect one line for
each in the output in the order the sequences were stated; there's no
need to parse the ‘foo:’ or ‘bar (private):’ to identify the sequence
involved.

    $ mark -list 1-4    <-- previously behaved as "mark -list", above
    cur: 1
    odd: 1 3
    even: 2 4

An example not given here would be empty sequences, i.e. ones which
don't exist.  Currently:

    $ mark -l -s cur -s foo -s bar -s xyzzy
    cur: 96894
    foo: 
    bar: 97036
    xyzzy: 
    $ 

Still showing empty sequences with the new intersection would again be
less surprising and simpler to explain.

    $ mark -l -s cur -s foo -s bar -s xyzzy notcur
    cur: 
    foo: 
    bar: 97036
    xyzzy: 
    $ 

BTW, ‘first’, etc., aren't sequences, as we know.

    $ p -seq first 42
    pick: sequence name is reserved: first

Yet,

    $ mark -l -s first -s cur -s last -s foo -s bar -s xyzzy
    first: 
    cur: 96894
    last: 
    foo: 
    bar: 97036
    xyzzy: 
    $ 

mark(1) doesn't complain and I'd expect it to as pick does.

How does this new functionality help your original need?  Were you
thinking ‘mark -l -s foo 42’ would either be silent or not depending if
42 were in foo?  If so, what parsing language were you cranking up to
check.  ;-)

Finally, when I've wanted this functionality in the past, I've wondered
if a new pick(1) test would be the way.  Perhaps ‘-msg’ to match
mh-format(5)'s ‘msg’ function.

    pick -msg 42 foo

The exit status would be sufficient to tell if 42 was in sequence foo.

Or if I want to know if any of sequence foo are in bar, xyzzy, or the
last few messages then it would be nice if ‘-msg’s parameter could be
more than a single message number.

    pick -msg foo bar xyzzy last:42

Really, all this brings us back to needing a nice set-based consistent
algebra which all commands take.  :-)  Completely made up, without much
consideration:

    forw subject:nmh \( !address:paul / mime-type:image/jpeg \)

Mercurial, the CVS, Subversion, ... thing, has a couple of notations
which are interesting for identifying files and revisions.  The former
has predicate functions, and the later has operators covering ancestry
because revisions form a tree, much like emails in a thread.

    Specifying file sets  https://manned.org/hg.1#head14
    Specifying revisions  https://manned.org/hg.1#head24

-- 
Cheers, Ralph.

<Prev in Thread] Current Thread [Next in Thread>