nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: check if message is in a particular sequence?


From: Paul Fox
Subject: Re: check if message is in a particular sequence?
Date: Sat, 01 May 2021 09:35:51 -0400

ralph wrote:
 > 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.

Yes.

 > 
 > >     $ 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

The current behavior matches my requirements, and the (new)
description in the man page describes it.  I wasn't thinking
of it as an intersection, but a membership listing:
       "If msgs are specified, then only the sequence memberships for
       the given messages are shown, either for all se quences, or
       just for those named by -sequence switches."

 > 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.

I understand your need.  How about if adding "-zero" caused sequences
in which the named messages aren't members to be listed as well? 
I.e., "include sequences with 'zero' results", The -zero switch is
already overused by delete (to mean, "invert"), so I don't think this
is too big a leap.  New (additional) man description:
       "Normally sequences in which none of the given msgs are members
       are suppressed in the output.  The -zero switch will cause all
       sequences mentioned on the command line to be listed,
       whether or not they include any of the specified messages."

 > 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: 

Is this actually the desired behavior?  Shouldn't mark instead complain
with "mark: no such sequence as xyzzy"?

I hadn't realized that mark was currently silent about this, and my
patch is not silent like that, when messages are provided:
    $ mark -l -s odd -s xyzzy 
    odd: 1 3 5 7 9
    xyzzy: 
    $ mark -l -s odd -s xyzzy 1
    odd: 1
    mark: no such sequence as xyzzy

The behaviors should clearly match.  I think I'd prefer the error, but
you can try to convince me..

 > ...
 > 
 > 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.

I agree that it should be an error.  And again, it seems that if
"first" is in error, then "xyzzy" should also be considered an error.

 > 
 > 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.  ;-)

Obviously, the same one I'm already running:
    if [ "$(mark -list -sequence foo 42)" ]
    then
        ...

 > 
 > 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
 > 

Perhaps I should have started there.  But the man page for mark came
so close to describing what I wanted that I actually tried it,
assuming/hoping it would already work.

paul

 > 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.
 > 


=----------------------
paul fox, pgf@foxharp.boston.ma.us (arlington, ma, where it's 45.3 degrees)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]