[nmh-workers] Additional things

Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[nmh-workers] Additional things

Ken Hornstein-2
So, as LONG as I'm thinking about stuff ...

One weakness of the MH format language is that when it deals with a list
of addresses, there is nothing that really handles a list of addresses.
By that I mean that if you have:

To: Foo Bar <[hidden email]>, Blah Arg <[hidden email]>, Some Body <[hidden email]>

If you do:

% scan -format '%(addr{to}'

You get:

[hidden email]

This has always bugged me.  Because of my previous message about S/MIME
support, I'd like to think about ways to extract out email addresses in some
kind of form and have the format language deal with them.

So, a thought about that.  There was a not-implemented loop syntax in the
MH format code; details here:

  https://lists.nongnu.org/archive/html/nmh-workers/2010-12/msg00050.html

That never really got implemented, but it makes me think ... could we
co-op that syntax for something useful?

Let's say it is something like this:

%[%(formataddr{to})%(formataddr({cc})%^%(addr{loop})%#,%]

What does that mean?  We take the addresses in the "To" and "cc" headers,
treat them as a address list, and execute %(addr) on each address (the
pseudo-component "loop" will be set to the value of each address as the
loop progresses).  Everything after %# gets executed between each entry.
So this on the above To: line would end up generating:

[hidden email],[hidden email],[hidden email]

This might be something I could actually implement in a reasonable amount
of time.

--Ken

--
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers
Reply | Threaded
Open this post in threaded view
|

Re: Additional things

Michael Richardson-5

Ken Hornstein <[hidden email]> wrote:
    > Let's say it is something like this:

    > %[%(formataddr{to})%(formataddr({cc})%^%(addr{loop})%#,%]

    > What does that mean?  We take the addresses in the "To" and "cc" headers,
    > treat them as a address list, and execute %(addr) on each address (the
    > pseudo-component "loop" will be set to the value of each address as the
    > loop progresses).  Everything after %# gets executed between each entry.
    > So this on the above To: line would end up generating:

    > [hidden email],[hidden email],[hidden email]

    > This might be something I could actually implement in a reasonable amount
    > of time.

Seems cool to me.
I guess addr{loop} will operate on any ,-seperated list of address-like
things.  I would also guess it would nuke the "My Name" and (comment)
parts beforehand.

--
]               Never tell me the odds!                 | ipv6 mesh networks [
]   Michael Richardson, Sandelman Software Works        |    IoT architect   [
]     [hidden email]  http://www.sandelman.ca/        |   ruby on rails    [


--
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Additional things

Ken Hornstein-2
>I guess addr{loop} will operate on any ,-seperated list of address-like
>things.

That's the idea; I am still thinking about whether or not it should work
on the str register or directly on components (I think the former would
be more useful).

>I would also guess it would nuke the "My Name" and (comment)
>parts beforehand.

Oh, no, not at all.  You could do "%(decode(friendly{loop}))" if you wanted
to.  That's all part of the address and would be available to the parser.

--Ken

--
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers
Reply | Threaded
Open this post in threaded view
|

Re: Additional things

Michael Richardson-5

Ken Hornstein <[hidden email]> wrote:
    >> I guess addr{loop} will operate on any ,-seperated list of address-like
    >> things.

    > That's the idea; I am still thinking about whether or not it should work
    > on the str register or directly on components (I think the former would
    > be more useful).

    >> I would also guess it would nuke the "My Name" and (comment)
    >> parts beforehand.

    > Oh, no, not at all.  You could do "%(decode(friendly{loop}))" if you wanted
    > to.  That's all part of the address and would be available to the parser.

What does friendly{} do exactly?
mh-format just says "user-friendly rendering".

--
]               Never tell me the odds!                 | ipv6 mesh networks [
]   Michael Richardson, Sandelman Software Works        |    IoT architect   [
]     [hidden email]  http://www.sandelman.ca/        |   ruby on rails    [


--
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Additional things

Ken Hornstein-2
>What does friendly{} do exactly?
>mh-format just says "user-friendly rendering".

Hm, I guess we should improve that documentation a bit.

If there's a "personal name" (Anything before <>), then it will return
that.  If there's no personal name but there IS a "note" (comments
string AFTER an email address), it will return that.  If there is neither
of those, it will try to parse the email address as an X400 directory
name and try to extract out a few of the fields from it to return.
If that fails it will just return the bare email address.  Basically,
it's trying to take it's best guess as to what is the real name in an
email address.

I guess in mh-format it would (roughly) be:

        $<(pers{header})%?(note{header})%|%(void(addr{header})%>%(putstr)

If that is any clearer :-)

--Ken

--
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers
Reply | Threaded
Open this post in threaded view
|

Re: Additional things

Michael Richardson-5
Ken Hornstein <[hidden email]> wrote:
    >> What does friendly{} do exactly?
    >> mh-format just says "user-friendly rendering".

    > Hm, I guess we should improve that documentation a bit.

    > If there's a "personal name" (Anything before <>), then it will return
    > that.  If there's no personal name but there IS a "note" (comments
    > string AFTER an email address), it will return that.  If there is neither
    > of those, it will try to parse the email address as an X400 directory
    > name and try to extract out a few of the fields from it to return.
    > If that fails it will just return the bare email address.  Basically,
    > it's trying to take it's best guess as to what is the real name in an
    > email address.

Thanks.

I think that maybe the X400 part could get ripped out as dead code? :-)

Not sure how to do a pull-request with savannah.

https://github.com/mcr/nmh/commit/e9d8f9d13bb4396be20832b2c1ec003f3edbe9ed

--
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Additional things

Ken Hornstein-2
>I think that maybe the X400 part could get ripped out as dead code? :-)

Done!

>Not sure how to do a pull-request with savannah.
>
>https://github.com/mcr/nmh/commit/e9d8f9d13bb4396be20832b2c1ec003f3edbe9ed

And done!

--Ken

--
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers