Re: Modify message after send...?
On 2015-07-19 00:59, David Bremner wrote: mailingli...@nawaz.org writes: BTW, all I really want to do is modify the From: field based on the recipients (for every email, with no default From). I'll welcome suggestions for existing ways to do that. I Googled a little, but didn't find a clear good solution. Furthermore, I expect over time the rules by which I pick the From: field will get more complex than my knowledge of Elisp. I'm afraid it's a bit "some-assembly-required", but let me mention one possible solution. At least if you just want to have a regular expression match on the recipient, then the example configuration in message-templ [1] may be enough to get you started. You'd have to either call message-templ-config-exec in a hook, or bind it to a key and call it manually to set up the headers before sending. [1]: http://pivot.cs.unb.ca/git?p=message-templ.git;a=tree Thanks for this. I'll see if I can follow the Elisp code. After sending my email, it occurred to me that message handling is not notmuch's job - that's passed on to message-mode. I figured message-mode must have some kind of hook before sending the email, and sure enough, it does have message-send-hook. The example at www.gnu.org/software/emacs/manual/html_mono/message.html shows how one can add headers before sending. There's also message-alternative-emails, although that likely works only if you're replying to an email. A little frustrating: They have a number of functions to modify/read fields like Subject, or To - but none for From! So I'll still have to do some surgery. I'll likely use the send-message-hook to: 1. Read the "To" & "cc" values. 2. Pass them to an external Python script. 3. Get the appropriate "From" field from the Python script. 4. Insert it into the From: field. How does one do steps 2 & 3 in Elisp? I just need a pointer. (Just Googled and saw this: http://stackoverflow.com/questions/5014246/how-to-capture-standard-output-of-a-shell-command-in-elisp) Thanks, ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Modify message after send...?
mailinglists at nawaz.org writes: > BTW, all I really want to do is modify the From: field based on the > recipients (for every email, with no default From). I'll welcome > suggestions for existing ways to do that. I Googled a little, but didn't > find a clear good solution. Furthermore, I expect over time the rules by > which I pick the From: field will get more complex than my knowledge of > Elisp. I'm afraid it's a bit "some-assembly-required", but let me mention one possible solution. At least if you just want to have a regular expression match on the recipient, then the example configuration in message-templ [1] may be enough to get you started. You'd have to either call message-templ-config-exec in a hook, or bind it to a key and call it manually to set up the headers before sending. [1]: http://pivot.cs.unb.ca/git?p=message-templ.git;a=tree
Modify message after send...?
On 2015-07-19 00:59, David Bremner wrote: > mailinglists at nawaz.org writes: > >> BTW, all I really want to do is modify the From: field based on the >> recipients (for every email, with no default From). I'll welcome >> suggestions for existing ways to do that. I Googled a little, but >> didn't >> find a clear good solution. Furthermore, I expect over time the >> rules by >> which I pick the From: field will get more complex than my knowledge >> of >> Elisp. > > I'm afraid it's a bit "some-assembly-required", but let me mention > one > possible solution. > > At least if you just want to have a regular expression match on the > recipient, then the example configuration in message-templ [1] may be > enough to get you started. You'd have to either call > message-templ-config-exec in a hook, or bind it to a key and call it > manually to set up the headers before sending. > > [1]: http://pivot.cs.unb.ca/git?p=message-templ.git;a=tree Thanks for this. I'll see if I can follow the Elisp code. After sending my email, it occurred to me that message handling is not notmuch's job - that's passed on to message-mode. I figured message-mode must have some kind of hook before sending the email, and sure enough, it does have message-send-hook. The example at www.gnu.org/software/emacs/manual/html_mono/message.html shows how one can add headers before sending. There's also message-alternative-emails, although that likely works only if you're replying to an email. A little frustrating: They have a number of functions to modify/read fields like Subject, or To - but none for From! So I'll still have to do some surgery. I'll likely use the send-message-hook to: 1. Read the "To" & "cc" values. 2. Pass them to an external Python script. 3. Get the appropriate "From" field from the Python script. 4. Insert it into the From: field. How does one do steps 2 & 3 in Elisp? I just need a pointer. (Just Googled and saw this: http://stackoverflow.com/questions/5014246/how-to-capture-standard-output-of-a-shell-command-in-elisp) Thanks,
Modify message after send...?
>> BTW, all I really want to do is modify the From: field based on the >> recipients (for every email, with no default From). I'll welcome >> suggestions for existing ways to do that. I Googled a little, but didn't >> find a clear good solution. Furthermore, I expect over time the rules by >> which I pick the From: field will get more complex than my knowledge of >> Elisp. I don't know how practical the following is but an alternative which would keep you entirely outside lisp would be to configure sendmail-program to be your python script and let it modify the message and then send it on to whatever sendmail program you use. Getting everything right with command line arguments and the message on stdin (I guess) and keeping any sane form of error handling may be difficult Also, note that sendmail-program is not notmuch specific so if you configure it might affect other emacs mail stuff like gnus. Best wishes Mark
Re: Modify message after send...?
>> BTW, all I really want to do is modify the From: field based on the >> recipients (for every email, with no default From). I'll welcome >> suggestions for existing ways to do that. I Googled a little, but didn't >> find a clear good solution. Furthermore, I expect over time the rules by >> which I pick the From: field will get more complex than my knowledge of >> Elisp. I don't know how practical the following is but an alternative which would keep you entirely outside lisp would be to configure sendmail-program to be your python script and let it modify the message and then send it on to whatever sendmail program you use. Getting everything right with command line arguments and the message on stdin (I guess) and keeping any sane form of error handling may be difficult Also, note that sendmail-program is not notmuch specific so if you configure it might affect other emacs mail stuff like gnus. Best wishes Mark ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Modify message after send...?
mailingli...@nawaz.org writes: > BTW, all I really want to do is modify the From: field based on the > recipients (for every email, with no default From). I'll welcome > suggestions for existing ways to do that. I Googled a little, but didn't > find a clear good solution. Furthermore, I expect over time the rules by > which I pick the From: field will get more complex than my knowledge of > Elisp. I'm afraid it's a bit "some-assembly-required", but let me mention one possible solution. At least if you just want to have a regular expression match on the recipient, then the example configuration in message-templ [1] may be enough to get you started. You'd have to either call message-templ-config-exec in a hook, or bind it to a key and call it manually to set up the headers before sending. [1]: http://pivot.cs.unb.ca/git?p=message-templ.git;a=tree ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Searching for phrases in the body of an email
On Sat, Jul 18, 2015 at 12:34:16PM -0400, Xu Wang wrote: > On Sat, Jul 18, 2015 at 11:32 AM, Suvayu Ali > wrote: > > > Of course this does not help me solve my original goal, but I guess now > > I can try different queries based on your idea. > > Ah I see. Your goal is to search for phrases close to "no plain text". > But if you use fuzzy searching but an exact grep, then it is normal > that the numbers are not consistent, no? Because your grep is not > fuzzy. My grep was this (case insensitive): 'plain[[:space:]/]+text'. Since I thought I was searching for the _phrase_ "plain text", that would be adequately fuzzy. However after following Jani's advice, I realise it wasn't always being treated as a phrase, neither was NEAR being treated as an operator. I wanted to combine a phrase (plain text) with the NEAR query (NEAR no), but maybe that combination is not possible. That's why I tried to combine NEAR and ADJ (as per your suggestion) by grouping them, that does not seem to work either! -- Suvayu Open source is the future. It sets us free.
Searching for phrases in the body of an email
Hi Jani, On Sat, Jul 18, 2015 at 06:53:53PM +0300, Jani Nikula wrote: > On Jul 18, 2015 6:32 PM, "Suvayu Ali" wrote: > > On Sat, Jul 18, 2015 at 10:54:30AM -0400, Xu Wang wrote: > > > > > > First note that I believe notmuch search is case insensitive by > > > default, so your grep should be case insensitive as well. > > > > Good point, I tried that, didn't change the numbers much. The number of > > matches from grep went up to 24, whereas notmuch count says 463. > > > > > More importantly, I'm not sure how 'no NEAR "plain text" ' syntax is > > > parsed. Maybe it is parsed as {no NEAR plain} or {text}. > > > > > > > Exactly, that's what I do not understand. > > > > export NOTMUCH_DEBUG_QUERY=1 > > might help. That helped a lot! This is what I get: $ notmuch count -- no NEAR \"plain\ text\" Query string is: no NEAR "plain text" Exclude query is: Xapian::Query() Final query is: Xapian::Query((Tmail AND Zno:(pos=1) AND near:(pos=2) AND Zplain:(pos=3) AND text:(pos=4))) 465 $ notmuch count -- \"plain\ text\" Query string is: "plain text" Exclude query is: Xapian::Query() Final query is: Xapian::Query((Tmail AND (plain:(pos=1) PHRASE 2 text:(pos=2 870 I wanted the "plain text" to be treated as a phrase, as in the second case. I have tried nesting the quotes. The closest I got to was this: $ notmuch count -- no NEAR 'plain\ text' Query string is: no NEAR plain\ text Exclude query is: Xapian::Query() Final query is: Xapian::Query((Tmail AND (no:(pos=1) NEAR 11 plain:(pos=2)) AND Ztext:(pos=3))) 151 I then tried this: $ notmuch count -- no NEAR \(plain ADJ/1 text\) Query string is: no NEAR (plain ADJ/1 text) Exclude query is: Xapian::Query() Final query is: Xapian::Query((Tmail AND Zno:(pos=1) AND near:(pos=2) AND Zplain:(pos=3) AND (adj:(pos=4) PHRASE 2 1:(pos=5)) AND Ztext:(pos=6))) 0 Again, this is not what I was expecting. With the last one, I was expecting to group "plain" and "text" within a distance of 1, in the given order, and then requring "no" to be near (within 10 words, the default) the "plain ADJ/1 text" combination. Is my understanding of the query language completely wrong? Apart from `man notmuch-search-terms', I looked here: http://xapian.org/docs/queryparser.html Thanks for any help. Cheers, -- Suvayu Open source is the future. It sets us free.