nmh-workers
[Top] [All Lists]

Re: sorting uniquely by message-id

2020-09-19 06:08:32
Hi Michael,

I really want to just keep the copy that went through the list,
because that's the one that went into the public archive, and replies
will work better on that version.  But, sometimes some of the messages
get copied to me only, and can't lose them.

So for all emails with the same message-id field, keep just the one with
a list-id field but if none of them have a list-id field then keep all
of them.

I realized I don't want to change the order of the folder.  Instead,
I am doing:

  scan -format '%5(msg),%{message-id},%<(addr{List-Id})%>' +inbox'

and then process this with Perl to do the right thing....

    if(defined($msgnum{$msgid})) {
        if(defined($msglist{$msgid})) {
            @todelete << $msgnum;
        } else {
            $msglist{$msgid} = $listid;
            push(@todelete, $msgnum{$msgid});
        }
    } else {
        $msgnum{$msgid} = $msgnum;
    }

Doesn't that add empty $listids to %msglist?  Consider this input.

    1,m,li@foo  $msgnum{'m'} = 1
    2,m         $msglist{'m'} = ''; push(@todelete, 1);

  156 %09/16   To:"Rob Wilton      asdf.ietf.or Re: [Asdf] Robert Wilton's 
Block
  164 %09/17     Carsten Bormann     asdf.ietf.or Re: [Asdf] Robert Wilton's 
Block
  175 %09/17     "Rob Wilton                      RE: [Asdf] Robert Wilton's 
Block
- 176 %09/17   "Rob Wilton                      RE: [Asdf] Robert Wilton's 
Block
  177 %09/17   "Rob Wilton         asdf.ietf.or Re: [Asdf] Robert Wilton's 
Block
- 178 %09/17     Carsten Bormann                  Re: [Asdf] Robert Wilton's 
Block
  179 %09/17     Carsten Bormann     asdf.ietf.or Re: [Asdf] Robert Wilton's 
Block
- 187 %09/17       David Kemp                       Re: [Asdf] Robert 
Wilton's Block
  188 %09/17       David Kemp          asdf.ietf.or Re: [Asdf] Robert 
Wilton's Block
- 200 %09/17         Carsten Bormann                  Re: [Asdf] Robert 
Wilton's Block
  201 %09/17         Carsten Bormann     asdf.ietf.or Re: [Asdf] Robert 
Wilton's Block
- 180 %09/17   "Rob Wilton                      RE: [Asdf] Robert Wilton's 
Block
  181 %09/17   "Rob Wilton         asdf.ietf.or Re: [Asdf] Robert Wilton's 
Block
- 184 %09/17     Carsten Bormann     asdf.ietf.or Re: [Asdf] Robert Wilton's 
Block
  185 %09/17     Carsten Bormann                  Re: [Asdf] Robert Wilton's 
Block
- 189 %09/17       "Rob Wilton                      RE: [Asdf] Robert 
Wilton's Block
  190 %09/17       "Rob Wilton         asdf.ietf.or Re: [Asdf] Robert 
Wilton's Block
- 193 %09/17         Alexander Pelov                  Re: [Asdf] Robert 
Wilton's Block
  194 %09/17         Alexander Pelov     asdf.ietf.or Re: [Asdf] Robert 
Wilton's Block
- 196 %09/17         Barry Leiba                      Re: [Asdf] Robert 
Wilton's Block
  197 %09/17         Barry Leiba                      Re: [Asdf] Robert 
Wilton's Block
- 198 %09/17           "Rob Wilton         asdf.ietf.or Re: [Asdf] Robert 
Wilton's Block
  199 %09/17           "Rob Wilton                      RE: [Asdf] Robert 
Wilton's Block
  327 %09/18           Carsten Bormann                  Re: [Asdf] Robert 
Wilton's Block

Given

    $ grep -i sequence-negation ~/.mh_profile
    sequence-negation: not

something like this might do.

    mark -seq dup -del all
    pick -seq li --list-id 'z*'
    scan -forma '%{message-id}' li |
    while read -r mi; do
        pick -nozero -seq dup --message-id "$mi" notli
    done

I think that I ought to use something other than , that can't appear
in any of the relevant fields.  ASCII defined this "FS" character
(ASCII 29 or something), and I wonder why we don't use it more
often...  i wonder if the format spec ought to make this easily
accessible?

US should be used for the lowest level, working up through RS and GS to
FS last; ascii(7).  Here's US.

    $ fmttest -forma '%{from}'$'\c_''%{date}' -width 0 . | sed -n l
    Michael Richardson <mcr@sandelman.ca>\037Fri, 18 Sep 2020 16:36:15 -0\
    400$
    $

-- 
Cheers, Ralph.

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