Wandering Thoughts archives

2023-09-29

Understanding the NMH repl command's '-cc me' and '-nocc me' options

Suppose, not hypothetically, that you use NMH as your mail client and that you would like to cc: yourself on all of the mail you send; this is what I do. It's relatively easy to set this up for the NMH comp command, which creates new messages. There are a number of approaches and it's easy to understand all except the most complex ones, and since you have to create the complex ones yourself, presumably anyone who can set it up knows what they're doing. However, understanding what you can do and how it works with the NMH repl command for replying to mail is not so straightforward or helpful, and for years I've been not really understanding what I was doing with it.

(Conventionally NMH people who want to keep a copy of all of their email use 'Fcc:' to automatically file a copy in an NMH folder, but this has various issues similar to the IMAP Sent folder situation.)

When repl replies to a message, it has a set of options to control what additional addresses are included in the message; these are the '-cc all/to/cc/me' and their -nocc versions. What '-cc me' does seems conceptually simple (and it sounds like what I want), but the actual reality of both what it does and how it works is not. If you look at the repl 'replcomps' or 'replgroupcomps' file (the default one is normally in /etc/nmh), you will see a complex mh-format tangle. What this tangle does for the cc: header is it unconditionally takes a bunch of different (potential) sets of addresses and puts them into a bucket, de-duplicating addresses as it goes:

%(formataddr{to}) %(formataddr{cc}) %(formataddr(localmbox))

In effect, what repl does to implement -cc and -nocc is that it filters the resulting collection of addresses (I don't know if this is the literal implementation). An address will be in the actual reply's cc: only if it was in To:, cc: or your local address and the relevant command line switch was given (an option not selected defaults to off, so a bare '-cc to' is normally equivalent to '-cc to -nocc cc -nocc me'). So the repl components file is always trying to cc you (that's the 'localmbox' bit), but whether or not it succeeds depends on if '-cc me' is in effect.

If you specify '-cc me', then your local address (your primary address) is guaranteed to be included in the cc: list. Normally it will be included only once, even if it already appears in To:, cc:, or both; the addresses will be de-duplicated as they're added to the collection, including the addition at the end of 'localmbox' (your local address). If '-nocc me' is in effect, both your local address and any Alternate-Mailboxes addresses from your mh-profile. will be filtered out of cc: (and in fact To: too).

Unfortunately, repl provides no way to either remove only your alternate mailboxes (while still cc'ing your primary one) or not cc: your primary mailbox if any of your alternate mailboxes are already cc'd. You can either cc: yourself and any alternate mailboxes that are already present, or remove everything; alternate mailboxes effectively only get used for '-nocc me', not for '-cc me'. If you almost never want to use '-nocc me', this means that it may not be too useful to list your alternate mailboxes in your .mh_profile. There's also no way to leave any existing cc's of yourself intact while not adding a new one if there wasn't one already; either '-nocc me' will remove any existing ones, or '-cc me' will add one if it's not already there.

(If you try to strip your alternate mailboxes with '-nocc me -cc me', the '-nocc me' has no effect; it turns off '-cc me' and then you turn it back on.)

Because 'repl -group' implies '-cc all' as the default, which includes '-cc me', normally repl will explicitly add a cc: to you in all such group replies, in addition to whoever the original message was explicitly to or cc'd to. As mentioned earlier, there's no real neutral option even without this default '-cc all', since anything not explicitly mentioned as a -cc is (explicitly) filtered out. Repl just doesn't want to leave this alone.

(If you want repl to leave this alone and never want to cc yourself, you need a custom components file that removes the '%(formataddr(localmbox))' bit, and then always supply '-cc me' either implicitly or explicitly to keep repl from removing your addresses from the to and cc address lists.)

If you just want to get an exact copy of the same email everyone else got but don't care about your address appearing in the headers, you can probably use the under-documented NMH 'Dcc:' header, which does what normal mail agents use 'Bcc:' for. NMH has a 'Bcc:', but that doesn't get you a verbatim copy of the message because NMH has opinions there (see send and especially post). You'll need custom 'replcomps' and 'replgroupcomps' files that add 'Dcc: ...' headers. If you do this you probably want to use '-nocc me' all the time, to strip your addresses from the explicit headers.

(I recently did a bunch of experimentation to understand this as part of trying to improve my MH-E environment (cf), so I want to write it down while I remember it. In the end I was able to hack together some elisp magic for MH-E to mostly do what I want, although the result is imperfect.)

unix/NMHReplAndCcMe written at 22:51:36; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.